aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-07 16:35:17 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-12-07 16:35:17 -0500
commit21b4e736922f546e0f1aa7b9d6c442f309a2444a (patch)
treee1be8645297f8ebe87445251743ebcc52081a20d
parent34161db6b14d984fb9b06c735b7b42f8803f6851 (diff)
parent68380b581383c028830f79ec2670f4a193854aa6 (diff)
Merge branch 'master' of /home/trondmy/kernel/linux-2.6/ into merge_linus
-rw-r--r--Documentation/DMA-API.txt12
-rw-r--r--Documentation/DocBook/kernel-api.tmpl32
-rw-r--r--Documentation/IPMI.txt34
-rw-r--r--Documentation/block/as-iosched.txt6
-rw-r--r--Documentation/devices.txt102
-rw-r--r--Documentation/filesystems/Locking2
-rw-r--r--Documentation/filesystems/fuse.txt21
-rw-r--r--Documentation/filesystems/sysv-fs.txt177
-rw-r--r--Documentation/i386/boot.txt6
-rw-r--r--Documentation/kernel-parameters.txt32
-rw-r--r--Documentation/networking/00-INDEX2
-rw-r--r--Documentation/networking/generic_netlink.txt3
-rw-r--r--Documentation/power/s2ram.txt56
-rw-r--r--Documentation/power/swsusp-and-swap-files.txt60
-rw-r--r--Documentation/power/swsusp.txt18
-rw-r--r--Documentation/power/userland-swsusp.txt64
-rw-r--r--Documentation/stable_api_nonsense.txt3
-rw-r--r--Documentation/sysctl/kernel.txt8
-rw-r--r--Documentation/x86_64/boot-options.txt7
-rw-r--r--MAINTAINERS25
-rw-r--r--REPORTING-BUGS4
-rw-r--r--arch/alpha/kernel/pci.c3
-rw-r--r--arch/alpha/kernel/sys_miata.c10
-rw-r--r--arch/alpha/kernel/sys_nautilus.c2
-rw-r--r--arch/alpha/mm/fault.c2
-rw-r--r--arch/arm/kernel/signal.c1
-rw-r--r--arch/arm/mach-omap1/devices.c2
-rw-r--r--arch/arm/mach-s3c2410/dma.c4
-rw-r--r--arch/arm/mm/fault.c2
-rw-r--r--arch/arm26/kernel/ecard.c4
-rw-r--r--arch/arm26/mm/fault.c2
-rw-r--r--arch/arm26/mm/memc.c6
-rw-r--r--arch/avr32/kernel/kprobes.c1
-rw-r--r--arch/avr32/kernel/signal.c2
-rw-r--r--arch/avr32/mm/dma-coherent.c2
-rw-r--r--arch/cris/mm/fault.c2
-rw-r--r--arch/frv/kernel/futex.c6
-rw-r--r--arch/frv/kernel/setup.c2
-rw-r--r--arch/frv/kernel/signal.c2
-rw-r--r--arch/frv/mm/fault.c2
-rw-r--r--arch/frv/mm/pgalloc.c6
-rw-r--r--arch/h8300/kernel/setup.c2
-rw-r--r--arch/h8300/kernel/signal.c2
-rw-r--r--arch/h8300/kernel/vmlinux.lds.S1
-rw-r--r--arch/i386/Kconfig72
-rw-r--r--arch/i386/Kconfig.cpu19
-rw-r--r--arch/i386/Kconfig.debug10
-rw-r--r--arch/i386/Makefile8
-rw-r--r--arch/i386/Makefile.cpu1
-rw-r--r--arch/i386/boot/compressed/Makefile28
-rw-r--r--arch/i386/boot/compressed/head.S185
-rw-r--r--arch/i386/boot/compressed/misc.c264
-rw-r--r--arch/i386/boot/compressed/relocs.c625
-rw-r--r--arch/i386/boot/compressed/vmlinux.lds43
-rw-r--r--arch/i386/boot/compressed/vmlinux.scr3
-rw-r--r--arch/i386/boot/setup.S42
-rw-r--r--arch/i386/defconfig22
-rw-r--r--arch/i386/kernel/Makefile5
-rw-r--r--arch/i386/kernel/acpi/cstate.c6
-rw-r--r--arch/i386/kernel/acpi/earlyquirk.c21
-rw-r--r--arch/i386/kernel/alternative.c63
-rw-r--r--arch/i386/kernel/apic.c22
-rw-r--r--arch/i386/kernel/apm.c3
-rw-r--r--arch/i386/kernel/asm-offsets.c39
-rw-r--r--arch/i386/kernel/cpu/amd.c5
-rw-r--r--arch/i386/kernel/cpu/common.c249
-rw-r--r--arch/i386/kernel/cpu/intel.c12
-rw-r--r--arch/i386/kernel/cpu/intel_cacheinfo.c11
-rw-r--r--arch/i386/kernel/cpu/mcheck/therm_throt.c2
-rw-r--r--arch/i386/kernel/cpu/mtrr/Makefile4
-rw-r--r--arch/i386/kernel/cpu/mtrr/amd.c2
-rw-r--r--arch/i386/kernel/cpu/mtrr/centaur.c9
-rw-r--r--arch/i386/kernel/cpu/mtrr/cyrix.c25
-rw-r--r--arch/i386/kernel/cpu/mtrr/generic.c78
-rw-r--r--arch/i386/kernel/cpu/mtrr/if.c31
-rw-r--r--arch/i386/kernel/cpu/mtrr/main.c71
-rw-r--r--arch/i386/kernel/cpu/mtrr/mtrr.h25
-rw-r--r--arch/i386/kernel/cpu/proc.c3
-rw-r--r--arch/i386/kernel/cpuid.c3
-rw-r--r--arch/i386/kernel/crash.c66
-rw-r--r--arch/i386/kernel/e820.c894
-rw-r--r--arch/i386/kernel/efi.c17
-rw-r--r--arch/i386/kernel/entry.S331
-rw-r--r--arch/i386/kernel/head.S66
-rw-r--r--arch/i386/kernel/hpet.c7
-rw-r--r--arch/i386/kernel/i8259.c5
-rw-r--r--arch/i386/kernel/io_apic.c66
-rw-r--r--arch/i386/kernel/kprobes.c4
-rw-r--r--arch/i386/kernel/ldt.c4
-rw-r--r--arch/i386/kernel/mca.c13
-rw-r--r--arch/i386/kernel/microcode.c2
-rw-r--r--arch/i386/kernel/module.c11
-rw-r--r--arch/i386/kernel/mpparse.c2
-rw-r--r--arch/i386/kernel/msr.c5
-rw-r--r--arch/i386/kernel/nmi.c42
-rw-r--r--arch/i386/kernel/paravirt.c569
-rw-r--r--arch/i386/kernel/pci-dma.c6
-rw-r--r--arch/i386/kernel/process.c81
-rw-r--r--arch/i386/kernel/ptrace.c18
-rw-r--r--arch/i386/kernel/quirks.c46
-rw-r--r--arch/i386/kernel/reboot.c1
-rw-r--r--arch/i386/kernel/setup.c855
-rw-r--r--arch/i386/kernel/signal.c6
-rw-r--r--arch/i386/kernel/smp.c10
-rw-r--r--arch/i386/kernel/smpboot.c69
-rw-r--r--arch/i386/kernel/sysenter.c6
-rw-r--r--arch/i386/kernel/time.c15
-rw-r--r--arch/i386/kernel/time_hpet.c15
-rw-r--r--arch/i386/kernel/topology.c8
-rw-r--r--arch/i386/kernel/traps.c120
-rw-r--r--arch/i386/kernel/tsc.c1
-rw-r--r--arch/i386/kernel/vm86.c121
-rw-r--r--arch/i386/kernel/vmlinux.lds.S147
-rw-r--r--arch/i386/mach-generic/probe.c4
-rw-r--r--arch/i386/mach-voyager/voyager_cat.c6
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c14
-rw-r--r--arch/i386/math-emu/fpu_emu.h1
-rw-r--r--arch/i386/math-emu/fpu_entry.c3
-rw-r--r--arch/i386/math-emu/fpu_system.h1
-rw-r--r--arch/i386/math-emu/load_store.c2
-rw-r--r--arch/i386/math-emu/reg_ld_str.c15
-rw-r--r--arch/i386/mm/boot_ioremap.c1
-rw-r--r--arch/i386/mm/discontig.c2
-rw-r--r--arch/i386/mm/fault.c12
-rw-r--r--arch/i386/mm/highmem.c26
-rw-r--r--arch/i386/mm/hugetlbpage.c112
-rw-r--r--arch/i386/mm/init.c6
-rw-r--r--arch/i386/mm/pageattr.c24
-rw-r--r--arch/i386/mm/pgtable.c13
-rw-r--r--arch/i386/pci/early.c7
-rw-r--r--arch/i386/pci/irq.c4
-rw-r--r--arch/i386/pci/pcbios.c11
-rw-r--r--arch/i386/power/Makefile2
-rw-r--r--arch/i386/power/cpu.c8
-rw-r--r--arch/i386/power/suspend.c158
-rw-r--r--arch/i386/power/swsusp.S9
-rw-r--r--arch/ia64/ia32/binfmt_elf32.c8
-rw-r--r--arch/ia64/ia32/ia32_support.c2
-rw-r--r--arch/ia64/ia32/ia32priv.h2
-rw-r--r--arch/ia64/ia32/sys_ia32.c2
-rw-r--r--arch/ia64/kernel/kprobes.c2
-rw-r--r--arch/ia64/kernel/palinfo.c2
-rw-r--r--arch/ia64/kernel/perfmon.c2
-rw-r--r--arch/ia64/kernel/salinfo.c2
-rw-r--r--arch/ia64/kernel/topology.c8
-rw-r--r--arch/ia64/mm/hugetlbpage.c5
-rw-r--r--arch/ia64/mm/init.c4
-rw-r--r--arch/m32r/kernel/setup.c4
-rw-r--r--arch/m32r/kernel/signal.c2
-rw-r--r--arch/m32r/mm/discontig.c4
-rw-r--r--arch/m68k/amiga/chipram.c3
-rw-r--r--arch/m68k/atari/hades-pci.c3
-rw-r--r--arch/m68k/mm/fault.c2
-rw-r--r--arch/m68knommu/kernel/vmlinux.lds.S1
-rw-r--r--arch/mips/kernel/binfmt_elfn32.c1
-rw-r--r--arch/mips/kernel/binfmt_elfo32.c1
-rw-r--r--arch/mips/kernel/irixelf.c8
-rw-r--r--arch/mips/mm/dma-coherent.c4
-rw-r--r--arch/mips/mm/dma-ip27.c4
-rw-r--r--arch/mips/mm/dma-ip32.c5
-rw-r--r--arch/mips/mm/dma-noncoherent.c5
-rw-r--r--arch/mips/mm/highmem.c10
-rw-r--r--arch/parisc/kernel/binfmt_elf32.c1
-rw-r--r--arch/parisc/mm/fault.c2
-rw-r--r--arch/powerpc/kernel/crash.c59
-rw-r--r--arch/powerpc/kernel/kprobes.c2
-rw-r--r--arch/powerpc/kernel/rtas_flash.c4
-rw-r--r--arch/powerpc/kernel/signal_32.c2
-rw-r--r--arch/powerpc/kernel/sysfs.c8
-rw-r--r--arch/powerpc/kernel/vdso.c2
-rw-r--r--arch/powerpc/kernel/vmlinux.lds.S1
-rw-r--r--arch/powerpc/mm/hugetlbpage.c7
-rw-r--r--arch/powerpc/mm/init_64.c6
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c6
-rw-r--r--arch/ppc/kernel/vmlinux.lds.S1
-rw-r--r--arch/s390/appldata/appldata_base.c2
-rw-r--r--arch/s390/kernel/binfmt_elf32.c1
-rw-r--r--arch/s390/kernel/kprobes.c2
-rw-r--r--arch/s390/lib/uaccess_std.c6
-rw-r--r--arch/sh/kernel/cpu/sh4/sq.c2
-rw-r--r--arch/sh/kernel/setup.c3
-rw-r--r--arch/sh/kernel/sh_ksyms.c4
-rw-r--r--arch/sh/kernel/signal.c1
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall.c2
-rw-r--r--arch/sh/mm/hugetlbpage.c5
-rw-r--r--arch/sh/mm/pmb.c6
-rw-r--r--arch/sh64/kernel/setup.c4
-rw-r--r--arch/sh64/kernel/signal.c2
-rw-r--r--arch/sh64/mm/fault.c2
-rw-r--r--arch/sh64/mm/hugetlbpage.c5
-rw-r--r--arch/sparc/kernel/vmlinux.lds.S1
-rw-r--r--arch/sparc/mm/highmem.c8
-rw-r--r--arch/sparc64/kernel/binfmt_elf32.c1
-rw-r--r--arch/sparc64/kernel/vmlinux.lds.S1
-rw-r--r--arch/sparc64/mm/hugetlbpage.c5
-rw-r--r--arch/sparc64/mm/init.c4
-rw-r--r--arch/sparc64/mm/tsb.c2
-rw-r--r--arch/um/drivers/daemon_kern.c2
-rw-r--r--arch/um/drivers/line.c6
-rw-r--r--arch/um/drivers/mcast_kern.c2
-rw-r--r--arch/um/drivers/pcap_kern.c2
-rw-r--r--arch/um/drivers/slip_kern.c2
-rw-r--r--arch/um/drivers/slirp_kern.c2
-rw-r--r--arch/um/include/chan_kern.h2
-rw-r--r--arch/um/include/line.h2
-rw-r--r--arch/um/include/sysdep-i386/ptrace.h2
-rw-r--r--arch/um/include/sysdep-i386/stub.h1
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace.h2
-rw-r--r--arch/um/os-Linux/drivers/ethertap_kern.c2
-rw-r--r--arch/um/os-Linux/drivers/tuntap_kern.c2
-rw-r--r--arch/um/sys-i386/ldt.c1
-rw-r--r--arch/um/sys-i386/ptrace_user.c2
-rw-r--r--arch/um/sys-i386/user-offsets.c2
-rw-r--r--arch/v850/kernel/vmlinux.lds.S1
-rw-r--r--arch/x86_64/Kconfig43
-rw-r--r--arch/x86_64/Makefile4
-rw-r--r--arch/x86_64/defconfig27
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c4
-rw-r--r--arch/x86_64/ia32/ia32_signal.c5
-rw-r--r--arch/x86_64/ia32/syscall32.c2
-rw-r--r--arch/x86_64/kernel/apic.c104
-rw-r--r--arch/x86_64/kernel/crash.c69
-rw-r--r--arch/x86_64/kernel/early-quirks.c18
-rw-r--r--arch/x86_64/kernel/entry.S36
-rw-r--r--arch/x86_64/kernel/genapic.c9
-rw-r--r--arch/x86_64/kernel/head64.c6
-rw-r--r--arch/x86_64/kernel/i387.c7
-rw-r--r--arch/x86_64/kernel/i8259.c3
-rw-r--r--arch/x86_64/kernel/io_apic.c258
-rw-r--r--arch/x86_64/kernel/irq.c2
-rw-r--r--arch/x86_64/kernel/kprobes.c2
-rw-r--r--arch/x86_64/kernel/mce.c3
-rw-r--r--arch/x86_64/kernel/mce_amd.c4
-rw-r--r--arch/x86_64/kernel/mpparse.c2
-rw-r--r--arch/x86_64/kernel/nmi.c29
-rw-r--r--arch/x86_64/kernel/pci-calgary.c218
-rw-r--r--arch/x86_64/kernel/pci-dma.c5
-rw-r--r--arch/x86_64/kernel/pci-gart.c3
-rw-r--r--arch/x86_64/kernel/process.c45
-rw-r--r--arch/x86_64/kernel/setup.c24
-rw-r--r--arch/x86_64/kernel/smp.c5
-rw-r--r--arch/x86_64/kernel/smpboot.c8
-rw-r--r--arch/x86_64/kernel/traps.c55
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S9
-rw-r--r--arch/x86_64/kernel/vsyscall.c4
-rw-r--r--arch/x86_64/lib/csum-partial.c4
-rw-r--r--arch/x86_64/lib/delay.c4
-rw-r--r--arch/x86_64/mm/fault.c10
-rw-r--r--arch/x86_64/mm/init.c7
-rw-r--r--arch/x86_64/mm/pageattr.c58
-rw-r--r--block/blktrace.c3
-rw-r--r--block/cfq-iosched.c4
-rw-r--r--block/ll_rw_blk.c10
-rw-r--r--crypto/Kconfig34
-rw-r--r--crypto/Makefile3
-rw-r--r--crypto/api.c15
-rw-r--r--crypto/digest.c48
-rw-r--r--crypto/gf128mul.c466
-rw-r--r--crypto/lrw.c301
-rw-r--r--crypto/tcrypt.c15
-rw-r--r--crypto/tcrypt.h602
-rw-r--r--crypto/xcbc.c348
-rw-r--r--drivers/ata/libata-core.c3
-rw-r--r--drivers/ata/sata_promise.c120
-rw-r--r--drivers/atm/Makefile2
-rw-r--r--drivers/atm/he.c6
-rw-r--r--drivers/base/core.c1
-rw-r--r--drivers/base/cpu.c6
-rw-r--r--drivers/base/dmapool.c4
-rw-r--r--drivers/base/memory.c34
-rw-r--r--drivers/base/topology.c2
-rw-r--r--drivers/block/DAC960.c4
-rw-r--r--drivers/block/Kconfig4
-rw-r--r--drivers/block/aoe/aoeblk.c2
-rw-r--r--drivers/block/cciss.c332
-rw-r--r--drivers/block/cciss.h6
-rw-r--r--drivers/block/cciss_cmd.h3
-rw-r--r--drivers/block/nbd.c16
-rw-r--r--drivers/block/paride/aten.c4
-rw-r--r--drivers/block/paride/bpck.c4
-rw-r--r--drivers/block/paride/bpck6.c17
-rw-r--r--drivers/block/paride/comm.c4
-rw-r--r--drivers/block/paride/dstr.c4
-rw-r--r--drivers/block/paride/epat.c4
-rw-r--r--drivers/block/paride/epia.c4
-rw-r--r--drivers/block/paride/fit2.c4
-rw-r--r--drivers/block/paride/fit3.c4
-rw-r--r--drivers/block/paride/friq.c4
-rw-r--r--drivers/block/paride/frpw.c4
-rw-r--r--drivers/block/paride/jumbo70
-rw-r--r--drivers/block/paride/kbic.c14
-rw-r--r--drivers/block/paride/ktti.c4
-rw-r--r--drivers/block/paride/on20.c4
-rw-r--r--drivers/block/paride/on26.c4
-rw-r--r--drivers/block/paride/paride.c47
-rw-r--r--drivers/block/paride/paride.h4
-rw-r--r--drivers/block/paride/pcd.c8
-rw-r--r--drivers/block/paride/pf.c8
-rw-r--r--drivers/block/paride/pg.c4
-rw-r--r--drivers/block/paride/pt.c4
-rw-r--r--drivers/block/pktcdvd.c2
-rw-r--r--drivers/bluetooth/hci_bcsp.c4
-rw-r--r--drivers/cdrom/optcd.c2
-rw-r--r--drivers/cdrom/sbpcd.c5
-rw-r--r--drivers/char/agp/amd64-agp.c2
-rw-r--r--drivers/char/decserial.c38
-rw-r--r--drivers/char/drm/drm_sman.c1
-rw-r--r--drivers/char/drm/drm_vm.c8
-rw-r--r--drivers/char/hvc_console.c1
-rw-r--r--drivers/char/hvcs.c426
-rw-r--r--drivers/char/hw_random/Kconfig19
-rw-r--r--drivers/char/hw_random/Makefile3
-rw-r--r--drivers/char/ip2/i2cmd.h5
-rw-r--r--drivers/char/ip2/i2lib.c1
-rw-r--r--drivers/char/ipmi/ipmi_bt_sm.c641
-rw-r--r--drivers/char/ipmi/ipmi_devintf.c25
-rw-r--r--drivers/char/ipmi/ipmi_kcs_sm.c18
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c724
-rw-r--r--drivers/char/ipmi/ipmi_poweroff.c114
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c376
-rw-r--r--drivers/char/ipmi/ipmi_smic_sm.c14
-rw-r--r--drivers/char/ipmi/ipmi_watchdog.c121
-rw-r--r--drivers/char/istallion.c4
-rw-r--r--drivers/char/misc.c2
-rw-r--r--drivers/char/mmtimer.c23
-rw-r--r--drivers/char/moxa.c5
-rw-r--r--drivers/char/pcmcia/synclink_cs.c26
-rw-r--r--drivers/char/rio/rio_linux.c8
-rw-r--r--drivers/char/riscom8.c5
-rw-r--r--drivers/char/synclink.c26
-rw-r--r--drivers/char/synclink_gt.c27
-rw-r--r--drivers/char/synclinkmp.c26
-rw-r--r--drivers/char/sysrq.c14
-rw-r--r--drivers/char/toshiba.c1
-rw-r--r--drivers/char/tpm/tpm.c1
-rw-r--r--drivers/char/vt.c16
-rw-r--r--drivers/char/watchdog/pcwd_usb.c2
-rw-r--r--drivers/cpufreq/cpufreq.c2
-rw-r--r--drivers/crypto/Kconfig13
-rw-r--r--drivers/crypto/Makefile1
-rw-r--r--drivers/crypto/geode-aes.c474
-rw-r--r--drivers/crypto/geode-aes.h40
-rw-r--r--drivers/dma/ioatdma.c4
-rw-r--r--drivers/edac/edac_mc.c1
-rw-r--r--drivers/ide/Kconfig16
-rw-r--r--drivers/ide/ide.c19
-rw-r--r--drivers/ide/pci/via82cxxx.c21
-rw-r--r--drivers/ieee1394/eth1394.c2
-rw-r--r--drivers/ieee1394/hosts.c2
-rw-r--r--drivers/ieee1394/nodemgr.c1
-rw-r--r--drivers/ieee1394/ohci1394.c8
-rw-r--r--drivers/ieee1394/pcilynx.c2
-rw-r--r--drivers/ieee1394/raw1394.c40
-rw-r--r--drivers/infiniband/hw/amso1100/c2_vq.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_av.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_cq.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_mrmw.c4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_pd.c2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_av.c2
-rw-r--r--drivers/input/gameport/gameport.c1
-rw-r--r--drivers/input/misc/hp_sdc_rtc.c4
-rw-r--r--drivers/input/serio/serio.c1
-rw-r--r--drivers/input/touchscreen/ads7846.c2
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c34
-rw-r--r--drivers/isdn/gigaset/usb-gigaset.c12
-rw-r--r--drivers/isdn/hisax/isdnhdlc.h8
-rw-r--r--drivers/leds/Kconfig6
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-wrap.c142
-rw-r--r--drivers/macintosh/apm_emu.c3
-rw-r--r--drivers/macintosh/therm_adt746x.c1
-rw-r--r--drivers/macintosh/via-pmu.c2
-rw-r--r--drivers/macintosh/windfarm_core.c1
-rw-r--r--drivers/md/dm-crypt.c70
-rw-r--r--drivers/md/dm-mpath.c2
-rw-r--r--drivers/md/dm-snap.c6
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/md/kcopyd.c2
-rw-r--r--drivers/md/md.c2
-rw-r--r--drivers/md/raid5.c4
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c2
-rw-r--r--drivers/media/dvb/dvb-usb/usb-urb.c2
-rw-r--r--drivers/media/dvb/frontends/l64781.c2
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c2
-rw-r--r--drivers/media/radio/Kconfig32
-rw-r--r--drivers/media/video/msp3400-driver.c2
-rw-r--r--drivers/media/video/tvaudio.c1
-rw-r--r--drivers/media/video/video-buf-dvb.c2
-rw-r--r--drivers/media/video/vivi.c1
-rw-r--r--drivers/message/fusion/mptbase.c255
-rw-r--r--drivers/message/fusion/mptfc.c5
-rw-r--r--drivers/message/fusion/mptscsih.c24
-rw-r--r--drivers/message/fusion/mptspi.c4
-rw-r--r--drivers/message/i2o/bus-osm.c3
-rw-r--r--drivers/message/i2o/device.c27
-rw-r--r--drivers/message/i2o/driver.c20
-rw-r--r--drivers/message/i2o/exec-osm.c10
-rw-r--r--drivers/message/i2o/i2o_block.c15
-rw-r--r--drivers/message/i2o/i2o_block.h2
-rw-r--r--drivers/message/i2o/i2o_config.c8
-rw-r--r--drivers/message/i2o/i2o_proc.c2
-rw-r--r--drivers/message/i2o/i2o_scsi.c23
-rw-r--r--drivers/message/i2o/pci.c5
-rw-r--r--drivers/mfd/ucb1x00-ts.c2
-rw-r--r--drivers/misc/tifm_core.c5
-rw-r--r--drivers/mtd/devices/m25p80.c2
-rw-r--r--drivers/net/3c501.c2
-rw-r--r--drivers/net/3c503.c2
-rw-r--r--drivers/net/3c505.c2
-rw-r--r--drivers/net/3c507.c2
-rw-r--r--drivers/net/3c523.c2
-rw-r--r--drivers/net/3c527.c2
-rw-r--r--drivers/net/ac3200.c2
-rw-r--r--drivers/net/apne.c4
-rw-r--r--drivers/net/appletalk/cops.c2
-rw-r--r--drivers/net/arm/at91_ether.c88
-rw-r--r--drivers/net/arm/at91_ether.h1
-rw-r--r--drivers/net/arm/ether1.c6
-rw-r--r--drivers/net/arm/ether3.c8
-rw-r--r--drivers/net/at1700.c2
-rw-r--r--drivers/net/atarilance.c4
-rw-r--r--drivers/net/bonding/bond_main.c2
-rw-r--r--drivers/net/cs89x0.c2
-rw-r--r--drivers/net/de600.c1
-rw-r--r--drivers/net/declance.c404
-rw-r--r--drivers/net/e2100.c2
-rw-r--r--drivers/net/eepro.c2
-rw-r--r--drivers/net/eexpress.c2
-rw-r--r--drivers/net/es3210.c2
-rw-r--r--drivers/net/eth16i.c2
-rw-r--r--drivers/net/hp-plus.c2
-rw-r--r--drivers/net/hp.c2
-rw-r--r--drivers/net/irda/pxaficp_ir.c26
-rw-r--r--drivers/net/irda/stir4200.c1
-rw-r--r--drivers/net/lance.c2
-rw-r--r--drivers/net/lasi_82596.c94
-rw-r--r--drivers/net/lne390.c2
-rw-r--r--drivers/net/mv643xx_eth.c4
-rw-r--r--drivers/net/mvme147.c4
-rw-r--r--drivers/net/myri10ge/myri10ge.c95
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp.h56
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp_gen_header.h2
-rw-r--r--drivers/net/ne.c2
-rw-r--r--drivers/net/ne2.c2
-rw-r--r--drivers/net/netxen/netxen_nic.h331
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c65
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h6
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c483
-rw-r--r--drivers/net/netxen/netxen_nic_hw.h10
-rw-r--r--drivers/net/netxen/netxen_nic_init.c361
-rw-r--r--drivers/net/netxen/netxen_nic_ioctl.h8
-rw-r--r--drivers/net/netxen/netxen_nic_isr.c51
-rw-r--r--drivers/net/netxen/netxen_nic_main.c306
-rw-r--r--drivers/net/netxen/netxen_nic_niu.c32
-rw-r--r--drivers/net/netxen/netxen_nic_phan_reg.h228
-rw-r--r--drivers/net/ni52.c2
-rw-r--r--drivers/net/ni65.c2
-rw-r--r--drivers/net/ns83820.c25
-rw-r--r--drivers/net/phy/phy.c3
-rw-r--r--drivers/net/r8169.c84
-rw-r--r--drivers/net/seeq8005.c2
-rw-r--r--drivers/net/sk98lin/skgesirq.c2
-rw-r--r--drivers/net/skge.h150
-rw-r--r--drivers/net/sky2.c117
-rw-r--r--drivers/net/sky2.h54
-rw-r--r--drivers/net/smc-ultra.c2
-rw-r--r--drivers/net/smc-ultra32.c2
-rw-r--r--drivers/net/smc9194.c2
-rw-r--r--drivers/net/smc91x.h24
-rw-r--r--drivers/net/sun3lance.c4
-rw-r--r--drivers/net/tg3.c142
-rw-r--r--drivers/net/tg3.h1
-rw-r--r--drivers/net/tokenring/smctr.c2
-rw-r--r--drivers/net/wd.c2
-rw-r--r--drivers/net/wireless/airo.c1
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c3
-rw-r--r--drivers/net/wireless/hostap/hostap_download.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c12
-rw-r--r--drivers/net/wireless/hostap/hostap_info.c3
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c12
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c3
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c3
-rw-r--r--drivers/net/wireless/ipw2100.c2
-rw-r--r--drivers/net/wireless/ipw2200.c24
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c9
-rw-r--r--drivers/net/wireless/prism54/oid_mgt.c4
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c13
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h43
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c53
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h3
-rw-r--r--drivers/net/wireless/zd1211rw/zd_netdev.c2
-rw-r--r--drivers/parport/parport_pc.c12
-rw-r--r--drivers/pci/msi.c2
-rw-r--r--drivers/pci/probe.c1
-rw-r--r--drivers/pcmcia/cs.c1
-rw-r--r--drivers/pnp/card.c30
-rw-r--r--drivers/pnp/interface.c17
-rw-r--r--drivers/pnp/pnpbios/core.c4
-rw-r--r--drivers/rtc/Kconfig12
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-ds1672.c9
-rw-r--r--drivers/rtc/rtc-ds1742.c67
-rw-r--r--drivers/rtc/rtc-omap.c572
-rw-r--r--drivers/rtc/rtc-rs5c372.c90
-rw-r--r--drivers/rtc/rtc-test.c9
-rw-r--r--drivers/rtc/rtc-x1205.c12
-rw-r--r--drivers/s390/block/dasd_devmap.c2
-rw-r--r--drivers/s390/block/dasd_eckd.c2
-rw-r--r--drivers/s390/block/dasd_fba.c2
-rw-r--r--drivers/s390/block/dasd_int.h2
-rw-r--r--drivers/s390/scsi/zfcp_def.h6
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c2
-rw-r--r--drivers/scsi/53c700.c82
-rw-r--r--drivers/scsi/53c700.h16
-rw-r--r--drivers/scsi/aic94xx/aic94xx.h4
-rw-r--r--drivers/scsi/aic94xx/aic94xx_hwi.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c4
-rw-r--r--drivers/scsi/ide-scsi.c6
-rw-r--r--drivers/scsi/ipr.c2
-rw-r--r--drivers/scsi/libsas/sas_init.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c2
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c2
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_lib.c4
-rw-r--r--drivers/scsi/scsi_tgt_lib.c2
-rw-r--r--drivers/serial/8250_exar_st16c554.c52
-rw-r--r--drivers/serial/8250_pnp.c29
-rw-r--r--drivers/serial/Kconfig30
-rw-r--r--drivers/serial/Makefile2
-rw-r--r--drivers/serial/amba-pl010.c2
-rw-r--r--drivers/serial/dz.c371
-rw-r--r--drivers/serial/dz.h32
-rw-r--r--drivers/serial/mpsc.c22
-rw-r--r--drivers/serial/uartlite.c505
-rw-r--r--drivers/spi/spi.c25
-rw-r--r--drivers/spi/spi_bitbang.c2
-rw-r--r--drivers/spi/spi_butterfly.c2
-rw-r--r--drivers/usb/atm/ueagle-atm.c2
-rw-r--r--drivers/usb/core/buffer.c2
-rw-r--r--drivers/usb/core/hub.c7
-rw-r--r--drivers/usb/core/message.c2
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/gmidi.c2
-rw-r--r--drivers/usb/gadget/goku_udc.c2
-rw-r--r--drivers/usb/gadget/inode.c6
-rw-r--r--drivers/usb/gadget/net2280.c2
-rw-r--r--drivers/usb/gadget/omap_udc.c2
-rw-r--r--drivers/usb/gadget/zero.c2
-rw-r--r--drivers/usb/host/ehci-dbg.c2
-rw-r--r--drivers/usb/host/hc_crisv10.c16
-rw-r--r--drivers/usb/host/ohci-dbg.c2
-rw-r--r--drivers/usb/host/ohci-pnx4008.c2
-rw-r--r--drivers/usb/host/uhci-hcd.c2
-rw-r--r--drivers/usb/host/uhci-q.c2
-rw-r--r--drivers/usb/input/acecad.c2
-rw-r--r--drivers/usb/input/aiptek.c2
-rw-r--r--drivers/usb/input/ati_remote.c6
-rw-r--r--drivers/usb/input/hid-core.c10
-rw-r--r--drivers/usb/input/keyspan_remote.c2
-rw-r--r--drivers/usb/input/mtouchusb.c2
-rw-r--r--drivers/usb/input/powermate.c4
-rw-r--r--drivers/usb/input/touchkitusb.c2
-rw-r--r--drivers/usb/input/usbkbd.c8
-rw-r--r--drivers/usb/input/usbmouse.c4
-rw-r--r--drivers/usb/input/usbtouchscreen.c2
-rw-r--r--drivers/usb/input/xpad.c2
-rw-r--r--drivers/usb/input/yealink.c6
-rw-r--r--drivers/usb/misc/phidgetkit.c4
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c4
-rw-r--r--drivers/usb/misc/usbtest.c36
-rw-r--r--drivers/usb/mon/mon_text.c10
-rw-r--r--drivers/usb/net/catc.c2
-rw-r--r--drivers/usb/net/net1080.c2
-rw-r--r--drivers/usb/net/pegasus.c2
-rw-r--r--drivers/usb/net/rndis_host.c2
-rw-r--r--drivers/usb/net/rtl8150.c2
-rw-r--r--drivers/usb/net/usbnet.c4
-rw-r--r--drivers/usb/serial/mos7720.c2
-rw-r--r--drivers/usb/serial/mos7840.c4
-rw-r--r--drivers/usb/storage/onetouch.c4
-rw-r--r--drivers/usb/storage/transport.c2
-rw-r--r--drivers/usb/storage/usb.c2
-rw-r--r--drivers/video/geode/gxfb_core.c2
-rw-r--r--drivers/w1/Makefile4
-rw-r--r--drivers/w1/slaves/Makefile4
-rw-r--r--drivers/w1/slaves/w1_ds2433.c30
-rw-r--r--drivers/w1/w1.c1
-rw-r--r--fs/9p/vfs_inode.c4
-rw-r--r--fs/adfs/super.c8
-rw-r--r--fs/affs/amigaffs.c4
-rw-r--r--fs/affs/bitmap.c3
-rw-r--r--fs/affs/super.c6
-rw-r--r--fs/afs/kafsasyncd.c1
-rw-r--r--fs/afs/kafstimod.c1
-rw-r--r--fs/afs/server.c3
-rw-r--r--fs/afs/super.c12
-rw-r--r--fs/aio.c20
-rw-r--r--fs/autofs/inode.c7
-rw-r--r--fs/autofs4/inode.c7
-rw-r--r--fs/befs/linuxvfs.c6
-rw-r--r--fs/bfs/inode.c6
-rw-r--r--fs/binfmt_elf.c26
-rw-r--r--fs/binfmt_elf_fdpic.c3
-rw-r--r--fs/bio.c4
-rw-r--r--fs/block_dev.c6
-rw-r--r--fs/buffer.c6
-rw-r--r--fs/cifs/cifsfs.c17
-rw-r--r--fs/cifs/connect.c1
-rw-r--r--fs/cifs/misc.c4
-rw-r--r--fs/cifs/transport.c6
-rw-r--r--fs/coda/inode.c6
-rw-r--r--fs/compat.c37
-rw-r--r--fs/compat_ioctl.c34
-rw-r--r--fs/configfs/configfs_internal.h2
-rw-r--r--fs/configfs/mount.c2
-rw-r--r--fs/cramfs/inode.c2
-rw-r--r--fs/dcache.c22
-rw-r--r--fs/dcookies.c2
-rw-r--r--fs/dlm/Kconfig20
-rw-r--r--fs/dlm/Makefile4
-rw-r--r--fs/dlm/dlm_internal.h4
-rw-r--r--fs/dlm/lock.c16
-rw-r--r--fs/dlm/lockspace.c4
-rw-r--r--fs/dlm/lowcomms-sctp.c (renamed from fs/dlm/lowcomms.c)264
-rw-r--r--fs/dlm/lowcomms-tcp.c1189
-rw-r--r--fs/dlm/lowcomms.h2
-rw-r--r--fs/dlm/main.c10
-rw-r--r--fs/dlm/member.c8
-rw-r--r--fs/dlm/memory.c2
-rw-r--r--fs/dlm/rcom.c58
-rw-r--r--fs/dlm/recover.c1
-rw-r--r--fs/dlm/recoverd.c44
-rw-r--r--fs/dlm/requestqueue.c26
-rw-r--r--fs/dlm/requestqueue.h2
-rw-r--r--fs/dnotify.c4
-rw-r--r--fs/dquot.c4
-rw-r--r--fs/ecryptfs/crypto.c6
-rw-r--r--fs/ecryptfs/file.c2
-rw-r--r--fs/ecryptfs/inode.c6
-rw-r--r--fs/ecryptfs/keystore.c2
-rw-r--r--fs/ecryptfs/main.c8
-rw-r--r--fs/ecryptfs/super.c2
-rw-r--r--fs/efs/super.c6
-rw-r--r--fs/eventpoll.c8
-rw-r--r--fs/exec.c5
-rw-r--r--fs/ext2/ioctl.c6
-rw-r--r--fs/ext2/super.c24
-rw-r--r--fs/ext2/xattr.c5
-rw-r--r--fs/ext3/Makefile2
-rw-r--r--fs/ext3/balloc.c31
-rw-r--r--fs/ext3/dir.c3
-rw-r--r--fs/ext3/ext3_jbd.c59
-rw-r--r--fs/ext3/inode.c85
-rw-r--r--fs/ext3/namei.c9
-rw-r--r--fs/ext3/super.c17
-rw-r--r--fs/ext3/xattr.c5
-rw-r--r--fs/ext4/Makefile3
-rw-r--r--fs/ext4/balloc.c31
-rw-r--r--fs/ext4/dir.c3
-rw-r--r--fs/ext4/ext4_jbd2.c59
-rw-r--r--fs/ext4/extents.c110
-rw-r--r--fs/ext4/inode.c85
-rw-r--r--fs/ext4/namei.c9
-rw-r--r--fs/ext4/super.c17
-rw-r--r--fs/ext4/xattr.c5
-rw-r--r--fs/fat/cache.c6
-rw-r--r--fs/fat/inode.c6
-rw-r--r--fs/fcntl.c4
-rw-r--r--fs/file.c29
-rw-r--r--fs/freevxfs/vxfs_inode.c6
-rw-r--r--fs/fuse/dev.c4
-rw-r--r--fs/fuse/dir.c5
-rw-r--r--fs/fuse/file.c37
-rw-r--r--fs/fuse/fuse_i.h9
-rw-r--r--fs/fuse/inode.c123
-rw-r--r--fs/gfs2/Kconfig1
-rw-r--r--fs/gfs2/acl.c39
-rw-r--r--fs/gfs2/acl.h1
-rw-r--r--fs/gfs2/bmap.c179
-rw-r--r--fs/gfs2/daemon.c7
-rw-r--r--fs/gfs2/dir.c93
-rw-r--r--fs/gfs2/dir.h8
-rw-r--r--fs/gfs2/eaops.c2
-rw-r--r--fs/gfs2/eattr.c66
-rw-r--r--fs/gfs2/eattr.h6
-rw-r--r--fs/gfs2/glock.c36
-rw-r--r--fs/gfs2/glock.h3
-rw-r--r--fs/gfs2/glops.c138
-rw-r--r--fs/gfs2/incore.h43
-rw-r--r--fs/gfs2/inode.c406
-rw-r--r--fs/gfs2/inode.h20
-rw-r--r--fs/gfs2/log.c41
-rw-r--r--fs/gfs2/log.h2
-rw-r--r--fs/gfs2/lops.c40
-rw-r--r--fs/gfs2/lops.h2
-rw-r--r--fs/gfs2/main.c4
-rw-r--r--fs/gfs2/meta_io.c46
-rw-r--r--fs/gfs2/meta_io.h1
-rw-r--r--fs/gfs2/ondisk.c138
-rw-r--r--fs/gfs2/ops_address.c52
-rw-r--r--fs/gfs2/ops_dentry.c4
-rw-r--r--fs/gfs2/ops_export.c38
-rw-r--r--fs/gfs2/ops_export.h2
-rw-r--r--fs/gfs2/ops_file.c66
-rw-r--r--fs/gfs2/ops_file.h2
-rw-r--r--fs/gfs2/ops_fstype.c4
-rw-r--r--fs/gfs2/ops_inode.c134
-rw-r--r--fs/gfs2/ops_super.c11
-rw-r--r--fs/gfs2/ops_vm.c2
-rw-r--r--fs/gfs2/quota.c15
-rw-r--r--fs/gfs2/recovery.c29
-rw-r--r--fs/gfs2/recovery.h2
-rw-r--r--fs/gfs2/rgrp.c13
-rw-r--r--fs/gfs2/super.c50
-rw-r--r--fs/gfs2/super.h6
-rw-r--r--fs/gfs2/sys.c8
-rw-r--r--fs/gfs2/util.c6
-rw-r--r--fs/gfs2/util.h12
-rw-r--r--fs/hfs/super.c6
-rw-r--r--fs/hfsplus/super.c6
-rw-r--r--fs/hpfs/dir.c10
-rw-r--r--fs/hpfs/dnode.c13
-rw-r--r--fs/hpfs/ea.c5
-rw-r--r--fs/hpfs/hpfs_fn.h3
-rw-r--r--fs/hpfs/inode.c5
-rw-r--r--fs/hpfs/map.c20
-rw-r--r--fs/hpfs/super.c29
-rw-r--r--fs/hugetlbfs/inode.c6
-rw-r--r--fs/inode.c9
-rw-r--r--fs/inotify_user.c4
-rw-r--r--fs/isofs/inode.c6
-rw-r--r--fs/jbd/journal.c8
-rw-r--r--fs/jbd/revoke.c4
-rw-r--r--fs/jbd/transaction.c4
-rw-r--r--fs/jbd2/commit.c8
-rw-r--r--fs/jbd2/journal.c8
-rw-r--r--fs/jbd2/revoke.c4
-rw-r--r--fs/jbd2/transaction.c2
-rw-r--r--fs/jffs/inode-v23.c4
-rw-r--r--fs/jffs/intrep.c4
-rw-r--r--fs/jffs/jffs_fm.c4
-rw-r--r--fs/jffs2/background.c1
-rw-r--r--fs/jffs2/malloc.c18
-rw-r--r--fs/jffs2/super.c6
-rw-r--r--fs/jfs/jfs_logmgr.c2
-rw-r--r--fs/jfs/jfs_metapage.c4
-rw-r--r--fs/jfs/jfs_txnmgr.c2
-rw-r--r--fs/jfs/super.c6
-rw-r--r--fs/lockd/clntproc.c1
-rw-r--r--fs/lockd/host.c53
-rw-r--r--fs/locks.c6
-rw-r--r--fs/mbcache.c2
-rw-r--r--fs/minix/inode.c6
-rw-r--r--fs/namei.c9
-rw-r--r--fs/namespace.c2
-rw-r--r--fs/ncpfs/inode.c6
-rw-r--r--fs/nfs/direct.c4
-rw-r--r--fs/nfs/inode.c6
-rw-r--r--fs/nfs/pagelist.c4
-rw-r--r--fs/nfs/read.c4
-rw-r--r--fs/nfs/write.c6
-rw-r--r--fs/nfsd/nfs3xdr.c24
-rw-r--r--fs/nfsd/nfs4state.c10
-rw-r--r--fs/nfsd/nfsxdr.c13
-rw-r--r--fs/nls/nls_cp936.c113
-rw-r--r--fs/ntfs/attrib.c2
-rw-r--r--fs/ntfs/index.c2
-rw-r--r--fs/ntfs/inode.c4
-rw-r--r--fs/ntfs/unistr.c2
-rw-r--r--fs/ocfs2/dlm/dlmfs.c6
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c2
-rw-r--r--fs/ocfs2/extent_map.c2
-rw-r--r--fs/ocfs2/inode.h2
-rw-r--r--fs/ocfs2/super.c10
-rw-r--r--fs/ocfs2/uptodate.c2
-rw-r--r--fs/openpromfs/inode.c6
-rw-r--r--fs/partitions/amiga.c2
-rw-r--r--fs/partitions/atari.c2
-rw-r--r--fs/partitions/check.c19
-rw-r--r--fs/partitions/ibm.c29
-rw-r--r--fs/pipe.c22
-rw-r--r--fs/proc/Makefile3
-rw-r--r--fs/proc/base.c11
-rw-r--r--fs/proc/inode.c6
-rw-r--r--fs/proc/kcore.c16
-rw-r--r--fs/proc/proc_misc.c2
-rw-r--r--fs/qnx4/inode.c6
-rw-r--r--fs/reiserfs/file.c61
-rw-r--r--fs/reiserfs/inode.c10
-rw-r--r--fs/reiserfs/super.c9
-rw-r--r--fs/romfs/inode.c6
-rw-r--r--fs/seq_file.c4
-rw-r--r--fs/smbfs/inode.c6
-rw-r--r--fs/smbfs/request.c4
-rw-r--r--fs/stat.c7
-rw-r--r--fs/sysfs/mount.c2
-rw-r--r--fs/sysfs/sysfs.h2
-rw-r--r--fs/sysv/CHANGES60
-rw-r--r--fs/sysv/ChangeLog106
-rw-r--r--fs/sysv/INTRO182
-rw-r--r--fs/sysv/inode.c6
-rw-r--r--fs/udf/super.c10
-rw-r--r--fs/ufs/super.c12
-rw-r--r--fs/ufs/util.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c5
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c1
-rw-r--r--include/acpi/platform/aclinux.h2
-rw-r--r--include/asm-alpha/dma-mapping.h4
-rw-r--r--include/asm-alpha/unistd.h182
-rw-r--r--include/asm-arm/dma-mapping.h2
-rw-r--r--include/asm-arm/setup.h104
-rw-r--r--include/asm-arm/unistd.h150
-rw-r--r--include/asm-arm26/pgalloc.h2
-rw-r--r--include/asm-arm26/setup.h4
-rw-r--r--include/asm-arm26/unistd.h133
-rw-r--r--include/asm-avr32/dma-mapping.h5
-rw-r--r--include/asm-avr32/setup.h4
-rw-r--r--include/asm-cris/arch-v10/bitops.h10
-rw-r--r--include/asm-cris/dma-mapping.h4
-rw-r--r--include/asm-cris/semaphore-helper.h8
-rw-r--r--include/asm-frv/dma-mapping.h4
-rw-r--r--include/asm-frv/highmem.h5
-rw-r--r--include/asm-frv/param.h1
-rw-r--r--include/asm-frv/setup.h6
-rw-r--r--include/asm-frv/unistd.h119
-rw-r--r--include/asm-generic/Kbuild1
-rw-r--r--include/asm-generic/Kbuild.asm1
-rw-r--r--include/asm-generic/atomic.h7
-rw-r--r--include/asm-generic/dma-mapping.h4
-rw-r--r--include/asm-generic/futex.h4
-rw-r--r--include/asm-generic/vmlinux.lds.h23
-rw-r--r--include/asm-h8300/delay.h4
-rw-r--r--include/asm-h8300/mmu_context.h4
-rw-r--r--include/asm-h8300/pci.h4
-rw-r--r--include/asm-h8300/tlbflush.h4
-rw-r--r--include/asm-h8300/unistd.h166
-rw-r--r--include/asm-i386/Kbuild1
-rw-r--r--include/asm-i386/alternative.h13
-rw-r--r--include/asm-i386/apic.h15
-rw-r--r--include/asm-i386/atomic.h6
-rw-r--r--include/asm-i386/boot.h6
-rw-r--r--include/asm-i386/bugs.h4
-rw-r--r--include/asm-i386/cpu.h3
-rw-r--r--include/asm-i386/cpufeature.h8
-rw-r--r--include/asm-i386/current.h7
-rw-r--r--include/asm-i386/delay.h13
-rw-r--r--include/asm-i386/desc.h95
-rw-r--r--include/asm-i386/dma-mapping.h4
-rw-r--r--include/asm-i386/e820.h5
-rw-r--r--include/asm-i386/elf.h2
-rw-r--r--include/asm-i386/futex.h4
-rw-r--r--include/asm-i386/genapic.h2
-rw-r--r--include/asm-i386/i387.h5
-rw-r--r--include/asm-i386/io.h8
-rw-r--r--include/asm-i386/irq.h5
-rw-r--r--include/asm-i386/irq_regs.h28
-rw-r--r--include/asm-i386/irqflags.h42
-rw-r--r--include/asm-i386/mach-default/setup_arch.h2
-rw-r--r--include/asm-i386/math_emu.h1
-rw-r--r--include/asm-i386/mmu_context.h8
-rw-r--r--include/asm-i386/mmzone.h27
-rw-r--r--include/asm-i386/module.h10
-rw-r--r--include/asm-i386/mpspec_def.h2
-rw-r--r--include/asm-i386/msr.h18
-rw-r--r--include/asm-i386/nmi.h8
-rw-r--r--include/asm-i386/page.h8
-rw-r--r--include/asm-i386/param.h1
-rw-r--r--include/asm-i386/paravirt.h505
-rw-r--r--include/asm-i386/pda.h100
-rw-r--r--include/asm-i386/percpu.h25
-rw-r--r--include/asm-i386/pgtable-2level.h10
-rw-r--r--include/asm-i386/pgtable-3level.h45
-rw-r--r--include/asm-i386/pgtable.h28
-rw-r--r--include/asm-i386/processor.h204
-rw-r--r--include/asm-i386/ptrace.h2
-rw-r--r--include/asm-i386/rwsem.h4
-rw-r--r--include/asm-i386/segment.h7
-rw-r--r--include/asm-i386/setup.h7
-rw-r--r--include/asm-i386/smp.h3
-rw-r--r--include/asm-i386/spinlock.h19
-rw-r--r--include/asm-i386/suspend.h21
-rw-r--r--include/asm-i386/system.h16
-rw-r--r--include/asm-i386/thread_info.h10
-rw-r--r--include/asm-i386/time.h41
-rw-r--r--include/asm-i386/tlbflush.h18
-rw-r--r--include/asm-i386/unistd.h98
-rw-r--r--include/asm-i386/unwind.h13
-rw-r--r--include/asm-i386/vm86.h17
-rw-r--r--include/asm-ia64/Kbuild1
-rw-r--r--include/asm-ia64/dma-mapping.h5
-rw-r--r--include/asm-ia64/futex.h4
-rw-r--r--include/asm-ia64/pgalloc.h2
-rw-r--r--include/asm-m32r/setup.h9
-rw-r--r--include/asm-m32r/unistd.h111
-rw-r--r--include/asm-m68k/dma-mapping.h4
-rw-r--r--include/asm-m68k/setup.h6
-rw-r--r--include/asm-m68k/unistd.h97
-rw-r--r--include/asm-m68knommu/setup.h5
-rw-r--r--include/asm-m68knommu/unistd.h150
-rw-r--r--include/asm-mips/dma-mapping.h4
-rw-r--r--include/asm-mips/futex.h4
-rw-r--r--include/asm-mips/highmem.h10
-rw-r--r--include/asm-mips/setup.h2
-rw-r--r--include/asm-mips/unistd.h262
-rw-r--r--include/asm-parisc/dma-mapping.h4
-rw-r--r--include/asm-parisc/futex.h4
-rw-r--r--include/asm-powerpc/dma-mapping.h6
-rw-r--r--include/asm-powerpc/elf.h2
-rw-r--r--include/asm-powerpc/futex.h4
-rw-r--r--include/asm-powerpc/pgalloc.h2
-rw-r--r--include/asm-powerpc/setup.h3
-rw-r--r--include/asm-powerpc/unistd.h109
-rw-r--r--include/asm-ppc/highmem.h8
-rw-r--r--include/asm-s390/setup.h3
-rw-r--r--include/asm-s390/unistd.h154
-rw-r--r--include/asm-sh/dma-mapping.h2
-rw-r--r--include/asm-sh/setup.h6
-rw-r--r--include/asm-sh/unistd.h137
-rw-r--r--include/asm-sh64/dma-mapping.h2
-rw-r--r--include/asm-sh64/setup.h6
-rw-r--r--include/asm-sh64/unistd.h142
-rw-r--r--include/asm-sparc/unistd.h130
-rw-r--r--include/asm-sparc64/dma-mapping.h4
-rw-r--r--include/asm-sparc64/futex.h4
-rw-r--r--include/asm-sparc64/pgalloc.h2
-rw-r--r--include/asm-sparc64/unistd.h118
-rw-r--r--include/asm-um/dma-mapping.h4
-rw-r--r--include/asm-v850/irq.h2
-rw-r--r--include/asm-v850/unistd.h160
-rw-r--r--include/asm-x86_64/Kbuild2
-rw-r--r--include/asm-x86_64/alternative.h12
-rw-r--r--include/asm-x86_64/atomic.h6
-rw-r--r--include/asm-x86_64/calgary.h2
-rw-r--r--include/asm-x86_64/cpufeature.h7
-rw-r--r--include/asm-x86_64/delay.h7
-rw-r--r--include/asm-x86_64/desc.h53
-rw-r--r--include/asm-x86_64/desc_defs.h69
-rw-r--r--include/asm-x86_64/dma-mapping.h5
-rw-r--r--include/asm-x86_64/futex.h4
-rw-r--r--include/asm-x86_64/genapic.h2
-rw-r--r--include/asm-x86_64/msr.h17
-rw-r--r--include/asm-x86_64/nmi.h3
-rw-r--r--include/asm-x86_64/pci-direct.h1
-rw-r--r--include/asm-x86_64/pgtable.h22
-rw-r--r--include/asm-x86_64/processor.h8
-rw-r--r--include/asm-x86_64/proto.h2
-rw-r--r--include/asm-x86_64/rio.h74
-rw-r--r--include/asm-x86_64/smp.h12
-rw-r--r--include/asm-x86_64/spinlock.h29
-rw-r--r--include/asm-x86_64/stacktrace.h2
-rw-r--r--include/asm-x86_64/unistd.h99
-rw-r--r--include/asm-x86_64/unwind.h8
-rw-r--r--include/asm-x86_64/vsyscall.h1
-rw-r--r--include/asm-xtensa/dma-mapping.h4
-rw-r--r--include/asm-xtensa/unistd.h184
-rw-r--r--include/crypto/b128ops.h80
-rw-r--r--include/crypto/gf128mul.h198
-rw-r--r--include/linux/Kbuild3
-rw-r--r--include/linux/aio.h2
-rw-r--r--include/linux/audit.h6
-rw-r--r--include/linux/bootmem.h3
-rw-r--r--include/linux/bottom_half.h10
-rw-r--r--include/linux/carta_random32.h29
-rw-r--r--include/linux/cciss_ioctl.h2
-rw-r--r--include/linux/cdev.h4
-rw-r--r--include/linux/cpu.h31
-rw-r--r--include/linux/cpuset.h4
-rw-r--r--include/linux/crypto.h22
-rw-r--r--include/linux/debug_locks.h2
-rw-r--r--include/linux/delayacct.h2
-rw-r--r--include/linux/device.h22
-rw-r--r--include/linux/efi.h3
-rw-r--r--include/linux/elf.h4
-rw-r--r--include/linux/ext3_jbd.h76
-rw-r--r--include/linux/ext4_jbd2.h76
-rw-r--r--include/linux/file.h4
-rw-r--r--include/linux/freezer.h87
-rw-r--r--include/linux/fs.h20
-rw-r--r--include/linux/fs_struct.h2
-rw-r--r--include/linux/fuse.h24
-rw-r--r--include/linux/genetlink.h6
-rw-r--r--include/linux/gfp.h3
-rw-r--r--include/linux/gfs2_ondisk.h138
-rw-r--r--include/linux/highmem.h8
-rw-r--r--include/linux/hugetlb.h1
-rw-r--r--include/linux/i2o.h20
-rw-r--r--include/linux/init_task.h2
-rw-r--r--include/linux/interrupt.h7
-rw-r--r--include/linux/ipmi.h45
-rw-r--r--include/linux/ipmi_msgdefs.h13
-rw-r--r--include/linux/ipmi_smi.h8
-rw-r--r--include/linux/jbd.h3
-rw-r--r--include/linux/jbd2.h3
-rw-r--r--include/linux/kexec.h1
-rw-r--r--include/linux/kprobes.h2
-rw-r--r--include/linux/ktime.h4
-rw-r--r--include/linux/lockd/lockd.h2
-rw-r--r--include/linux/lockdep.h11
-rw-r--r--include/linux/mm.h81
-rw-r--r--include/linux/mmzone.h87
-rw-r--r--include/linux/moduleparam.h3
-rw-r--r--include/linux/msg.h6
-rw-r--r--include/linux/mutex.h2
-rw-r--r--include/linux/nbd.h1
-rw-r--r--include/linux/netfilter/nf_conntrack_pptp.h3
-rw-r--r--include/linux/nmi.h5
-rw-r--r--include/linux/pci_ids.h9
-rw-r--r--include/linux/pfkeyv2.h1
-rw-r--r--include/linux/profile.h24
-rw-r--r--include/linux/quotaops.h3
-rw-r--r--include/linux/radix-tree.h101
-rw-r--r--include/linux/raid/raid5.h2
-rw-r--r--include/linux/reiserfs_fs.h2
-rw-r--r--include/linux/relay.h2
-rw-r--r--include/linux/rmap.h4
-rw-r--r--include/linux/rtmutex.h2
-rw-r--r--include/linux/rwsem-spinlock.h3
-rw-r--r--include/linux/sched.h111
-rw-r--r--include/linux/screen_info.h3
-rw-r--r--include/linux/seq_file.h4
-rw-r--r--include/linux/serial_8250.h1
-rw-r--r--include/linux/serial_core.h2
-rw-r--r--include/linux/signal.h2
-rw-r--r--include/linux/skbuff.h8
-rw-r--r--include/linux/slab.h92
-rw-r--r--include/linux/smp.h7
-rw-r--r--include/linux/spinlock.h1
-rw-r--r--include/linux/start_kernel.h12
-rw-r--r--include/linux/sunrpc/sched.h4
-rw-r--r--include/linux/suspend.h9
-rw-r--r--include/linux/swap.h6
-rw-r--r--include/linux/taskstats_kern.h43
-rw-r--r--include/linux/uaccess.h49
-rw-r--r--include/linux/workqueue.h9
-rw-r--r--include/net/dst.h2
-rw-r--r--include/net/inet_hashtables.h6
-rw-r--r--include/net/irda/irlan_filter.h2
-rw-r--r--include/net/neighbour.h2
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h2
-rw-r--r--include/net/request_sock.h4
-rw-r--r--include/net/sock.h21
-rw-r--r--include/net/timewait_sock.h2
-rw-r--r--include/net/xfrm.h24
-rw-r--r--include/scsi/libsas.h4
-rw-r--r--init/do_mounts_initrd.c1
-rw-r--r--init/initramfs.c4
-rw-r--r--init/main.c5
-rw-r--r--ipc/compat.c23
-rw-r--r--ipc/mqueue.c6
-rw-r--r--ipc/msg.c44
-rw-r--r--ipc/sem.c3
-rw-r--r--kernel/Kconfig.hz20
-rw-r--r--kernel/acct.c3
-rw-r--r--kernel/audit.c1
-rw-r--r--kernel/auditfilter.c3
-rw-r--r--kernel/auditsc.c6
-rw-r--r--kernel/configs.c2
-rw-r--r--kernel/cpu.c6
-rw-r--r--kernel/cpuset.c22
-rw-r--r--kernel/delayacct.c4
-rw-r--r--kernel/dma.c2
-rw-r--r--kernel/exit.c8
-rw-r--r--kernel/fork.c44
-rw-r--r--kernel/futex.c45
-rw-r--r--kernel/irq/handle.c2
-rw-r--r--kernel/kallsyms.c17
-rw-r--r--kernel/kexec.c59
-rw-r--r--kernel/kprobes.c117
-rw-r--r--kernel/lockdep.c52
-rw-r--r--kernel/lockdep_internals.h2
-rw-r--r--kernel/lockdep_proc.c6
-rw-r--r--kernel/module.c2
-rw-r--r--kernel/mutex-debug.c3
-rw-r--r--kernel/pid.c2
-rw-r--r--kernel/posix-timers.c2
-rw-r--r--kernel/power/Kconfig2
-rw-r--r--kernel/power/disk.c66
-rw-r--r--kernel/power/main.c14
-rw-r--r--kernel/power/power.h32
-rw-r--r--kernel/power/process.c130
-rw-r--r--kernel/power/snapshot.c860
-rw-r--r--kernel/power/swap.c347
-rw-r--r--kernel/power/swsusp.c98
-rw-r--r--kernel/power/user.c102
-rw-r--r--kernel/printk.c24
-rw-r--r--kernel/profile.c47
-rw-r--r--kernel/rcupdate.c4
-rw-r--r--kernel/rcutorture.c4
-rw-r--r--kernel/relay.c2
-rw-r--r--kernel/resource.c6
-rw-r--r--kernel/rtmutex-tester.c1
-rw-r--r--kernel/sched.c39
-rw-r--r--kernel/signal.c6
-rw-r--r--kernel/softirq.c2
-rw-r--r--kernel/sys.c4
-rw-r--r--kernel/sysctl.c26
-rw-r--r--kernel/taskstats.c169
-rw-r--r--kernel/unwind.c203
-rw-r--r--kernel/user.c4
-rw-r--r--kernel/workqueue.c108
-rw-r--r--lib/Kconfig.debug1
-rw-r--r--lib/Makefile2
-rw-r--r--lib/cmdline.c35
-rw-r--r--lib/idr.c4
-rw-r--r--lib/kobject.c3
-rw-r--r--lib/list_debug.c10
-rw-r--r--lib/locking-selftest.c2
-rw-r--r--lib/radix-tree.c333
-rw-r--r--lib/spinlock_debug.c4
-rw-r--r--mm/allocpercpu.c9
-rw-r--r--mm/bootmem.c6
-rw-r--r--mm/filemap.c1
-rw-r--r--mm/fremap.c2
-rw-r--r--mm/hugetlb.c22
-rw-r--r--mm/memory.c3
-rw-r--r--mm/memory_hotplug.c1
-rw-r--r--mm/mempolicy.c10
-rw-r--r--mm/migrate.c19
-rw-r--r--mm/mlock.c2
-rw-r--r--mm/mmap.c4
-rw-r--r--mm/mmzone.c5
-rw-r--r--mm/nommu.c6
-rw-r--r--mm/oom_kill.c41
-rw-r--r--mm/page_alloc.c281
-rw-r--r--mm/page_io.c45
-rw-r--r--mm/pdflush.c1
-rw-r--r--mm/readahead.c8
-rw-r--r--mm/shmem.c8
-rw-r--r--mm/slab.c286
-rw-r--r--mm/sparse.c23
-rw-r--r--mm/swap.c6
-rw-r--r--mm/swapfile.c92
-rw-r--r--mm/thrash.c116
-rw-r--r--mm/vmscan.c13
-rw-r--r--mm/vmstat.c22
-rw-r--r--net/bridge/br_fdb.c2
-rw-r--r--net/bridge/br_netfilter.c36
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/dst.c2
-rw-r--r--net/core/flow.c6
-rw-r--r--net/core/neighbour.c2
-rw-r--r--net/core/skbuff.c20
-rw-r--r--net/core/sock.c25
-rw-r--r--net/core/wireless.c4
-rw-r--r--net/dccp/ackvec.c4
-rw-r--r--net/dccp/ccid.c6
-rw-r--r--net/dccp/ccid.h4
-rw-r--r--net/dccp/ccids/ccid3.c6
-rw-r--r--net/dccp/ccids/lib/loss_interval.c2
-rw-r--r--net/dccp/ccids/lib/loss_interval.h2
-rw-r--r--net/dccp/ccids/lib/packet_history.h4
-rw-r--r--net/decnet/dn_table.c4
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_assoc.c14
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_auth.c2
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_priv.h2
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c3
-rw-r--r--net/ipv4/fib_hash.c8
-rw-r--r--net/ipv4/fib_trie.c6
-rw-r--r--net/ipv4/inet_hashtables.c6
-rw-r--r--net/ipv4/inet_timewait_sock.c3
-rw-r--r--net/ipv4/inetpeer.c2
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_conn.c2
-rw-r--r--net/ipv4/netfilter/arp_tables.c48
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c4
-rw-r--r--net/ipv4/netfilter/ip_tables.c144
-rw-r--r--net/ipv4/route.c2
-rw-r--r--net/ipv4/tcp_input.c4
-rw-r--r--net/ipv4/xfrm4_policy.c2
-rw-r--r--net/ipv6/af_inet6.c6
-rw-r--r--net/ipv6/ip6_fib.c4
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/netfilter/ip6_tables.c59
-rw-r--r--net/ipv6/raw.c3
-rw-r--r--net/ipv6/xfrm6_tunnel.c4
-rw-r--r--net/irda/irttp.c4
-rw-r--r--net/key/af_key.c27
-rw-r--r--net/netfilter/nf_conntrack_core.c8
-rw-r--r--net/netfilter/nf_conntrack_expect.c29
-rw-r--r--net/netfilter/xt_hashlimit.c2
-rw-r--r--net/netlink/genetlink.c18
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/rxrpc/krxiod.c1
-rw-r--r--net/rxrpc/krxsecd.c1
-rw-r--r--net/rxrpc/krxtimod.c1
-rw-r--r--net/sched/cls_fw.c3
-rw-r--r--net/sctp/protocol.c4
-rw-r--r--net/sctp/sm_make_chunk.c4
-rw-r--r--net/sctp/socket.c4
-rw-r--r--net/socket.c25
-rw-r--r--net/sunrpc/rpc_pipe.c6
-rw-r--r--net/sunrpc/sched.c4
-rw-r--r--net/sunrpc/svcauth.c3
-rw-r--r--net/sunrpc/svcsock.c32
-rw-r--r--net/sunrpc/xprtsock.c31
-rw-r--r--net/tipc/handler.c2
-rw-r--r--net/wanrouter/wanmain.c57
-rw-r--r--net/xfrm/xfrm_algo.c17
-rw-r--r--net/xfrm/xfrm_input.c4
-rw-r--r--net/xfrm/xfrm_policy.c179
-rw-r--r--net/xfrm/xfrm_state.c42
-rw-r--r--net/xfrm/xfrm_user.c33
-rw-r--r--scripts/kallsyms.c24
-rw-r--r--scripts/kconfig/qconf.cc8
-rwxr-xr-xscripts/kernel-doc2
-rw-r--r--scripts/mod/modpost.c2
-rwxr-xr-xscripts/ver_linux8
-rw-r--r--security/keys/key.c8
-rw-r--r--security/keys/keyring.c4
-rw-r--r--security/keys/process_keys.c2
-rw-r--r--security/selinux/avc.c4
-rw-r--r--security/selinux/hooks.c4
-rw-r--r--security/selinux/ss/avtab.c4
-rw-r--r--sound/arm/sa11xx-uda1341.c2
-rw-r--r--sound/core/pcm_native.c10
-rw-r--r--sound/oss/Kconfig115
-rw-r--r--sound/oss/btaudio.c2
-rw-r--r--sound/oss/emu10k1/audio.c8
-rw-r--r--sound/oss/emu10k1/cardwi.c31
-rw-r--r--sound/oss/emu10k1/cardwi.h2
-rw-r--r--sound/oss/emu10k1/passthrough.c13
-rw-r--r--sound/oss/via82cxxx_audio.c4
-rw-r--r--sound/usb/usx2y/usX2Yhwdep.c2
1227 files changed, 24505 insertions, 14149 deletions
diff --git a/Documentation/DMA-API.txt b/Documentation/DMA-API.txt
index 05431621c861..805db4b2cba6 100644
--- a/Documentation/DMA-API.txt
+++ b/Documentation/DMA-API.txt
@@ -77,7 +77,7 @@ To get this part of the dma_ API, you must #include <linux/dmapool.h>
77Many drivers need lots of small dma-coherent memory regions for DMA 77Many drivers need lots of small dma-coherent memory regions for DMA
78descriptors or I/O buffers. Rather than allocating in units of a page 78descriptors or I/O buffers. Rather than allocating in units of a page
79or more using dma_alloc_coherent(), you can use DMA pools. These work 79or more using dma_alloc_coherent(), you can use DMA pools. These work
80much like a kmem_cache_t, except that they use the dma-coherent allocator 80much like a struct kmem_cache, except that they use the dma-coherent allocator
81not __get_free_pages(). Also, they understand common hardware constraints 81not __get_free_pages(). Also, they understand common hardware constraints
82for alignment, like queue heads needing to be aligned on N byte boundaries. 82for alignment, like queue heads needing to be aligned on N byte boundaries.
83 83
@@ -94,7 +94,7 @@ The pool create() routines initialize a pool of dma-coherent buffers
94for use with a given device. It must be called in a context which 94for use with a given device. It must be called in a context which
95can sleep. 95can sleep.
96 96
97The "name" is for diagnostics (like a kmem_cache_t name); dev and size 97The "name" is for diagnostics (like a struct kmem_cache name); dev and size
98are like what you'd pass to dma_alloc_coherent(). The device's hardware 98are like what you'd pass to dma_alloc_coherent(). The device's hardware
99alignment requirement for this type of data is "align" (which is expressed 99alignment requirement for this type of data is "align" (which is expressed
100in bytes, and must be a power of two). If your device has no boundary 100in bytes, and must be a power of two). If your device has no boundary
@@ -431,10 +431,10 @@ be identical to those passed in (and returned by
431dma_alloc_noncoherent()). 431dma_alloc_noncoherent()).
432 432
433int 433int
434dma_is_consistent(dma_addr_t dma_handle) 434dma_is_consistent(struct device *dev, dma_addr_t dma_handle)
435 435
436returns true if the memory pointed to by the dma_handle is actually 436returns true if the device dev is performing consistent DMA on the memory
437consistent. 437area pointed to by the dma_handle.
438 438
439int 439int
440dma_get_cache_alignment(void) 440dma_get_cache_alignment(void)
@@ -459,7 +459,7 @@ anything like this. You must also be extra careful about accessing
459memory you intend to sync partially. 459memory you intend to sync partially.
460 460
461void 461void
462dma_cache_sync(void *vaddr, size_t size, 462dma_cache_sync(struct device *dev, void *vaddr, size_t size,
463 enum dma_data_direction direction) 463 enum dma_data_direction direction)
464 464
465Do a partial sync of memory that was allocated by 465Do a partial sync of memory that was allocated by
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index a166675c4303..ca094913c555 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -418,9 +418,35 @@ X!Edrivers/pnp/system.c
418!Idrivers/parport/daisy.c 418!Idrivers/parport/daisy.c
419 </chapter> 419 </chapter>
420 420
421 <chapter id="viddev"> 421 <chapter id="message_devices">
422 <title>Video4Linux</title> 422 <title>Message-based devices</title>
423!Edrivers/media/video/videodev.c 423 <sect1><title>Fusion message devices</title>
424!Edrivers/message/fusion/mptbase.c
425!Idrivers/message/fusion/mptbase.c
426!Edrivers/message/fusion/mptscsih.c
427!Idrivers/message/fusion/mptscsih.c
428!Idrivers/message/fusion/mptctl.c
429!Idrivers/message/fusion/mptspi.c
430!Idrivers/message/fusion/mptfc.c
431!Idrivers/message/fusion/mptlan.c
432 </sect1>
433 <sect1><title>I2O message devices</title>
434!Iinclude/linux/i2o.h
435!Idrivers/message/i2o/core.h
436!Edrivers/message/i2o/iop.c
437!Idrivers/message/i2o/iop.c
438!Idrivers/message/i2o/config-osm.c
439!Edrivers/message/i2o/exec-osm.c
440!Idrivers/message/i2o/exec-osm.c
441!Idrivers/message/i2o/bus-osm.c
442!Edrivers/message/i2o/device.c
443!Idrivers/message/i2o/device.c
444!Idrivers/message/i2o/driver.c
445!Idrivers/message/i2o/pci.c
446!Idrivers/message/i2o/i2o_block.c
447!Idrivers/message/i2o/i2o_scsi.c
448!Idrivers/message/i2o/i2o_proc.c
449 </sect1>
424 </chapter> 450 </chapter>
425 451
426 <chapter id="snddev"> 452 <chapter id="snddev">
diff --git a/Documentation/IPMI.txt b/Documentation/IPMI.txt
index 0e3924ecd76b..24dc3fcf1594 100644
--- a/Documentation/IPMI.txt
+++ b/Documentation/IPMI.txt
@@ -365,6 +365,7 @@ You can change this at module load time (for a module) with:
365 regshifts=<shift1>,<shift2>,... 365 regshifts=<shift1>,<shift2>,...
366 slave_addrs=<addr1>,<addr2>,... 366 slave_addrs=<addr1>,<addr2>,...
367 force_kipmid=<enable1>,<enable2>,... 367 force_kipmid=<enable1>,<enable2>,...
368 unload_when_empty=[0|1]
368 369
369Each of these except si_trydefaults is a list, the first item for the 370Each of these except si_trydefaults is a list, the first item for the
370first interface, second item for the second interface, etc. 371first interface, second item for the second interface, etc.
@@ -416,6 +417,11 @@ by the driver, but systems with broken interrupts might need an enable,
416or users that don't want the daemon (don't need the performance, don't 417or users that don't want the daemon (don't need the performance, don't
417want the CPU hit) can disable it. 418want the CPU hit) can disable it.
418 419
420If unload_when_empty is set to 1, the driver will be unloaded if it
421doesn't find any interfaces or all the interfaces fail to work. The
422default is one. Setting to 0 is useful with the hotmod, but is
423obviously only useful for modules.
424
419When compiled into the kernel, the parameters can be specified on the 425When compiled into the kernel, the parameters can be specified on the
420kernel command line as: 426kernel command line as:
421 427
@@ -441,6 +447,25 @@ have high-res timers enabled in the kernel and you don't have
441interrupts enabled, the driver will run VERY slowly. Don't blame me, 447interrupts enabled, the driver will run VERY slowly. Don't blame me,
442these interfaces suck. 448these interfaces suck.
443 449
450The driver supports a hot add and remove of interfaces. This way,
451interfaces can be added or removed after the kernel is up and running.
452This is done using /sys/modules/ipmi_si/hotmod, which is a write-only
453parameter. You write a string to this interface. The string has the
454format:
455 <op1>[:op2[:op3...]]
456The "op"s are:
457 add|remove,kcs|bt|smic,mem|i/o,<address>[,<opt1>[,<opt2>[,...]]]
458You can specify more than one interface on the line. The "opt"s are:
459 rsp=<regspacing>
460 rsi=<regsize>
461 rsh=<regshift>
462 irq=<irq>
463 ipmb=<ipmb slave addr>
464and these have the same meanings as discussed above. Note that you
465can also use this on the kernel command line for a more compact format
466for specifying an interface. Note that when removing an interface,
467only the first three parameters (si type, address type, and address)
468are used for the comparison. Any options are ignored for removing.
444 469
445The SMBus Driver 470The SMBus Driver
446---------------- 471----------------
@@ -502,7 +527,10 @@ used to control it:
502 527
503 modprobe ipmi_watchdog timeout=<t> pretimeout=<t> action=<action type> 528 modprobe ipmi_watchdog timeout=<t> pretimeout=<t> action=<action type>
504 preaction=<preaction type> preop=<preop type> start_now=x 529 preaction=<preaction type> preop=<preop type> start_now=x
505 nowayout=x 530 nowayout=x ifnum_to_use=n
531
532ifnum_to_use specifies which interface the watchdog timer should use.
533The default is -1, which means to pick the first one registered.
506 534
507The timeout is the number of seconds to the action, and the pretimeout 535The timeout is the number of seconds to the action, and the pretimeout
508is the amount of seconds before the reset that the pre-timeout panic will 536is the amount of seconds before the reset that the pre-timeout panic will
@@ -624,5 +652,9 @@ command line. The parameter is also available via the proc filesystem
624in /proc/sys/dev/ipmi/poweroff_powercycle. Note that if the system 652in /proc/sys/dev/ipmi/poweroff_powercycle. Note that if the system
625does not support power cycling, it will always do the power off. 653does not support power cycling, it will always do the power off.
626 654
655The "ifnum_to_use" parameter specifies which interface the poweroff
656code should use. The default is -1, which means to pick the first one
657registered.
658
627Note that if you have ACPI enabled, the system will prefer using ACPI to 659Note that if you have ACPI enabled, the system will prefer using ACPI to
628power off. 660power off.
diff --git a/Documentation/block/as-iosched.txt b/Documentation/block/as-iosched.txt
index e2a66f8143c5..a598fe10a297 100644
--- a/Documentation/block/as-iosched.txt
+++ b/Documentation/block/as-iosched.txt
@@ -24,8 +24,10 @@ very similar behavior to the deadline IO scheduler.
24Selecting IO schedulers 24Selecting IO schedulers
25----------------------- 25-----------------------
26To choose IO schedulers at boot time, use the argument 'elevator=deadline'. 26To choose IO schedulers at boot time, use the argument 'elevator=deadline'.
27'noop' and 'as' (the default) are also available. IO schedulers are assigned 27'noop', 'as' and 'cfq' (the default) are also available. IO schedulers are
28globally at boot time only presently. 28assigned globally at boot time only presently. It's also possible to change
29the IO scheduler for a determined device on the fly, as described in
30Documentation/block/switching-sched.txt.
29 31
30 32
31Anticipatory IO scheduler Policies 33Anticipatory IO scheduler Policies
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index 70690f1a14af..8de132a02ba9 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -3,7 +3,7 @@
3 3
4 Maintained by Torben Mathiasen <device@lanana.org> 4 Maintained by Torben Mathiasen <device@lanana.org>
5 5
6 Last revised: 15 May 2006 6 Last revised: 29 November 2006
7 7
8This list is the Linux Device List, the official registry of allocated 8This list is the Linux Device List, the official registry of allocated
9device numbers and /dev directory nodes for the Linux operating 9device numbers and /dev directory nodes for the Linux operating
@@ -94,6 +94,7 @@ Your cooperation is appreciated.
94 9 = /dev/urandom Faster, less secure random number gen. 94 9 = /dev/urandom Faster, less secure random number gen.
95 10 = /dev/aio Asynchronous I/O notification interface 95 10 = /dev/aio Asynchronous I/O notification interface
96 11 = /dev/kmsg Writes to this come out as printk's 96 11 = /dev/kmsg Writes to this come out as printk's
97
97 1 block RAM disk 98 1 block RAM disk
98 0 = /dev/ram0 First RAM disk 99 0 = /dev/ram0 First RAM disk
99 1 = /dev/ram1 Second RAM disk 100 1 = /dev/ram1 Second RAM disk
@@ -122,7 +123,7 @@ Your cooperation is appreciated.
122 devices are on major 128 and above and use the PTY 123 devices are on major 128 and above and use the PTY
123 master multiplex (/dev/ptmx) to acquire a PTY on 124 master multiplex (/dev/ptmx) to acquire a PTY on
124 demand. 125 demand.
125 126
126 2 block Floppy disks 127 2 block Floppy disks
127 0 = /dev/fd0 Controller 0, drive 0, autodetect 128 0 = /dev/fd0 Controller 0, drive 0, autodetect
128 1 = /dev/fd1 Controller 0, drive 1, autodetect 129 1 = /dev/fd1 Controller 0, drive 1, autodetect
@@ -257,7 +258,7 @@ Your cooperation is appreciated.
257 129 = /dev/vcsa1 tty1 text/attribute contents 258 129 = /dev/vcsa1 tty1 text/attribute contents
258 ... 259 ...
259 191 = /dev/vcsa63 tty63 text/attribute contents 260 191 = /dev/vcsa63 tty63 text/attribute contents
260 261
261 NOTE: These devices permit both read and write access. 262 NOTE: These devices permit both read and write access.
262 263
263 7 block Loopback devices 264 7 block Loopback devices
@@ -411,7 +412,7 @@ Your cooperation is appreciated.
411 207 = /dev/video/em8300_sp EM8300 DVD decoder subpicture 412 207 = /dev/video/em8300_sp EM8300 DVD decoder subpicture
412 208 = /dev/compaq/cpqphpc Compaq PCI Hot Plug Controller 413 208 = /dev/compaq/cpqphpc Compaq PCI Hot Plug Controller
413 209 = /dev/compaq/cpqrid Compaq Remote Insight Driver 414 209 = /dev/compaq/cpqrid Compaq Remote Insight Driver
414 210 = /dev/impi/bt IMPI coprocessor block transfer 415 210 = /dev/impi/bt IMPI coprocessor block transfer
415 211 = /dev/impi/smic IMPI coprocessor stream interface 416 211 = /dev/impi/smic IMPI coprocessor stream interface
416 212 = /dev/watchdogs/0 First watchdog device 417 212 = /dev/watchdogs/0 First watchdog device
417 213 = /dev/watchdogs/1 Second watchdog device 418 213 = /dev/watchdogs/1 Second watchdog device
@@ -506,6 +507,7 @@ Your cooperation is appreciated.
506 33 = /dev/patmgr1 Sequencer patch manager 507 33 = /dev/patmgr1 Sequencer patch manager
507 34 = /dev/midi02 Third MIDI port 508 34 = /dev/midi02 Third MIDI port
508 50 = /dev/midi03 Fourth MIDI port 509 50 = /dev/midi03 Fourth MIDI port
510
509 14 block BIOS harddrive callback support {2.6} 511 14 block BIOS harddrive callback support {2.6}
510 0 = /dev/dos_hda First BIOS harddrive whole disk 512 0 = /dev/dos_hda First BIOS harddrive whole disk
511 64 = /dev/dos_hdb Second BIOS harddrive whole disk 513 64 = /dev/dos_hdb Second BIOS harddrive whole disk
@@ -527,6 +529,7 @@ Your cooperation is appreciated.
527 529
528 16 char Non-SCSI scanners 530 16 char Non-SCSI scanners
529 0 = /dev/gs4500 Genius 4500 handheld scanner 531 0 = /dev/gs4500 Genius 4500 handheld scanner
532
530 16 block GoldStar CD-ROM 533 16 block GoldStar CD-ROM
531 0 = /dev/gscd GoldStar CD-ROM 534 0 = /dev/gscd GoldStar CD-ROM
532 535
@@ -548,6 +551,7 @@ Your cooperation is appreciated.
548 0 = /dev/ttyC0 First Cyclades port 551 0 = /dev/ttyC0 First Cyclades port
549 ... 552 ...
550 31 = /dev/ttyC31 32nd Cyclades port 553 31 = /dev/ttyC31 32nd Cyclades port
554
551 19 block "Double" compressed disk 555 19 block "Double" compressed disk
552 0 = /dev/double0 First compressed disk 556 0 = /dev/double0 First compressed disk
553 ... 557 ...
@@ -563,6 +567,7 @@ Your cooperation is appreciated.
563 0 = /dev/cub0 Callout device for ttyC0 567 0 = /dev/cub0 Callout device for ttyC0
564 ... 568 ...
565 31 = /dev/cub31 Callout device for ttyC31 569 31 = /dev/cub31 Callout device for ttyC31
570
566 20 block Hitachi CD-ROM (under development) 571 20 block Hitachi CD-ROM (under development)
567 0 = /dev/hitcd Hitachi CD-ROM 572 0 = /dev/hitcd Hitachi CD-ROM
568 573
@@ -582,7 +587,7 @@ Your cooperation is appreciated.
582 587
583 This device is used on the ARM-based Acorn RiscPC. 588 This device is used on the ARM-based Acorn RiscPC.
584 Partitions are handled the same way as for IDE disks 589 Partitions are handled the same way as for IDE disks
585 (see major number 3). 590 (see major number 3).
586 591
587 22 char Digiboard serial card 592 22 char Digiboard serial card
588 0 = /dev/ttyD0 First Digiboard port 593 0 = /dev/ttyD0 First Digiboard port
@@ -591,7 +596,7 @@ Your cooperation is appreciated.
591 22 block Second IDE hard disk/CD-ROM interface 596 22 block Second IDE hard disk/CD-ROM interface
592 0 = /dev/hdc Master: whole disk (or CD-ROM) 597 0 = /dev/hdc Master: whole disk (or CD-ROM)
593 64 = /dev/hdd Slave: whole disk (or CD-ROM) 598 64 = /dev/hdd Slave: whole disk (or CD-ROM)
594 599
595 Partitions are handled the same way as for the first 600 Partitions are handled the same way as for the first
596 interface (see major number 3). 601 interface (see major number 3).
597 602
@@ -639,6 +644,7 @@ Your cooperation is appreciated.
639 644
640 26 char Quanta WinVision frame grabber {2.6} 645 26 char Quanta WinVision frame grabber {2.6}
641 0 = /dev/wvisfgrab Quanta WinVision frame grabber 646 0 = /dev/wvisfgrab Quanta WinVision frame grabber
647
642 26 block Second Matsushita (Panasonic/SoundBlaster) CD-ROM 648 26 block Second Matsushita (Panasonic/SoundBlaster) CD-ROM
643 0 = /dev/sbpcd4 Panasonic CD-ROM controller 1 unit 0 649 0 = /dev/sbpcd4 Panasonic CD-ROM controller 1 unit 0
644 1 = /dev/sbpcd5 Panasonic CD-ROM controller 1 unit 1 650 1 = /dev/sbpcd5 Panasonic CD-ROM controller 1 unit 1
@@ -670,6 +676,7 @@ Your cooperation is appreciated.
670 37 = /dev/nrawqft1 Unit 1, no rewind-on-close, no file marks 676 37 = /dev/nrawqft1 Unit 1, no rewind-on-close, no file marks
671 38 = /dev/nrawqft2 Unit 2, no rewind-on-close, no file marks 677 38 = /dev/nrawqft2 Unit 2, no rewind-on-close, no file marks
672 39 = /dev/nrawqft3 Unit 3, no rewind-on-close, no file marks 678 39 = /dev/nrawqft3 Unit 3, no rewind-on-close, no file marks
679
673 27 block Third Matsushita (Panasonic/SoundBlaster) CD-ROM 680 27 block Third Matsushita (Panasonic/SoundBlaster) CD-ROM
674 0 = /dev/sbpcd8 Panasonic CD-ROM controller 2 unit 0 681 0 = /dev/sbpcd8 Panasonic CD-ROM controller 2 unit 0
675 1 = /dev/sbpcd9 Panasonic CD-ROM controller 2 unit 1 682 1 = /dev/sbpcd9 Panasonic CD-ROM controller 2 unit 1
@@ -681,6 +688,7 @@ Your cooperation is appreciated.
681 1 = /dev/staliomem1 Second Stallion card I/O memory 688 1 = /dev/staliomem1 Second Stallion card I/O memory
682 2 = /dev/staliomem2 Third Stallion card I/O memory 689 2 = /dev/staliomem2 Third Stallion card I/O memory
683 3 = /dev/staliomem3 Fourth Stallion card I/O memory 690 3 = /dev/staliomem3 Fourth Stallion card I/O memory
691
684 28 char Atari SLM ACSI laser printer (68k/Atari) 692 28 char Atari SLM ACSI laser printer (68k/Atari)
685 0 = /dev/slm0 First SLM laser printer 693 0 = /dev/slm0 First SLM laser printer
686 1 = /dev/slm1 Second SLM laser printer 694 1 = /dev/slm1 Second SLM laser printer
@@ -690,6 +698,7 @@ Your cooperation is appreciated.
690 1 = /dev/sbpcd13 Panasonic CD-ROM controller 3 unit 1 698 1 = /dev/sbpcd13 Panasonic CD-ROM controller 3 unit 1
691 2 = /dev/sbpcd14 Panasonic CD-ROM controller 3 unit 2 699 2 = /dev/sbpcd14 Panasonic CD-ROM controller 3 unit 2
692 3 = /dev/sbpcd15 Panasonic CD-ROM controller 3 unit 3 700 3 = /dev/sbpcd15 Panasonic CD-ROM controller 3 unit 3
701
693 28 block ACSI disk (68k/Atari) 702 28 block ACSI disk (68k/Atari)
694 0 = /dev/ada First ACSI disk whole disk 703 0 = /dev/ada First ACSI disk whole disk
695 16 = /dev/adb Second ACSI disk whole disk 704 16 = /dev/adb Second ACSI disk whole disk
@@ -750,6 +759,7 @@ Your cooperation is appreciated.
750 31 char MPU-401 MIDI 759 31 char MPU-401 MIDI
751 0 = /dev/mpu401data MPU-401 data port 760 0 = /dev/mpu401data MPU-401 data port
752 1 = /dev/mpu401stat MPU-401 status port 761 1 = /dev/mpu401stat MPU-401 status port
762
753 31 block ROM/flash memory card 763 31 block ROM/flash memory card
754 0 = /dev/rom0 First ROM card (rw) 764 0 = /dev/rom0 First ROM card (rw)
755 ... 765 ...
@@ -801,7 +811,7 @@ Your cooperation is appreciated.
801 34 block Fourth IDE hard disk/CD-ROM interface 811 34 block Fourth IDE hard disk/CD-ROM interface
802 0 = /dev/hdg Master: whole disk (or CD-ROM) 812 0 = /dev/hdg Master: whole disk (or CD-ROM)
803 64 = /dev/hdh Slave: whole disk (or CD-ROM) 813 64 = /dev/hdh Slave: whole disk (or CD-ROM)
804 814
805 Partitions are handled the same way as for the first 815 Partitions are handled the same way as for the first
806 interface (see major number 3). 816 interface (see major number 3).
807 817
@@ -818,6 +828,7 @@ Your cooperation is appreciated.
818 129 = /dev/smpte1 Second MIDI port, SMPTE timed 828 129 = /dev/smpte1 Second MIDI port, SMPTE timed
819 130 = /dev/smpte2 Third MIDI port, SMPTE timed 829 130 = /dev/smpte2 Third MIDI port, SMPTE timed
820 131 = /dev/smpte3 Fourth MIDI port, SMPTE timed 830 131 = /dev/smpte3 Fourth MIDI port, SMPTE timed
831
821 35 block Slow memory ramdisk 832 35 block Slow memory ramdisk
822 0 = /dev/slram Slow memory ramdisk 833 0 = /dev/slram Slow memory ramdisk
823 834
@@ -828,6 +839,7 @@ Your cooperation is appreciated.
828 16 = /dev/tap0 First Ethertap device 839 16 = /dev/tap0 First Ethertap device
829 ... 840 ...
830 31 = /dev/tap15 16th Ethertap device 841 31 = /dev/tap15 16th Ethertap device
842
831 36 block MCA ESDI hard disk 843 36 block MCA ESDI hard disk
832 0 = /dev/eda First ESDI disk whole disk 844 0 = /dev/eda First ESDI disk whole disk
833 64 = /dev/edb Second ESDI disk whole disk 845 64 = /dev/edb Second ESDI disk whole disk
@@ -882,6 +894,7 @@ Your cooperation is appreciated.
882 894
883 40 char Matrox Meteor frame grabber {2.6} 895 40 char Matrox Meteor frame grabber {2.6}
884 0 = /dev/mmetfgrab Matrox Meteor frame grabber 896 0 = /dev/mmetfgrab Matrox Meteor frame grabber
897
885 40 block Syquest EZ135 parallel port removable drive 898 40 block Syquest EZ135 parallel port removable drive
886 0 = /dev/eza Parallel EZ135 drive, whole disk 899 0 = /dev/eza Parallel EZ135 drive, whole disk
887 900
@@ -893,6 +906,7 @@ Your cooperation is appreciated.
893 906
894 41 char Yet Another Micro Monitor 907 41 char Yet Another Micro Monitor
895 0 = /dev/yamm Yet Another Micro Monitor 908 0 = /dev/yamm Yet Another Micro Monitor
909
896 41 block MicroSolutions BackPack parallel port CD-ROM 910 41 block MicroSolutions BackPack parallel port CD-ROM
897 0 = /dev/bpcd BackPack CD-ROM 911 0 = /dev/bpcd BackPack CD-ROM
898 912
@@ -901,6 +915,7 @@ Your cooperation is appreciated.
901 the parallel port ATAPI CD-ROM driver at major number 46. 915 the parallel port ATAPI CD-ROM driver at major number 46.
902 916
903 42 char Demo/sample use 917 42 char Demo/sample use
918
904 42 block Demo/sample use 919 42 block Demo/sample use
905 920
906 This number is intended for use in sample code, as 921 This number is intended for use in sample code, as
@@ -918,6 +933,7 @@ Your cooperation is appreciated.
918 0 = /dev/ttyI0 First virtual modem 933 0 = /dev/ttyI0 First virtual modem
919 ... 934 ...
920 63 = /dev/ttyI63 64th virtual modem 935 63 = /dev/ttyI63 64th virtual modem
936
921 43 block Network block devices 937 43 block Network block devices
922 0 = /dev/nb0 First network block device 938 0 = /dev/nb0 First network block device
923 1 = /dev/nb1 Second network block device 939 1 = /dev/nb1 Second network block device
@@ -934,12 +950,13 @@ Your cooperation is appreciated.
934 0 = /dev/cui0 Callout device for ttyI0 950 0 = /dev/cui0 Callout device for ttyI0
935 ... 951 ...
936 63 = /dev/cui63 Callout device for ttyI63 952 63 = /dev/cui63 Callout device for ttyI63
953
937 44 block Flash Translation Layer (FTL) filesystems 954 44 block Flash Translation Layer (FTL) filesystems
938 0 = /dev/ftla FTL on first Memory Technology Device 955 0 = /dev/ftla FTL on first Memory Technology Device
939 16 = /dev/ftlb FTL on second Memory Technology Device 956 16 = /dev/ftlb FTL on second Memory Technology Device
940 32 = /dev/ftlc FTL on third Memory Technology Device 957 32 = /dev/ftlc FTL on third Memory Technology Device
941 ... 958 ...
942 240 = /dev/ftlp FTL on 16th Memory Technology Device 959 240 = /dev/ftlp FTL on 16th Memory Technology Device
943 960
944 Partitions are handled in the same way as for IDE 961 Partitions are handled in the same way as for IDE
945 disks (see major number 3) except that the partition 962 disks (see major number 3) except that the partition
@@ -958,6 +975,7 @@ Your cooperation is appreciated.
958 191 = /dev/ippp63 64th SyncPPP device 975 191 = /dev/ippp63 64th SyncPPP device
959 976
960 255 = /dev/isdninfo ISDN monitor interface 977 255 = /dev/isdninfo ISDN monitor interface
978
961 45 block Parallel port IDE disk devices 979 45 block Parallel port IDE disk devices
962 0 = /dev/pda First parallel port IDE disk 980 0 = /dev/pda First parallel port IDE disk
963 16 = /dev/pdb Second parallel port IDE disk 981 16 = /dev/pdb Second parallel port IDE disk
@@ -1044,6 +1062,7 @@ Your cooperation is appreciated.
1044 1 = /dev/dcbri1 Second DataComm card 1062 1 = /dev/dcbri1 Second DataComm card
1045 2 = /dev/dcbri2 Third DataComm card 1063 2 = /dev/dcbri2 Third DataComm card
1046 3 = /dev/dcbri3 Fourth DataComm card 1064 3 = /dev/dcbri3 Fourth DataComm card
1065
1047 52 block Mylex DAC960 PCI RAID controller; fifth controller 1066 52 block Mylex DAC960 PCI RAID controller; fifth controller
1048 0 = /dev/rd/c4d0 First disk, whole disk 1067 0 = /dev/rd/c4d0 First disk, whole disk
1049 8 = /dev/rd/c4d1 Second disk, whole disk 1068 8 = /dev/rd/c4d1 Second disk, whole disk
@@ -1093,6 +1112,7 @@ Your cooperation is appreciated.
1093 1112
1094 55 char DSP56001 digital signal processor 1113 55 char DSP56001 digital signal processor
1095 0 = /dev/dsp56k First DSP56001 1114 0 = /dev/dsp56k First DSP56001
1115
1096 55 block Mylex DAC960 PCI RAID controller; eighth controller 1116 55 block Mylex DAC960 PCI RAID controller; eighth controller
1097 0 = /dev/rd/c7d0 First disk, whole disk 1117 0 = /dev/rd/c7d0 First disk, whole disk
1098 8 = /dev/rd/c7d1 Second disk, whole disk 1118 8 = /dev/rd/c7d1 Second disk, whole disk
@@ -1130,6 +1150,7 @@ Your cooperation is appreciated.
1130 0 = /dev/cup0 Callout device for ttyP0 1150 0 = /dev/cup0 Callout device for ttyP0
1131 1 = /dev/cup1 Callout device for ttyP1 1151 1 = /dev/cup1 Callout device for ttyP1
1132 ... 1152 ...
1153
1133 58 block Reserved for logical volume manager 1154 58 block Reserved for logical volume manager
1134 1155
1135 59 char sf firewall package 1156 59 char sf firewall package
@@ -1149,6 +1170,7 @@ Your cooperation is appreciated.
1149 NAMING CONFLICT -- PROPOSED REVISED NAME /dev/rpda0 etc 1170 NAMING CONFLICT -- PROPOSED REVISED NAME /dev/rpda0 etc
1150 1171
1151 60-63 char LOCAL/EXPERIMENTAL USE 1172 60-63 char LOCAL/EXPERIMENTAL USE
1173
1152 60-63 block LOCAL/EXPERIMENTAL USE 1174 60-63 block LOCAL/EXPERIMENTAL USE
1153 Allocated for local/experimental use. For devices not 1175 Allocated for local/experimental use. For devices not
1154 assigned official numbers, these ranges should be 1176 assigned official numbers, these ranges should be
@@ -1434,7 +1456,6 @@ Your cooperation is appreciated.
1434 DAC960 (see major number 48) except that the limit on 1456 DAC960 (see major number 48) except that the limit on
1435 partitions is 15. 1457 partitions is 15.
1436 1458
1437
1438 78 char PAM Software's multimodem boards 1459 78 char PAM Software's multimodem boards
1439 0 = /dev/ttyM0 First PAM modem 1460 0 = /dev/ttyM0 First PAM modem
1440 1 = /dev/ttyM1 Second PAM modem 1461 1 = /dev/ttyM1 Second PAM modem
@@ -1450,7 +1471,6 @@ Your cooperation is appreciated.
1450 DAC960 (see major number 48) except that the limit on 1471 DAC960 (see major number 48) except that the limit on
1451 partitions is 15. 1472 partitions is 15.
1452 1473
1453
1454 79 char PAM Software's multimodem boards - alternate devices 1474 79 char PAM Software's multimodem boards - alternate devices
1455 0 = /dev/cum0 Callout device for ttyM0 1475 0 = /dev/cum0 Callout device for ttyM0
1456 1 = /dev/cum1 Callout device for ttyM1 1476 1 = /dev/cum1 Callout device for ttyM1
@@ -1466,7 +1486,6 @@ Your cooperation is appreciated.
1466 DAC960 (see major number 48) except that the limit on 1486 DAC960 (see major number 48) except that the limit on
1467 partitions is 15. 1487 partitions is 15.
1468 1488
1469
1470 80 char Photometrics AT200 CCD camera 1489 80 char Photometrics AT200 CCD camera
1471 0 = /dev/at200 Photometrics AT200 CCD camera 1490 0 = /dev/at200 Photometrics AT200 CCD camera
1472 1491
@@ -1679,7 +1698,7 @@ Your cooperation is appreciated.
1679 1 = /dev/dcxx1 Second capture card 1698 1 = /dev/dcxx1 Second capture card
1680 ... 1699 ...
1681 1700
1682 94 block IBM S/390 DASD block storage 1701 94 block IBM S/390 DASD block storage
1683 0 = /dev/dasda First DASD device, major 1702 0 = /dev/dasda First DASD device, major
1684 1 = /dev/dasda1 First DASD device, block 1 1703 1 = /dev/dasda1 First DASD device, block 1
1685 2 = /dev/dasda2 First DASD device, block 2 1704 2 = /dev/dasda2 First DASD device, block 2
@@ -1695,7 +1714,7 @@ Your cooperation is appreciated.
1695 1 = /dev/ipnat NAT control device/log file 1714 1 = /dev/ipnat NAT control device/log file
1696 2 = /dev/ipstate State information log file 1715 2 = /dev/ipstate State information log file
1697 3 = /dev/ipauth Authentication control device/log file 1716 3 = /dev/ipauth Authentication control device/log file
1698 ... 1717 ...
1699 1718
1700 96 char Parallel port ATAPI tape devices 1719 96 char Parallel port ATAPI tape devices
1701 0 = /dev/pt0 First parallel port ATAPI tape 1720 0 = /dev/pt0 First parallel port ATAPI tape
@@ -1705,7 +1724,7 @@ Your cooperation is appreciated.
1705 129 = /dev/npt1 Second p.p. ATAPI tape, no rewind 1724 129 = /dev/npt1 Second p.p. ATAPI tape, no rewind
1706 ... 1725 ...
1707 1726
1708 96 block Inverse NAND Flash Translation Layer 1727 96 block Inverse NAND Flash Translation Layer
1709 0 = /dev/inftla First INFTL layer 1728 0 = /dev/inftla First INFTL layer
1710 16 = /dev/inftlb Second INFTL layer 1729 16 = /dev/inftlb Second INFTL layer
1711 ... 1730 ...
@@ -1937,7 +1956,6 @@ Your cooperation is appreciated.
1937 ... 1956 ...
1938 1957
1939113 block IBM iSeries virtual CD-ROM 1958113 block IBM iSeries virtual CD-ROM
1940
1941 0 = /dev/iseries/vcda First virtual CD-ROM 1959 0 = /dev/iseries/vcda First virtual CD-ROM
1942 1 = /dev/iseries/vcdb Second virtual CD-ROM 1960 1 = /dev/iseries/vcdb Second virtual CD-ROM
1943 ... 1961 ...
@@ -2059,11 +2077,12 @@ Your cooperation is appreciated.
2059 ... 2077 ...
2060 2078
2061119 char VMware virtual network control 2079119 char VMware virtual network control
2062 0 = /dev/vnet0 1st virtual network 2080 0 = /dev/vmnet0 1st virtual network
2063 1 = /dev/vnet1 2nd virtual network 2081 1 = /dev/vmnet1 2nd virtual network
2064 ... 2082 ...
2065 2083
2066120-127 char LOCAL/EXPERIMENTAL USE 2084120-127 char LOCAL/EXPERIMENTAL USE
2085
2067120-127 block LOCAL/EXPERIMENTAL USE 2086120-127 block LOCAL/EXPERIMENTAL USE
2068 Allocated for local/experimental use. For devices not 2087 Allocated for local/experimental use. For devices not
2069 assigned official numbers, these ranges should be 2088 assigned official numbers, these ranges should be
@@ -2075,7 +2094,6 @@ Your cooperation is appreciated.
2075 nodes; instead they should be accessed through the 2094 nodes; instead they should be accessed through the
2076 /dev/ptmx cloning interface. 2095 /dev/ptmx cloning interface.
2077 2096
2078
2079128 block SCSI disk devices (128-143) 2097128 block SCSI disk devices (128-143)
2080 0 = /dev/sddy 129th SCSI disk whole disk 2098 0 = /dev/sddy 129th SCSI disk whole disk
2081 16 = /dev/sddz 130th SCSI disk whole disk 2099 16 = /dev/sddz 130th SCSI disk whole disk
@@ -2087,7 +2105,6 @@ Your cooperation is appreciated.
2087 disks (see major number 3) except that the limit on 2105 disks (see major number 3) except that the limit on
2088 partitions is 15. 2106 partitions is 15.
2089 2107
2090
2091129 block SCSI disk devices (144-159) 2108129 block SCSI disk devices (144-159)
2092 0 = /dev/sdeo 145th SCSI disk whole disk 2109 0 = /dev/sdeo 145th SCSI disk whole disk
2093 16 = /dev/sdep 146th SCSI disk whole disk 2110 16 = /dev/sdep 146th SCSI disk whole disk
@@ -2123,7 +2140,6 @@ Your cooperation is appreciated.
2123 disks (see major number 3) except that the limit on 2140 disks (see major number 3) except that the limit on
2124 partitions is 15. 2141 partitions is 15.
2125 2142
2126
2127132 block SCSI disk devices (192-207) 2143132 block SCSI disk devices (192-207)
2128 0 = /dev/sdgk 193rd SCSI disk whole disk 2144 0 = /dev/sdgk 193rd SCSI disk whole disk
2129 16 = /dev/sdgl 194th SCSI disk whole disk 2145 16 = /dev/sdgl 194th SCSI disk whole disk
@@ -2135,7 +2151,6 @@ Your cooperation is appreciated.
2135 disks (see major number 3) except that the limit on 2151 disks (see major number 3) except that the limit on
2136 partitions is 15. 2152 partitions is 15.
2137 2153
2138
2139133 block SCSI disk devices (208-223) 2154133 block SCSI disk devices (208-223)
2140 0 = /dev/sdha 209th SCSI disk whole disk 2155 0 = /dev/sdha 209th SCSI disk whole disk
2141 16 = /dev/sdhb 210th SCSI disk whole disk 2156 16 = /dev/sdhb 210th SCSI disk whole disk
@@ -2147,7 +2162,6 @@ Your cooperation is appreciated.
2147 disks (see major number 3) except that the limit on 2162 disks (see major number 3) except that the limit on
2148 partitions is 15. 2163 partitions is 15.
2149 2164
2150
2151134 block SCSI disk devices (224-239) 2165134 block SCSI disk devices (224-239)
2152 0 = /dev/sdhq 225th SCSI disk whole disk 2166 0 = /dev/sdhq 225th SCSI disk whole disk
2153 16 = /dev/sdhr 226th SCSI disk whole disk 2167 16 = /dev/sdhr 226th SCSI disk whole disk
@@ -2159,7 +2173,6 @@ Your cooperation is appreciated.
2159 disks (see major number 3) except that the limit on 2173 disks (see major number 3) except that the limit on
2160 partitions is 15. 2174 partitions is 15.
2161 2175
2162
2163135 block SCSI disk devices (240-255) 2176135 block SCSI disk devices (240-255)
2164 0 = /dev/sdig 241st SCSI disk whole disk 2177 0 = /dev/sdig 241st SCSI disk whole disk
2165 16 = /dev/sdih 242nd SCSI disk whole disk 2178 16 = /dev/sdih 242nd SCSI disk whole disk
@@ -2171,7 +2184,6 @@ Your cooperation is appreciated.
2171 disks (see major number 3) except that the limit on 2184 disks (see major number 3) except that the limit on
2172 partitions is 15. 2185 partitions is 15.
2173 2186
2174
2175136-143 char Unix98 PTY slaves 2187136-143 char Unix98 PTY slaves
2176 0 = /dev/pts/0 First Unix98 pseudo-TTY 2188 0 = /dev/pts/0 First Unix98 pseudo-TTY
2177 1 = /dev/pts/1 Second Unix98 pesudo-TTY 2189 1 = /dev/pts/1 Second Unix98 pesudo-TTY
@@ -2384,6 +2396,7 @@ Your cooperation is appreciated.
2384 ... 2396 ...
2385 2397
2386159 char RESERVED 2398159 char RESERVED
2399
2387159 block RESERVED 2400159 block RESERVED
2388 2401
2389160 char General Purpose Instrument Bus (GPIB) 2402160 char General Purpose Instrument Bus (GPIB)
@@ -2427,7 +2440,7 @@ Your cooperation is appreciated.
2427 2440
2428 Partitions are handled in the same way as for IDE 2441 Partitions are handled in the same way as for IDE
2429 disks (see major number 3) except that the limit on 2442 disks (see major number 3) except that the limit on
2430 partitions is 31. 2443 partitions is 31.
2431 2444
2432162 char Raw block device interface 2445162 char Raw block device interface
2433 0 = /dev/rawctl Raw I/O control device 2446 0 = /dev/rawctl Raw I/O control device
@@ -2483,7 +2496,6 @@ Your cooperation is appreciated.
2483 2496
2484171 char Reserved for IEEE 1394 (Firewire) 2497171 char Reserved for IEEE 1394 (Firewire)
2485 2498
2486
2487172 char Moxa Intellio serial card 2499172 char Moxa Intellio serial card
2488 0 = /dev/ttyMX0 First Moxa port 2500 0 = /dev/ttyMX0 First Moxa port
2489 1 = /dev/ttyMX1 Second Moxa port 2501 1 = /dev/ttyMX1 Second Moxa port
@@ -2543,9 +2555,6 @@ Your cooperation is appreciated.
2543 64 = /dev/usb/rio500 Diamond Rio 500 2555 64 = /dev/usb/rio500 Diamond Rio 500
2544 65 = /dev/usb/usblcd USBLCD Interface (info@usblcd.de) 2556 65 = /dev/usb/usblcd USBLCD Interface (info@usblcd.de)
2545 66 = /dev/usb/cpad0 Synaptics cPad (mouse/LCD) 2557 66 = /dev/usb/cpad0 Synaptics cPad (mouse/LCD)
2546 67 = /dev/usb/adutux0 1st Ontrak ADU device
2547 ...
2548 76 = /dev/usb/adutux10 10th Ontrak ADU device
2549 96 = /dev/usb/hiddev0 1st USB HID device 2558 96 = /dev/usb/hiddev0 1st USB HID device
2550 ... 2559 ...
2551 111 = /dev/usb/hiddev15 16th USB HID device 2560 111 = /dev/usb/hiddev15 16th USB HID device
@@ -2558,7 +2567,7 @@ Your cooperation is appreciated.
2558 132 = /dev/usb/idmouse ID Mouse (fingerprint scanner) device 2567 132 = /dev/usb/idmouse ID Mouse (fingerprint scanner) device
2559 133 = /dev/usb/sisusbvga1 First SiSUSB VGA device 2568 133 = /dev/usb/sisusbvga1 First SiSUSB VGA device
2560 ... 2569 ...
2561 140 = /dev/usb/sisusbvga8 Eigth SISUSB VGA device 2570 140 = /dev/usb/sisusbvga8 Eighth SISUSB VGA device
2562 144 = /dev/usb/lcd USB LCD device 2571 144 = /dev/usb/lcd USB LCD device
2563 160 = /dev/usb/legousbtower0 1st USB Legotower device 2572 160 = /dev/usb/legousbtower0 1st USB Legotower device
2564 ... 2573 ...
@@ -2571,7 +2580,7 @@ Your cooperation is appreciated.
2571 0 = /dev/uba First USB block device 2580 0 = /dev/uba First USB block device
2572 8 = /dev/ubb Second USB block device 2581 8 = /dev/ubb Second USB block device
2573 16 = /dev/ubc Third USB block device 2582 16 = /dev/ubc Third USB block device
2574 ... 2583 ...
2575 2584
2576181 char Conrad Electronic parallel port radio clocks 2585181 char Conrad Electronic parallel port radio clocks
2577 0 = /dev/pcfclock0 First Conrad radio clock 2586 0 = /dev/pcfclock0 First Conrad radio clock
@@ -2657,7 +2666,7 @@ Your cooperation is appreciated.
2657 32 = /dev/mvideo/status2 Third device 2666 32 = /dev/mvideo/status2 Third device
2658 ... 2667 ...
2659 ... 2668 ...
2660 240 = /dev/mvideo/status15 16th device 2669 240 = /dev/mvideo/status15 16th device
2661 ... 2670 ...
2662 2671
2663195 char Nvidia graphics devices 2672195 char Nvidia graphics devices
@@ -2795,6 +2804,10 @@ Your cooperation is appreciated.
2795 ... 2804 ...
2796 185 = /dev/ttyNX15 Hilscher netX serial port 15 2805 185 = /dev/ttyNX15 Hilscher netX serial port 15
2797 186 = /dev/ttyJ0 JTAG1 DCC protocol based serial port emulation 2806 186 = /dev/ttyJ0 JTAG1 DCC protocol based serial port emulation
2807 187 = /dev/ttyUL0 Xilinx uartlite - port 0
2808 ...
2809 190 = /dev/ttyUL3 Xilinx uartlite - port 3
2810 191 = /dev/xvc0 Xen virtual console - port 0
2798 2811
2799205 char Low-density serial ports (alternate device) 2812205 char Low-density serial ports (alternate device)
2800 0 = /dev/culu0 Callout device for ttyLU0 2813 0 = /dev/culu0 Callout device for ttyLU0
@@ -2832,7 +2845,6 @@ Your cooperation is appreciated.
2832 82 = /dev/cuvr0 Callout device for ttyVR0 2845 82 = /dev/cuvr0 Callout device for ttyVR0
2833 83 = /dev/cuvr1 Callout device for ttyVR1 2846 83 = /dev/cuvr1 Callout device for ttyVR1
2834 2847
2835
2836206 char OnStream SC-x0 tape devices 2848206 char OnStream SC-x0 tape devices
2837 0 = /dev/osst0 First OnStream SCSI tape, mode 0 2849 0 = /dev/osst0 First OnStream SCSI tape, mode 0
2838 1 = /dev/osst1 Second OnStream SCSI tape, mode 0 2850 1 = /dev/osst1 Second OnStream SCSI tape, mode 0
@@ -2922,7 +2934,6 @@ Your cooperation is appreciated.
2922 ... 2934 ...
2923 2935
2924212 char LinuxTV.org DVB driver subsystem 2936212 char LinuxTV.org DVB driver subsystem
2925
2926 0 = /dev/dvb/adapter0/video0 first video decoder of first card 2937 0 = /dev/dvb/adapter0/video0 first video decoder of first card
2927 1 = /dev/dvb/adapter0/audio0 first audio decoder of first card 2938 1 = /dev/dvb/adapter0/audio0 first audio decoder of first card
2928 2 = /dev/dvb/adapter0/sec0 (obsolete/unused) 2939 2 = /dev/dvb/adapter0/sec0 (obsolete/unused)
@@ -3008,9 +3019,9 @@ Your cooperation is appreciated.
3008 2 = /dev/3270/tub2 Second 3270 terminal 3019 2 = /dev/3270/tub2 Second 3270 terminal
3009 ... 3020 ...
3010 3021
3011229 char IBM iSeries virtual console 3022229 char IBM iSeries/pSeries virtual console
3012 0 = /dev/iseries/vtty0 First console port 3023 0 = /dev/hvc0 First console port
3013 1 = /dev/iseries/vtty1 Second console port 3024 1 = /dev/hvc1 Second console port
3014 ... 3025 ...
3015 3026
3016230 char IBM iSeries virtual tape 3027230 char IBM iSeries virtual tape
@@ -3083,12 +3094,14 @@ Your cooperation is appreciated.
3083234-239 UNASSIGNED 3094234-239 UNASSIGNED
3084 3095
3085240-254 char LOCAL/EXPERIMENTAL USE 3096240-254 char LOCAL/EXPERIMENTAL USE
3097
3086240-254 block LOCAL/EXPERIMENTAL USE 3098240-254 block LOCAL/EXPERIMENTAL USE
3087 Allocated for local/experimental use. For devices not 3099 Allocated for local/experimental use. For devices not
3088 assigned official numbers, these ranges should be 3100 assigned official numbers, these ranges should be
3089 used in order to avoid conflicting with future assignments. 3101 used in order to avoid conflicting with future assignments.
3090 3102
3091255 char RESERVED 3103255 char RESERVED
3104
3092255 block RESERVED 3105255 block RESERVED
3093 3106
3094 This major is reserved to assist the expansion to a 3107 This major is reserved to assist the expansion to a
@@ -3115,7 +3128,20 @@ Your cooperation is appreciated.
3115257 char Phoenix Technologies Cryptographic Services Driver 3128257 char Phoenix Technologies Cryptographic Services Driver
3116 0 = /dev/ptlsec Crypto Services Driver 3129 0 = /dev/ptlsec Crypto Services Driver
3117 3130
3118 3131257 block SSFDC Flash Translation Layer filesystem
3132 0 = /dev/ssfdca First SSFDC layer
3133 8 = /dev/ssfdcb Second SSFDC layer
3134 16 = /dev/ssfdcc Third SSFDC layer
3135 24 = /dev/ssfdcd 4th SSFDC layer
3136 32 = /dev/ssfdce 5th SSFDC layer
3137 40 = /dev/ssfdcf 6th SSFDC layer
3138 48 = /dev/ssfdcg 7th SSFDC layer
3139 56 = /dev/ssfdch 8th SSFDC layer
3140
3141258 block ROM/Flash read-only translation layer
3142 0 = /dev/blockrom0 First ROM card's translation layer interface
3143 1 = /dev/blockrom1 Second ROM card's translation layer interface
3144 ...
3119 3145
3120 **** ADDITIONAL /dev DIRECTORY ENTRIES 3146 **** ADDITIONAL /dev DIRECTORY ENTRIES
3121 3147
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index eb1a6cad21e6..790ef6fbe495 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -124,7 +124,7 @@ sync_fs: no no read
124write_super_lockfs: ? 124write_super_lockfs: ?
125unlockfs: ? 125unlockfs: ?
126statfs: no no no 126statfs: no no no
127remount_fs: no yes maybe (see below) 127remount_fs: yes yes maybe (see below)
128clear_inode: no 128clear_inode: no
129umount_begin: yes no no 129umount_begin: yes no no
130show_options: no (vfsmount->sem) 130show_options: no (vfsmount->sem)
diff --git a/Documentation/filesystems/fuse.txt b/Documentation/filesystems/fuse.txt
index 3d7447738958..345392c4caeb 100644
--- a/Documentation/filesystems/fuse.txt
+++ b/Documentation/filesystems/fuse.txt
@@ -51,6 +51,22 @@ homepage:
51 51
52 http://fuse.sourceforge.net/ 52 http://fuse.sourceforge.net/
53 53
54Filesystem type
55~~~~~~~~~~~~~~~
56
57The filesystem type given to mount(2) can be one of the following:
58
59'fuse'
60
61 This is the usual way to mount a FUSE filesystem. The first
62 argument of the mount system call may contain an arbitrary string,
63 which is not interpreted by the kernel.
64
65'fuseblk'
66
67 The filesystem is block device based. The first argument of the
68 mount system call is interpreted as the name of the device.
69
54Mount options 70Mount options
55~~~~~~~~~~~~~ 71~~~~~~~~~~~~~
56 72
@@ -94,6 +110,11 @@ Mount options
94 The default is infinite. Note that the size of read requests is 110 The default is infinite. Note that the size of read requests is
95 limited anyway to 32 pages (which is 128kbyte on i386). 111 limited anyway to 32 pages (which is 128kbyte on i386).
96 112
113'blksize=N'
114
115 Set the block size for the filesystem. The default is 512. This
116 option is only valid for 'fuseblk' type mounts.
117
97Control filesystem 118Control filesystem
98~~~~~~~~~~~~~~~~~~ 119~~~~~~~~~~~~~~~~~~
99 120
diff --git a/Documentation/filesystems/sysv-fs.txt b/Documentation/filesystems/sysv-fs.txt
index d81722418010..253b50d1328e 100644
--- a/Documentation/filesystems/sysv-fs.txt
+++ b/Documentation/filesystems/sysv-fs.txt
@@ -1,11 +1,8 @@
1This is the implementation of the SystemV/Coherent filesystem for Linux.
2It implements all of 1It implements all of
3 - Xenix FS, 2 - Xenix FS,
4 - SystemV/386 FS, 3 - SystemV/386 FS,
5 - Coherent FS. 4 - Coherent FS.
6 5
7This is version beta 4.
8
9To install: 6To install:
10* Answer the 'System V and Coherent filesystem support' question with 'y' 7* Answer the 'System V and Coherent filesystem support' question with 'y'
11 when configuring the kernel. 8 when configuring the kernel.
@@ -28,11 +25,173 @@ Bugs in the present implementation:
28 for this FS on hard disk yet. 25 for this FS on hard disk yet.
29 26
30 27
31Please report any bugs and suggestions to 28These filesystems are rather similar. Here is a comparison with Minix FS:
32 Bruno Haible <haible@ma2s2.mathematik.uni-karlsruhe.de> 29
33 Pascal Haible <haible@izfm.uni-stuttgart.de> 30* Linux fdisk reports on partitions
34 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl> 31 - Minix FS 0x81 Linux/Minix
32 - Xenix FS ??
33 - SystemV FS ??
34 - Coherent FS 0x08 AIX bootable
35
36* Size of a block or zone (data allocation unit on disk)
37 - Minix FS 1024
38 - Xenix FS 1024 (also 512 ??)
39 - SystemV FS 1024 (also 512 and 2048)
40 - Coherent FS 512
41
42* General layout: all have one boot block, one super block and
43 separate areas for inodes and for directories/data.
44 On SystemV Release 2 FS (e.g. Microport) the first track is reserved and
45 all the block numbers (including the super block) are offset by one track.
46
47* Byte ordering of "short" (16 bit entities) on disk:
48 - Minix FS little endian 0 1
49 - Xenix FS little endian 0 1
50 - SystemV FS little endian 0 1
51 - Coherent FS little endian 0 1
52 Of course, this affects only the file system, not the data of files on it!
53
54* Byte ordering of "long" (32 bit entities) on disk:
55 - Minix FS little endian 0 1 2 3
56 - Xenix FS little endian 0 1 2 3
57 - SystemV FS little endian 0 1 2 3
58 - Coherent FS PDP-11 2 3 0 1
59 Of course, this affects only the file system, not the data of files on it!
60
61* Inode on disk: "short", 0 means non-existent, the root dir ino is:
62 - Minix FS 1
63 - Xenix FS, SystemV FS, Coherent FS 2
64
65* Maximum number of hard links to a file:
66 - Minix FS 250
67 - Xenix FS ??
68 - SystemV FS ??
69 - Coherent FS >=10000
70
71* Free inode management:
72 - Minix FS a bitmap
73 - Xenix FS, SystemV FS, Coherent FS
74 There is a cache of a certain number of free inodes in the super-block.
75 When it is exhausted, new free inodes are found using a linear search.
76
77* Free block management:
78 - Minix FS a bitmap
79 - Xenix FS, SystemV FS, Coherent FS
80 Free blocks are organized in a "free list". Maybe a misleading term,
81 since it is not true that every free block contains a pointer to
82 the next free block. Rather, the free blocks are organized in chunks
83 of limited size, and every now and then a free block contains pointers
84 to the free blocks pertaining to the next chunk; the first of these
85 contains pointers and so on. The list terminates with a "block number"
86 0 on Xenix FS and SystemV FS, with a block zeroed out on Coherent FS.
87
88* Super-block location:
89 - Minix FS block 1 = bytes 1024..2047
90 - Xenix FS block 1 = bytes 1024..2047
91 - SystemV FS bytes 512..1023
92 - Coherent FS block 1 = bytes 512..1023
93
94* Super-block layout:
95 - Minix FS
96 unsigned short s_ninodes;
97 unsigned short s_nzones;
98 unsigned short s_imap_blocks;
99 unsigned short s_zmap_blocks;
100 unsigned short s_firstdatazone;
101 unsigned short s_log_zone_size;
102 unsigned long s_max_size;
103 unsigned short s_magic;
104 - Xenix FS, SystemV FS, Coherent FS
105 unsigned short s_firstdatazone;
106 unsigned long s_nzones;
107 unsigned short s_fzone_count;
108 unsigned long s_fzones[NICFREE];
109 unsigned short s_finode_count;
110 unsigned short s_finodes[NICINOD];
111 char s_flock;
112 char s_ilock;
113 char s_modified;
114 char s_rdonly;
115 unsigned long s_time;
116 short s_dinfo[4]; -- SystemV FS only
117 unsigned long s_free_zones;
118 unsigned short s_free_inodes;
119 short s_dinfo[4]; -- Xenix FS only
120 unsigned short s_interleave_m,s_interleave_n; -- Coherent FS only
121 char s_fname[6];
122 char s_fpack[6];
123 then they differ considerably:
124 Xenix FS
125 char s_clean;
126 char s_fill[371];
127 long s_magic;
128 long s_type;
129 SystemV FS
130 long s_fill[12 or 14];
131 long s_state;
132 long s_magic;
133 long s_type;
134 Coherent FS
135 unsigned long s_unique;
136 Note that Coherent FS has no magic.
137
138* Inode layout:
139 - Minix FS
140 unsigned short i_mode;
141 unsigned short i_uid;
142 unsigned long i_size;
143 unsigned long i_time;
144 unsigned char i_gid;
145 unsigned char i_nlinks;
146 unsigned short i_zone[7+1+1];
147 - Xenix FS, SystemV FS, Coherent FS
148 unsigned short i_mode;
149 unsigned short i_nlink;
150 unsigned short i_uid;
151 unsigned short i_gid;
152 unsigned long i_size;
153 unsigned char i_zone[3*(10+1+1+1)];
154 unsigned long i_atime;
155 unsigned long i_mtime;
156 unsigned long i_ctime;
157
158* Regular file data blocks are organized as
159 - Minix FS
160 7 direct blocks
161 1 indirect block (pointers to blocks)
162 1 double-indirect block (pointer to pointers to blocks)
163 - Xenix FS, SystemV FS, Coherent FS
164 10 direct blocks
165 1 indirect block (pointers to blocks)
166 1 double-indirect block (pointer to pointers to blocks)
167 1 triple-indirect block (pointer to pointers to pointers to blocks)
168
169* Inode size, inodes per block
170 - Minix FS 32 32
171 - Xenix FS 64 16
172 - SystemV FS 64 16
173 - Coherent FS 64 8
174
175* Directory entry on disk
176 - Minix FS
177 unsigned short inode;
178 char name[14/30];
179 - Xenix FS, SystemV FS, Coherent FS
180 unsigned short inode;
181 char name[14];
182
183* Dir entry size, dir entries per block
184 - Minix FS 16/32 64/32
185 - Xenix FS 16 64
186 - SystemV FS 16 64
187 - Coherent FS 16 32
188
189* How to implement symbolic links such that the host fsck doesn't scream:
190 - Minix FS normal
191 - Xenix FS kludge: as regular files with chmod 1000
192 - SystemV FS ??
193 - Coherent FS kludge: as regular files with chmod 1000
35 194
36Bruno Haible
37<haible@ma2s2.mathematik.uni-karlsruhe.de>
38 195
196Notation: We often speak of a "block" but mean a zone (the allocation unit)
197and not the disk driver's notion of "block".
diff --git a/Documentation/i386/boot.txt b/Documentation/i386/boot.txt
index c51314b1a463..9575de300a61 100644
--- a/Documentation/i386/boot.txt
+++ b/Documentation/i386/boot.txt
@@ -2,7 +2,7 @@
2 ---------------------------- 2 ----------------------------
3 3
4 H. Peter Anvin <hpa@zytor.com> 4 H. Peter Anvin <hpa@zytor.com>
5 Last update 2005-09-02 5 Last update 2006-11-17
6 6
7On the i386 platform, the Linux kernel uses a rather complicated boot 7On the i386 platform, the Linux kernel uses a rather complicated boot
8convention. This has evolved partially due to historical aspects, as 8convention. This has evolved partially due to historical aspects, as
@@ -35,6 +35,8 @@ Protocol 2.03: (Kernel 2.4.18-pre1) Explicitly makes the highest possible
35 initrd address available to the bootloader. 35 initrd address available to the bootloader.
36 36
37Protocol 2.04: (Kernel 2.6.14) Extend the syssize field to four bytes. 37Protocol 2.04: (Kernel 2.6.14) Extend the syssize field to four bytes.
38Protocol 2.05: (Kernel 2.6.20) Make protected mode kernel relocatable.
39 Introduce relocatable_kernel and kernel_alignment fields.
38 40
39 41
40**** MEMORY LAYOUT 42**** MEMORY LAYOUT
@@ -129,6 +131,8 @@ Offset Proto Name Meaning
1290226/2 N/A pad1 Unused 1310226/2 N/A pad1 Unused
1300228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line 1320228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line
131022C/4 2.03+ initrd_addr_max Highest legal initrd address 133022C/4 2.03+ initrd_addr_max Highest legal initrd address
1340230/4 2.05+ kernel_alignment Physical addr alignment required for kernel
1350234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not
132 136
133(1) For backwards compatibility, if the setup_sects field contains 0, the 137(1) For backwards compatibility, if the setup_sects field contains 0, the
134 real value is 4. 138 real value is 4.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 2e1898e4e8fd..b79bcdf16319 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -599,8 +599,6 @@ and is between 256 and 4096 characters. It is defined in the file
599 599
600 hugepages= [HW,IA-32,IA-64] Maximal number of HugeTLB pages. 600 hugepages= [HW,IA-32,IA-64] Maximal number of HugeTLB pages.
601 601
602 noirqbalance [IA-32,SMP,KNL] Disable kernel irq balancing
603
604 i8042.direct [HW] Put keyboard port into non-translated mode 602 i8042.direct [HW] Put keyboard port into non-translated mode
605 i8042.dumbkbd [HW] Pretend that controller can only read data from 603 i8042.dumbkbd [HW] Pretend that controller can only read data from
606 keyboard and cannot control its state 604 keyboard and cannot control its state
@@ -650,6 +648,10 @@ and is between 256 and 4096 characters. It is defined in the file
650 idle= [HW] 648 idle= [HW]
651 Format: idle=poll or idle=halt 649 Format: idle=poll or idle=halt
652 650
651 ignore_loglevel [KNL]
652 Ignore loglevel setting - this will print /all/
653 kernel messages to the console. Useful for debugging.
654
653 ihash_entries= [KNL] 655 ihash_entries= [KNL]
654 Set number of hash buckets for inode cache. 656 Set number of hash buckets for inode cache.
655 657
@@ -714,7 +716,12 @@ and is between 256 and 4096 characters. It is defined in the file
714 Format: <RDP>,<reset>,<pci_scan>,<verbosity> 716 Format: <RDP>,<reset>,<pci_scan>,<verbosity>
715 717
716 isolcpus= [KNL,SMP] Isolate CPUs from the general scheduler. 718 isolcpus= [KNL,SMP] Isolate CPUs from the general scheduler.
717 Format: <cpu number>,...,<cpu number> 719 Format:
720 <cpu number>,...,<cpu number>
721 or
722 <cpu number>-<cpu number> (must be a positive range in ascending order)
723 or a mixture
724 <cpu number>,...,<cpu number>-<cpu number>
718 This option can be used to specify one or more CPUs 725 This option can be used to specify one or more CPUs
719 to isolate from the general SMP balancing and scheduling 726 to isolate from the general SMP balancing and scheduling
720 algorithms. The only way to move a process onto or off 727 algorithms. The only way to move a process onto or off
@@ -1012,6 +1019,10 @@ and is between 256 and 4096 characters. It is defined in the file
1012 emulation library even if a 387 maths coprocessor 1019 emulation library even if a 387 maths coprocessor
1013 is present. 1020 is present.
1014 1021
1022 noaliencache [MM, NUMA] Disables the allcoation of alien caches in
1023 the slab allocator. Saves per-node memory, but will
1024 impact performance on real NUMA hardware.
1025
1015 noalign [KNL,ARM] 1026 noalign [KNL,ARM]
1016 1027
1017 noapic [SMP,APIC] Tells the kernel to not make use of any 1028 noapic [SMP,APIC] Tells the kernel to not make use of any
@@ -1052,9 +1063,14 @@ and is between 256 and 4096 characters. It is defined in the file
1052 in certain environments such as networked servers or 1063 in certain environments such as networked servers or
1053 real-time systems. 1064 real-time systems.
1054 1065
1066 noirqbalance [IA-32,SMP,KNL] Disable kernel irq balancing
1067
1055 noirqdebug [IA-32] Disables the code which attempts to detect and 1068 noirqdebug [IA-32] Disables the code which attempts to detect and
1056 disable unhandled interrupt sources. 1069 disable unhandled interrupt sources.
1057 1070
1071 no_timer_check [IA-32,X86_64,APIC] Disables the code which tests for
1072 broken timer IRQ sources.
1073
1058 noisapnp [ISAPNP] Disables ISA PnP code. 1074 noisapnp [ISAPNP] Disables ISA PnP code.
1059 1075
1060 noinitrd [RAM] Tells the kernel not to load any configured 1076 noinitrd [RAM] Tells the kernel not to load any configured
@@ -1285,6 +1301,7 @@ and is between 256 and 4096 characters. It is defined in the file
1285 Param: "schedule" - profile schedule points. 1301 Param: "schedule" - profile schedule points.
1286 Param: <number> - step/bucket size as a power of 2 for 1302 Param: <number> - step/bucket size as a power of 2 for
1287 statistical time based profiling. 1303 statistical time based profiling.
1304 Param: "sleep" - profile D-state sleeping (millisecs)
1288 1305
1289 processor.max_cstate= [HW,ACPI] 1306 processor.max_cstate= [HW,ACPI]
1290 Limit processor to maximum C-state 1307 Limit processor to maximum C-state
@@ -1366,6 +1383,12 @@ and is between 256 and 4096 characters. It is defined in the file
1366 resume= [SWSUSP] 1383 resume= [SWSUSP]
1367 Specify the partition device for software suspend 1384 Specify the partition device for software suspend
1368 1385
1386 resume_offset= [SWSUSP]
1387 Specify the offset from the beginning of the partition
1388 given by "resume=" at which the swap header is located,
1389 in <PAGE_SIZE> units (needed only for swap files).
1390 See Documentation/power/swsusp-and-swap-files.txt
1391
1369 rhash_entries= [KNL,NET] 1392 rhash_entries= [KNL,NET]
1370 Set number of hash buckets for route cache 1393 Set number of hash buckets for route cache
1371 1394
@@ -1732,6 +1755,9 @@ and is between 256 and 4096 characters. It is defined in the file
1732 norandmaps Don't use address space randomization 1755 norandmaps Don't use address space randomization
1733 Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space 1756 Equivalent to echo 0 > /proc/sys/kernel/randomize_va_space
1734 1757
1758 unwind_debug=N N > 0 will enable dwarf2 unwinder debugging
1759 This is useful to get more information why
1760 you got a "dwarf2 unwinder stuck"
1735 1761
1736______________________________________________________________________ 1762______________________________________________________________________
1737 1763
diff --git a/Documentation/networking/00-INDEX b/Documentation/networking/00-INDEX
index b1181ce232d9..e06b6e3c1db5 100644
--- a/Documentation/networking/00-INDEX
+++ b/Documentation/networking/00-INDEX
@@ -58,6 +58,8 @@ fore200e.txt
58 - FORE Systems PCA-200E/SBA-200E ATM NIC driver info. 58 - FORE Systems PCA-200E/SBA-200E ATM NIC driver info.
59framerelay.txt 59framerelay.txt
60 - info on using Frame Relay/Data Link Connection Identifier (DLCI). 60 - info on using Frame Relay/Data Link Connection Identifier (DLCI).
61generic_netlink.txt
62 - info on Generic Netlink
61ip-sysctl.txt 63ip-sysctl.txt
62 - /proc/sys/net/ipv4/* variables 64 - /proc/sys/net/ipv4/* variables
63ip_dynaddr.txt 65ip_dynaddr.txt
diff --git a/Documentation/networking/generic_netlink.txt b/Documentation/networking/generic_netlink.txt
new file mode 100644
index 000000000000..d4f8b8b9b53c
--- /dev/null
+++ b/Documentation/networking/generic_netlink.txt
@@ -0,0 +1,3 @@
1A wiki document on how to use Generic Netlink can be found here:
2
3 * http://linux-net.osdl.org/index.php/Generic_Netlink_HOWTO
diff --git a/Documentation/power/s2ram.txt b/Documentation/power/s2ram.txt
new file mode 100644
index 000000000000..b05f512130ea
--- /dev/null
+++ b/Documentation/power/s2ram.txt
@@ -0,0 +1,56 @@
1 How to get s2ram working
2 ~~~~~~~~~~~~~~~~~~~~~~~~
3 2006 Linus Torvalds
4 2006 Pavel Machek
5
61) Check suspend.sf.net, program s2ram there has long whitelist of
7 "known ok" machines, along with tricks to use on each one.
8
92) If that does not help, try reading tricks.txt and
10 video.txt. Perhaps problem is as simple as broken module, and
11 simple module unload can fix it.
12
133) You can use Linus' TRACE_RESUME infrastructure, described below.
14
15 Using TRACE_RESUME
16 ~~~~~~~~~~~~~~~~~~
17
18I've been working at making the machines I have able to STR, and almost
19always it's a driver that is buggy. Thank God for the suspend/resume
20debugging - the thing that Chuck tried to disable. That's often the _only_
21way to debug these things, and it's actually pretty powerful (but
22time-consuming - having to insert TRACE_RESUME() markers into the device
23driver that doesn't resume and recompile and reboot).
24
25Anyway, the way to debug this for people who are interested (have a
26machine that doesn't boot) is:
27
28 - enable PM_DEBUG, and PM_TRACE
29
30 - use a script like this:
31
32 #!/bin/sh
33 sync
34 echo 1 > /sys/power/pm_trace
35 echo mem > /sys/power/state
36
37 to suspend
38
39 - if it doesn't come back up (which is usually the problem), reboot by
40 holding the power button down, and look at the dmesg output for things
41 like
42
43 Magic number: 4:156:725
44 hash matches drivers/base/power/resume.c:28
45 hash matches device 0000:01:00.0
46
47 which means that the last trace event was just before trying to resume
48 device 0000:01:00.0. Then figure out what driver is controlling that
49 device (lspci and /sys/devices/pci* is your friend), and see if you can
50 fix it, disable it, or trace into its resume function.
51
52For example, the above happens to be the VGA device on my EVO, which I
53used to run with "radeonfb" (it's an ATI Radeon mobility). It turns out
54that "radeonfb" simply cannot resume that device - it tries to set the
55PLL's, and it just _hangs_. Using the regular VGA console and letting X
56resume it instead works fine.
diff --git a/Documentation/power/swsusp-and-swap-files.txt b/Documentation/power/swsusp-and-swap-files.txt
new file mode 100644
index 000000000000..06f911a5f885
--- /dev/null
+++ b/Documentation/power/swsusp-and-swap-files.txt
@@ -0,0 +1,60 @@
1Using swap files with software suspend (swsusp)
2 (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
3
4The Linux kernel handles swap files almost in the same way as it handles swap
5partitions and there are only two differences between these two types of swap
6areas:
7(1) swap files need not be contiguous,
8(2) the header of a swap file is not in the first block of the partition that
9holds it. From the swsusp's point of view (1) is not a problem, because it is
10already taken care of by the swap-handling code, but (2) has to be taken into
11consideration.
12
13In principle the location of a swap file's header may be determined with the
14help of appropriate filesystem driver. Unfortunately, however, it requires the
15filesystem holding the swap file to be mounted, and if this filesystem is
16journaled, it cannot be mounted during resume from disk. For this reason to
17identify a swap file swsusp uses the name of the partition that holds the file
18and the offset from the beginning of the partition at which the swap file's
19header is located. For convenience, this offset is expressed in <PAGE_SIZE>
20units.
21
22In order to use a swap file with swsusp, you need to:
23
241) Create the swap file and make it active, eg.
25
26# dd if=/dev/zero of=<swap_file_path> bs=1024 count=<swap_file_size_in_k>
27# mkswap <swap_file_path>
28# swapon <swap_file_path>
29
302) Use an application that will bmap the swap file with the help of the
31FIBMAP ioctl and determine the location of the file's swap header, as the
32offset, in <PAGE_SIZE> units, from the beginning of the partition which
33holds the swap file.
34
353) Add the following parameters to the kernel command line:
36
37resume=<swap_file_partition> resume_offset=<swap_file_offset>
38
39where <swap_file_partition> is the partition on which the swap file is located
40and <swap_file_offset> is the offset of the swap header determined by the
41application in 2) (of course, this step may be carried out automatically
42by the same application that determies the swap file's header offset using the
43FIBMAP ioctl)
44
45OR
46
47Use a userland suspend application that will set the partition and offset
48with the help of the SNAPSHOT_SET_SWAP_AREA ioctl described in
49Documentation/power/userland-swsusp.txt (this is the only method to suspend
50to a swap file allowing the resume to be initiated from an initrd or initramfs
51image).
52
53Now, swsusp will use the swap file in the same way in which it would use a swap
54partition. In particular, the swap file has to be active (ie. be present in
55/proc/swaps) so that it can be used for suspending.
56
57Note that if the swap file used for suspending is deleted and recreated,
58the location of its header need not be the same as before. Thus every time
59this happens the value of the "resume_offset=" kernel command line parameter
60has to be updated.
diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
index e635e6f1e316..0761ff6c57ed 100644
--- a/Documentation/power/swsusp.txt
+++ b/Documentation/power/swsusp.txt
@@ -297,20 +297,12 @@ system is shut down or suspended. Additionally use the encrypted
297suspend image to prevent sensitive data from being stolen after 297suspend image to prevent sensitive data from being stolen after
298resume. 298resume.
299 299
300Q: Why can't we suspend to a swap file? 300Q: Can I suspend to a swap file?
301 301
302A: Because accessing swap file needs the filesystem mounted, and 302A: Generally, yes, you can. However, it requires you to use the "resume=" and
303filesystem might do something wrong (like replaying the journal) 303"resume_offset=" kernel command line parameters, so the resume from a swap file
304during mount. 304cannot be initiated from an initrd or initramfs image. See
305 305swsusp-and-swap-files.txt for details.
306There are few ways to get that fixed:
307
3081) Probably could be solved by modifying every filesystem to support
309some kind of "really read-only!" option. Patches welcome.
310
3112) suspend2 gets around that by storing absolute positions in on-disk
312image (and blocksize), with resume parameter pointing directly to
313suspend header.
314 306
315Q: Is there a maximum system RAM size that is supported by swsusp? 307Q: Is there a maximum system RAM size that is supported by swsusp?
316 308
diff --git a/Documentation/power/userland-swsusp.txt b/Documentation/power/userland-swsusp.txt
index 64755e9285db..000556c932e9 100644
--- a/Documentation/power/userland-swsusp.txt
+++ b/Documentation/power/userland-swsusp.txt
@@ -9,9 +9,8 @@ done it already.
9Now, to use the userland interface for software suspend you need special 9Now, to use the userland interface for software suspend you need special
10utilities that will read/write the system memory snapshot from/to the 10utilities that will read/write the system memory snapshot from/to the
11kernel. Such utilities are available, for example, from 11kernel. Such utilities are available, for example, from
12<http://www.sisk.pl/kernel/utilities/suspend>. You may want to have 12<http://suspend.sourceforge.net>. You may want to have a look at them if you
13a look at them if you are going to develop your own suspend/resume 13are going to develop your own suspend/resume utilities.
14utilities.
15 14
16The interface consists of a character device providing the open(), 15The interface consists of a character device providing the open(),
17release(), read(), and write() operations as well as several ioctl() 16release(), read(), and write() operations as well as several ioctl()
@@ -21,9 +20,9 @@ be read from /sys/class/misc/snapshot/dev.
21 20
22The device can be open either for reading or for writing. If open for 21The device can be open either for reading or for writing. If open for
23reading, it is considered to be in the suspend mode. Otherwise it is 22reading, it is considered to be in the suspend mode. Otherwise it is
24assumed to be in the resume mode. The device cannot be open for reading 23assumed to be in the resume mode. The device cannot be open for simultaneous
25and writing. It is also impossible to have the device open more than once 24reading and writing. It is also impossible to have the device open more than
26at a time. 25once at a time.
27 26
28The ioctl() commands recognized by the device are: 27The ioctl() commands recognized by the device are:
29 28
@@ -69,9 +68,46 @@ SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated with
69SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument 68SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument
70 should specify the device's major and minor numbers in the old 69 should specify the device's major and minor numbers in the old
71 two-byte format, as returned by the stat() function in the .st_rdev 70 two-byte format, as returned by the stat() function in the .st_rdev
72 member of the stat structure); it is recommended to always use this 71 member of the stat structure)
73 call, because the code to set the resume partition could be removed from 72
74 future kernels 73SNAPSHOT_SET_SWAP_AREA - set the resume partition and the offset (in <PAGE_SIZE>
74 units) from the beginning of the partition at which the swap header is
75 located (the last ioctl() argument should point to a struct
76 resume_swap_area, as defined in kernel/power/power.h, containing the
77 resume device specification, as for the SNAPSHOT_SET_SWAP_FILE ioctl(),
78 and the offset); for swap partitions the offset is always 0, but it is
79 different to zero for swap files (please see
80 Documentation/swsusp-and-swap-files.txt for details).
81 The SNAPSHOT_SET_SWAP_AREA ioctl() is considered as a replacement for
82 SNAPSHOT_SET_SWAP_FILE which is regarded as obsolete. It is
83 recommended to always use this call, because the code to set the resume
84 partition may be removed from future kernels
85
86SNAPSHOT_S2RAM - suspend to RAM; using this call causes the kernel to
87 immediately enter the suspend-to-RAM state, so this call must always
88 be preceded by the SNAPSHOT_FREEZE call and it is also necessary
89 to use the SNAPSHOT_UNFREEZE call after the system wakes up. This call
90 is needed to implement the suspend-to-both mechanism in which the
91 suspend image is first created, as though the system had been suspended
92 to disk, and then the system is suspended to RAM (this makes it possible
93 to resume the system from RAM if there's enough battery power or restore
94 its state on the basis of the saved suspend image otherwise)
95
96SNAPSHOT_PMOPS - enable the usage of the pmops->prepare, pmops->enter and
97 pmops->finish methods (the in-kernel swsusp knows these as the "platform
98 method") which are needed on many machines to (among others) speed up
99 the resume by letting the BIOS skip some steps or to let the system
100 recognise the correct state of the hardware after the resume (in
101 particular on many machines this ensures that unplugged AC
102 adapters get correctly detected and that kacpid does not run wild after
103 the resume). The last ioctl() argument can take one of the three
104 values, defined in kernel/power/power.h:
105 PMOPS_PREPARE - make the kernel carry out the
106 pm_ops->prepare(PM_SUSPEND_DISK) operation
107 PMOPS_ENTER - make the kernel power off the system by calling
108 pm_ops->enter(PM_SUSPEND_DISK)
109 PMOPS_FINISH - make the kernel carry out the
110 pm_ops->finish(PM_SUSPEND_DISK) operation
75 111
76The device's read() operation can be used to transfer the snapshot image from 112The device's read() operation can be used to transfer the snapshot image from
77the kernel. It has the following limitations: 113the kernel. It has the following limitations:
@@ -91,10 +127,12 @@ unfreeze user space processes frozen by SNAPSHOT_UNFREEZE if they are
91still frozen when the device is being closed). 127still frozen when the device is being closed).
92 128
93Currently it is assumed that the userland utilities reading/writing the 129Currently it is assumed that the userland utilities reading/writing the
94snapshot image from/to the kernel will use a swap partition, called the resume 130snapshot image from/to the kernel will use a swap parition, called the resume
95partition, as storage space. However, this is not really required, as they 131partition, or a swap file as storage space (if a swap file is used, the resume
96can use, for example, a special (blank) suspend partition or a file on a partition 132partition is the partition that holds this file). However, this is not really
97that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and mounted afterwards. 133required, as they can use, for example, a special (blank) suspend partition or
134a file on a partition that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and
135mounted afterwards.
98 136
99These utilities SHOULD NOT make any assumptions regarding the ordering of 137These utilities SHOULD NOT make any assumptions regarding the ordering of
100data within the snapshot image, except for the image header that MAY be 138data within the snapshot image, except for the image header that MAY be
diff --git a/Documentation/stable_api_nonsense.txt b/Documentation/stable_api_nonsense.txt
index f39c9d714db3..a2afca3b2bab 100644
--- a/Documentation/stable_api_nonsense.txt
+++ b/Documentation/stable_api_nonsense.txt
@@ -62,9 +62,6 @@ consider the following facts about the Linux kernel:
62 - different structures can contain different fields 62 - different structures can contain different fields
63 - Some functions may not be implemented at all, (i.e. some locks 63 - Some functions may not be implemented at all, (i.e. some locks
64 compile away to nothing for non-SMP builds.) 64 compile away to nothing for non-SMP builds.)
65 - Parameter passing of variables from function to function can be
66 done in different ways (the CONFIG_REGPARM option controls
67 this.)
68 - Memory within the kernel can be aligned in different ways, 65 - Memory within the kernel can be aligned in different ways,
69 depending on the build options. 66 depending on the build options.
70 - Linux runs on a wide range of different processor architectures. 67 - Linux runs on a wide range of different processor architectures.
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
index 0bc7f1e3c9e6..5922e84d9133 100644
--- a/Documentation/sysctl/kernel.txt
+++ b/Documentation/sysctl/kernel.txt
@@ -27,6 +27,7 @@ show up in /proc/sys/kernel:
27- hotplug 27- hotplug
28- java-appletviewer [ binfmt_java, obsolete ] 28- java-appletviewer [ binfmt_java, obsolete ]
29- java-interpreter [ binfmt_java, obsolete ] 29- java-interpreter [ binfmt_java, obsolete ]
30- kstack_depth_to_print [ X86 only ]
30- l2cr [ PPC only ] 31- l2cr [ PPC only ]
31- modprobe ==> Documentation/kmod.txt 32- modprobe ==> Documentation/kmod.txt
32- msgmax 33- msgmax
@@ -170,6 +171,13 @@ This flag controls the L2 cache of G3 processor boards. If
170 171
171============================================================== 172==============================================================
172 173
174kstack_depth_to_print: (X86 only)
175
176Controls the number of words to print when dumping the raw
177kernel stack.
178
179==============================================================
180
173osrelease, ostype & version: 181osrelease, ostype & version:
174 182
175# cat osrelease 183# cat osrelease
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index f3c57f43ba64..dbdcaf68e3ea 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -52,10 +52,6 @@ APICs
52 apicmaintimer. Useful when your PIT timer is totally 52 apicmaintimer. Useful when your PIT timer is totally
53 broken. 53 broken.
54 54
55 disable_8254_timer / enable_8254_timer
56 Enable interrupt 0 timer routing over the 8254 in addition to over
57 the IO-APIC. The kernel tries to set a sensible default.
58
59Early Console 55Early Console
60 56
61 syntax: earlyprintk=vga 57 syntax: earlyprintk=vga
@@ -183,7 +179,7 @@ PCI
183IOMMU 179IOMMU
184 180
185 iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge] 181 iommu=[size][,noagp][,off][,force][,noforce][,leak][,memaper[=order]][,merge]
186 [,forcesac][,fullflush][,nomerge][,noaperture] 182 [,forcesac][,fullflush][,nomerge][,noaperture][,calgary]
187 size set size of iommu (in bytes) 183 size set size of iommu (in bytes)
188 noagp don't initialize the AGP driver and use full aperture. 184 noagp don't initialize the AGP driver and use full aperture.
189 off don't use the IOMMU 185 off don't use the IOMMU
@@ -204,6 +200,7 @@ IOMMU
204 buffering. 200 buffering.
205 nodac Forbid DMA >4GB 201 nodac Forbid DMA >4GB
206 panic Always panic when IOMMU overflows 202 panic Always panic when IOMMU overflows
203 calgary Use the Calgary IOMMU if it is available
207 204
208 swiotlb=pages[,force] 205 swiotlb=pages[,force]
209 206
diff --git a/MAINTAINERS b/MAINTAINERS
index 5dff26814a06..cf24400213f8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1091,13 +1091,19 @@ M: miku@iki.fi
1091S: Maintained 1091S: Maintained
1092 1092
1093EXT2 FILE SYSTEM 1093EXT2 FILE SYSTEM
1094L: ext2-devel@lists.sourceforge.net 1094L: linux-ext4@vger.kernel.org
1095S: Maintained 1095S: Maintained
1096 1096
1097EXT3 FILE SYSTEM 1097EXT3 FILE SYSTEM
1098P: Stephen Tweedie, Andrew Morton 1098P: Stephen Tweedie, Andrew Morton
1099M: sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com 1099M: sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com
1100L: ext2-devel@lists.sourceforge.net 1100L: linux-ext4@vger.kernel.org
1101S: Maintained
1102
1103EXT4 FILE SYSTEM
1104P: Stephen Tweedie, Andrew Morton
1105M: sct@redhat.com, akpm@osdl.org, adilger@clusterfs.com
1106L: linux-ext4@vger.kernel.org
1101S: Maintained 1107S: Maintained
1102 1108
1103F71805F HARDWARE MONITORING DRIVER 1109F71805F HARDWARE MONITORING DRIVER
@@ -1214,7 +1220,8 @@ HARDWARE MONITORING
1214P: Jean Delvare 1220P: Jean Delvare
1215M: khali@linux-fr.org 1221M: khali@linux-fr.org
1216L: lm-sensors@lm-sensors.org 1222L: lm-sensors@lm-sensors.org
1217W: http://www.lm-sensors.nu/ 1223W: http://www.lm-sensors.org/
1224T: quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-hwmon/
1218S: Maintained 1225S: Maintained
1219 1226
1220HARDWARE RANDOM NUMBER GENERATOR CORE 1227HARDWARE RANDOM NUMBER GENERATOR CORE
@@ -1340,8 +1347,7 @@ I2C SUBSYSTEM
1340P: Jean Delvare 1347P: Jean Delvare
1341M: khali@linux-fr.org 1348M: khali@linux-fr.org
1342L: i2c@lm-sensors.org 1349L: i2c@lm-sensors.org
1343W: http://www.lm-sensors.nu/ 1350T: quilt http://khali.linux-fr.org/devel/linux-2.6/jdelvare-i2c/
1344T: quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
1345S: Maintained 1351S: Maintained
1346 1352
1347I2O 1353I2O
@@ -1673,7 +1679,7 @@ S: Supported
1673JOURNALLING LAYER FOR BLOCK DEVICES (JBD) 1679JOURNALLING LAYER FOR BLOCK DEVICES (JBD)
1674P: Stephen Tweedie, Andrew Morton 1680P: Stephen Tweedie, Andrew Morton
1675M: sct@redhat.com, akpm@osdl.org 1681M: sct@redhat.com, akpm@osdl.org
1676L: ext2-devel@lists.sourceforge.net 1682L: linux-ext4@vger.kernel.org
1677S: Maintained 1683S: Maintained
1678 1684
1679K8TEMP HARDWARE MONITORING DRIVER 1685K8TEMP HARDWARE MONITORING DRIVER
@@ -2913,7 +2919,6 @@ S: Maintained
2913SUN3/3X 2919SUN3/3X
2914P: Sam Creasey 2920P: Sam Creasey
2915M: sammy@sammy.net 2921M: sammy@sammy.net
2916L: sun3-list@redhat.com
2917W: http://sammy.net/sun3/ 2922W: http://sammy.net/sun3/
2918S: Maintained 2923S: Maintained
2919 2924
@@ -3454,6 +3459,12 @@ W: http://oss.sgi.com/projects/xfs
3454T: git git://oss.sgi.com:8090/xfs/xfs-2.6 3459T: git git://oss.sgi.com:8090/xfs/xfs-2.6
3455S: Supported 3460S: Supported
3456 3461
3462XILINX UARTLITE SERIAL DRIVER
3463P: Peter Korsgaard
3464M: jacmet@sunsite.dk
3465L: linux-serial@vger.kernel.org
3466S: Maintained
3467
3457X86 3-LEVEL PAGING (PAE) SUPPORT 3468X86 3-LEVEL PAGING (PAE) SUPPORT
3458P: Ingo Molnar 3469P: Ingo Molnar
3459M: mingo@redhat.com 3470M: mingo@redhat.com
diff --git a/REPORTING-BUGS b/REPORTING-BUGS
index f9da827a0c18..ac02e42a2627 100644
--- a/REPORTING-BUGS
+++ b/REPORTING-BUGS
@@ -40,7 +40,9 @@ summary from [1.]>" for easy identification by the developers.
40[1.] One line summary of the problem: 40[1.] One line summary of the problem:
41[2.] Full description of the problem/report: 41[2.] Full description of the problem/report:
42[3.] Keywords (i.e., modules, networking, kernel): 42[3.] Keywords (i.e., modules, networking, kernel):
43[4.] Kernel version (from /proc/version): 43[4.] Kernel information
44[4.1.] Kernel version (from /proc/version):
45[4.2.] Kernel .config file:
44[5.] Most recent kernel version which did not have the bug: 46[5.] Most recent kernel version which did not have the bug:
45[6.] Output of Oops.. message (if applicable) with symbolic information 47[6.] Output of Oops.. message (if applicable) with symbolic information
46 resolved (see Documentation/oops-tracing.txt) 48 resolved (see Documentation/oops-tracing.txt)
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c
index ffb7d5423cc0..3c10b9a1ddf5 100644
--- a/arch/alpha/kernel/pci.c
+++ b/arch/alpha/kernel/pci.c
@@ -516,10 +516,11 @@ sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn)
516 if (bus == 0 && dfn == 0) { 516 if (bus == 0 && dfn == 0) {
517 hose = pci_isa_hose; 517 hose = pci_isa_hose;
518 } else { 518 } else {
519 dev = pci_find_slot(bus, dfn); 519 dev = pci_get_bus_and_slot(bus, dfn);
520 if (!dev) 520 if (!dev)
521 return -ENODEV; 521 return -ENODEV;
522 hose = dev->sysdata; 522 hose = dev->sysdata;
523 pci_dev_put(dev);
523 } 524 }
524 } 525 }
525 526
diff --git a/arch/alpha/kernel/sys_miata.c b/arch/alpha/kernel/sys_miata.c
index b8b817feb1ee..910b43cd63e8 100644
--- a/arch/alpha/kernel/sys_miata.c
+++ b/arch/alpha/kernel/sys_miata.c
@@ -183,11 +183,15 @@ miata_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
183 183
184 if((slot == 7) && (PCI_FUNC(dev->devfn) == 3)) { 184 if((slot == 7) && (PCI_FUNC(dev->devfn) == 3)) {
185 u8 irq=0; 185 u8 irq=0;
186 186 struct pci_dev *pdev = pci_get_slot(dev->bus, dev->devfn & ~7);
187 if(pci_read_config_byte(pci_find_slot(dev->bus->number, dev->devfn & ~(7)), 0x40,&irq)!=PCIBIOS_SUCCESSFUL) 187 if(pdev == NULL || pci_read_config_byte(pdev, 0x40,&irq) != PCIBIOS_SUCCESSFUL) {
188 pci_dev_put(pdev);
188 return -1; 189 return -1;
189 else 190 }
191 else {
192 pci_dev_put(pdev);
190 return irq; 193 return irq;
194 }
191 } 195 }
192 196
193 return COMMON_TABLE_LOOKUP; 197 return COMMON_TABLE_LOOKUP;
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c
index 93744bab73fb..e7594a7cf585 100644
--- a/arch/alpha/kernel/sys_nautilus.c
+++ b/arch/alpha/kernel/sys_nautilus.c
@@ -200,7 +200,7 @@ nautilus_init_pci(void)
200 bus = pci_scan_bus(0, alpha_mv.pci_ops, hose); 200 bus = pci_scan_bus(0, alpha_mv.pci_ops, hose);
201 hose->bus = bus; 201 hose->bus = bus;
202 202
203 irongate = pci_find_slot(0, 0); 203 irongate = pci_get_bus_and_slot(0, 0);
204 bus->self = irongate; 204 bus->self = irongate;
205 bus->resource[1] = &irongate_mem; 205 bus->resource[1] = &irongate_mem;
206 206
diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
index 8871529a34e2..8aa9db834c11 100644
--- a/arch/alpha/mm/fault.c
+++ b/arch/alpha/mm/fault.c
@@ -108,7 +108,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
108 108
109 /* If we're in an interrupt context, or have no user context, 109 /* If we're in an interrupt context, or have no user context,
110 we must not take the fault. */ 110 we must not take the fault. */
111 if (!mm || in_interrupt()) 111 if (!mm || in_atomic())
112 goto no_context; 112 goto no_context;
113 113
114#ifdef CONFIG_ALPHA_LARGE_VMALLOC 114#ifdef CONFIG_ALPHA_LARGE_VMALLOC
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index 48cf7fffddf2..f38a60a03b8c 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -11,6 +11,7 @@
11#include <linux/signal.h> 11#include <linux/signal.h>
12#include <linux/ptrace.h> 12#include <linux/ptrace.h>
13#include <linux/personality.h> 13#include <linux/personality.h>
14#include <linux/freezer.h>
14 15
15#include <asm/cacheflush.h> 16#include <asm/cacheflush.h>
16#include <asm/ucontext.h> 17#include <asm/ucontext.h>
diff --git a/arch/arm/mach-omap1/devices.c b/arch/arm/mach-omap1/devices.c
index a611c3b63954..6dcd10ab4496 100644
--- a/arch/arm/mach-omap1/devices.c
+++ b/arch/arm/mach-omap1/devices.c
@@ -55,7 +55,7 @@ static inline void omap_init_irda(void) {}
55 55
56/*-------------------------------------------------------------------------*/ 56/*-------------------------------------------------------------------------*/
57 57
58#if defined(CONFIG_OMAP_RTC) || defined(CONFIG_OMAP_RTC) 58#if defined(CONFIG_RTC_DRV_OMAP) || defined(CONFIG_RTC_DRV_OMAP_MODULE)
59 59
60#define OMAP_RTC_BASE 0xfffb4800 60#define OMAP_RTC_BASE 0xfffb4800
61 61
diff --git a/arch/arm/mach-s3c2410/dma.c b/arch/arm/mach-s3c2410/dma.c
index 3d211dc2f2f9..01abb0ace234 100644
--- a/arch/arm/mach-s3c2410/dma.c
+++ b/arch/arm/mach-s3c2410/dma.c
@@ -40,7 +40,7 @@
40 40
41/* io map for dma */ 41/* io map for dma */
42static void __iomem *dma_base; 42static void __iomem *dma_base;
43static kmem_cache_t *dma_kmem; 43static struct kmem_cache *dma_kmem;
44 44
45struct s3c24xx_dma_selection dma_sel; 45struct s3c24xx_dma_selection dma_sel;
46 46
@@ -1271,7 +1271,7 @@ struct sysdev_class dma_sysclass = {
1271 1271
1272/* kmem cache implementation */ 1272/* kmem cache implementation */
1273 1273
1274static void s3c2410_dma_cache_ctor(void *p, kmem_cache_t *c, unsigned long f) 1274static void s3c2410_dma_cache_ctor(void *p, struct kmem_cache *c, unsigned long f)
1275{ 1275{
1276 memset(p, 0, sizeof(struct s3c2410_dma_buf)); 1276 memset(p, 0, sizeof(struct s3c2410_dma_buf));
1277} 1277}
diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
index 5e658a874498..9fd6d2eafb40 100644
--- a/arch/arm/mm/fault.c
+++ b/arch/arm/mm/fault.c
@@ -230,7 +230,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
230 * If we're in an interrupt or have no user 230 * If we're in an interrupt or have no user
231 * context, we must not take the fault.. 231 * context, we must not take the fault..
232 */ 232 */
233 if (in_interrupt() || !mm) 233 if (in_atomic() || !mm)
234 goto no_context; 234 goto no_context;
235 235
236 /* 236 /*
diff --git a/arch/arm26/kernel/ecard.c b/arch/arm26/kernel/ecard.c
index 047d0a408b9d..43dd41be71fb 100644
--- a/arch/arm26/kernel/ecard.c
+++ b/arch/arm26/kernel/ecard.c
@@ -620,12 +620,10 @@ ecard_probe(int slot, card_type_t type)
620 struct ex_ecid cid; 620 struct ex_ecid cid;
621 int i, rc = -ENOMEM; 621 int i, rc = -ENOMEM;
622 622
623 ec = kmalloc(sizeof(ecard_t), GFP_KERNEL); 623 ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
624 if (!ec) 624 if (!ec)
625 goto nomem; 625 goto nomem;
626 626
627 memset(ec, 0, sizeof(ecard_t));
628
629 ec->slot_no = slot; 627 ec->slot_no = slot;
630 ec->type = type; 628 ec->type = type;
631 ec->irq = NO_IRQ; 629 ec->irq = NO_IRQ;
diff --git a/arch/arm26/mm/fault.c b/arch/arm26/mm/fault.c
index a1f6d8a9cc32..93c0cee0fb5e 100644
--- a/arch/arm26/mm/fault.c
+++ b/arch/arm26/mm/fault.c
@@ -215,7 +215,7 @@ int do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
215 * If we're in an interrupt or have no user 215 * If we're in an interrupt or have no user
216 * context, we must not take the fault.. 216 * context, we must not take the fault..
217 */ 217 */
218 if (in_interrupt() || !mm) 218 if (in_atomic() || !mm)
219 goto no_context; 219 goto no_context;
220 220
221 down_read(&mm->mmap_sem); 221 down_read(&mm->mmap_sem);
diff --git a/arch/arm26/mm/memc.c b/arch/arm26/mm/memc.c
index 34def6397c3c..f2901581d4da 100644
--- a/arch/arm26/mm/memc.c
+++ b/arch/arm26/mm/memc.c
@@ -24,7 +24,7 @@
24 24
25#define MEMC_TABLE_SIZE (256*sizeof(unsigned long)) 25#define MEMC_TABLE_SIZE (256*sizeof(unsigned long))
26 26
27kmem_cache_t *pte_cache, *pgd_cache; 27struct kmem_cache *pte_cache, *pgd_cache;
28int page_nr; 28int page_nr;
29 29
30/* 30/*
@@ -162,12 +162,12 @@ void __init create_memmap_holes(struct meminfo *mi)
162{ 162{
163} 163}
164 164
165static void pte_cache_ctor(void *pte, kmem_cache_t *cache, unsigned long flags) 165static void pte_cache_ctor(void *pte, struct kmem_cache *cache, unsigned long flags)
166{ 166{
167 memzero(pte, sizeof(pte_t) * PTRS_PER_PTE); 167 memzero(pte, sizeof(pte_t) * PTRS_PER_PTE);
168} 168}
169 169
170static void pgd_cache_ctor(void *pgd, kmem_cache_t *cache, unsigned long flags) 170static void pgd_cache_ctor(void *pgd, struct kmem_cache *cache, unsigned long flags)
171{ 171{
172 memzero(pgd + MEMC_TABLE_SIZE, USER_PTRS_PER_PGD * sizeof(pgd_t)); 172 memzero(pgd + MEMC_TABLE_SIZE, USER_PTRS_PER_PGD * sizeof(pgd_t));
173} 173}
diff --git a/arch/avr32/kernel/kprobes.c b/arch/avr32/kernel/kprobes.c
index ca41fc1edbe1..d0abbcaf1c1e 100644
--- a/arch/avr32/kernel/kprobes.c
+++ b/arch/avr32/kernel/kprobes.c
@@ -154,6 +154,7 @@ ss_probe:
154 return 1; 154 return 1;
155 155
156no_kprobe: 156no_kprobe:
157 preempt_enable_no_resched();
157 return ret; 158 return ret;
158} 159}
159 160
diff --git a/arch/avr32/kernel/signal.c b/arch/avr32/kernel/signal.c
index 33096651c24f..0ec14854a200 100644
--- a/arch/avr32/kernel/signal.c
+++ b/arch/avr32/kernel/signal.c
@@ -15,7 +15,7 @@
15#include <linux/errno.h> 15#include <linux/errno.h>
16#include <linux/ptrace.h> 16#include <linux/ptrace.h>
17#include <linux/unistd.h> 17#include <linux/unistd.h>
18#include <linux/suspend.h> 18#include <linux/freezer.h>
19 19
20#include <asm/uaccess.h> 20#include <asm/uaccess.h>
21#include <asm/ucontext.h> 21#include <asm/ucontext.h>
diff --git a/arch/avr32/mm/dma-coherent.c b/arch/avr32/mm/dma-coherent.c
index 44ab8a7bdae2..b68d669f823d 100644
--- a/arch/avr32/mm/dma-coherent.c
+++ b/arch/avr32/mm/dma-coherent.c
@@ -11,7 +11,7 @@
11#include <asm/addrspace.h> 11#include <asm/addrspace.h>
12#include <asm/cacheflush.h> 12#include <asm/cacheflush.h>
13 13
14void dma_cache_sync(void *vaddr, size_t size, int direction) 14void dma_cache_sync(struct device *dev, void *vaddr, size_t size, int direction)
15{ 15{
16 /* 16 /*
17 * No need to sync an uncached area 17 * No need to sync an uncached area
diff --git a/arch/cris/mm/fault.c b/arch/cris/mm/fault.c
index 934c51078cce..c73e91f1299a 100644
--- a/arch/cris/mm/fault.c
+++ b/arch/cris/mm/fault.c
@@ -232,7 +232,7 @@ do_page_fault(unsigned long address, struct pt_regs *regs,
232 * context, we must not take the fault.. 232 * context, we must not take the fault..
233 */ 233 */
234 234
235 if (in_interrupt() || !mm) 235 if (in_atomic() || !mm)
236 goto no_context; 236 goto no_context;
237 237
238 down_read(&mm->mmap_sem); 238 down_read(&mm->mmap_sem);
diff --git a/arch/frv/kernel/futex.c b/arch/frv/kernel/futex.c
index eae874a970c6..14f64b054c7e 100644
--- a/arch/frv/kernel/futex.c
+++ b/arch/frv/kernel/futex.c
@@ -10,9 +10,9 @@
10 */ 10 */
11 11
12#include <linux/futex.h> 12#include <linux/futex.h>
13#include <linux/uaccess.h>
13#include <asm/futex.h> 14#include <asm/futex.h>
14#include <asm/errno.h> 15#include <asm/errno.h>
15#include <asm/uaccess.h>
16 16
17/* 17/*
18 * the various futex operations; MMU fault checking is ignored under no-MMU 18 * the various futex operations; MMU fault checking is ignored under no-MMU
@@ -200,7 +200,7 @@ int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
200 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) 200 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
201 return -EFAULT; 201 return -EFAULT;
202 202
203 inc_preempt_count(); 203 pagefault_disable();
204 204
205 switch (op) { 205 switch (op) {
206 case FUTEX_OP_SET: 206 case FUTEX_OP_SET:
@@ -223,7 +223,7 @@ int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
223 break; 223 break;
224 } 224 }
225 225
226 dec_preempt_count(); 226 pagefault_enable();
227 227
228 if (!ret) { 228 if (!ret) {
229 switch (cmp) { 229 switch (cmp) {
diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c
index a8c61dac1cee..1a5eb6c301c9 100644
--- a/arch/frv/kernel/setup.c
+++ b/arch/frv/kernel/setup.c
@@ -947,7 +947,7 @@ static void __init setup_linux_memory(void)
947 if (LOADER_TYPE && INITRD_START) { 947 if (LOADER_TYPE && INITRD_START) {
948 if (INITRD_START + INITRD_SIZE <= (low_top_pfn << PAGE_SHIFT)) { 948 if (INITRD_START + INITRD_SIZE <= (low_top_pfn << PAGE_SHIFT)) {
949 reserve_bootmem(INITRD_START, INITRD_SIZE); 949 reserve_bootmem(INITRD_START, INITRD_SIZE);
950 initrd_start = INITRD_START ? INITRD_START + PAGE_OFFSET : 0; 950 initrd_start = INITRD_START + PAGE_OFFSET;
951 initrd_end = initrd_start + INITRD_SIZE; 951 initrd_end = initrd_start + INITRD_SIZE;
952 } 952 }
953 else { 953 else {
diff --git a/arch/frv/kernel/signal.c b/arch/frv/kernel/signal.c
index b8a5882b8625..85baeae9666a 100644
--- a/arch/frv/kernel/signal.c
+++ b/arch/frv/kernel/signal.c
@@ -21,7 +21,7 @@
21#include <linux/ptrace.h> 21#include <linux/ptrace.h>
22#include <linux/unistd.h> 22#include <linux/unistd.h>
23#include <linux/personality.h> 23#include <linux/personality.h>
24#include <linux/suspend.h> 24#include <linux/freezer.h>
25#include <asm/ucontext.h> 25#include <asm/ucontext.h>
26#include <asm/uaccess.h> 26#include <asm/uaccess.h>
27#include <asm/cacheflush.h> 27#include <asm/cacheflush.h>
diff --git a/arch/frv/mm/fault.c b/arch/frv/mm/fault.c
index 8b3eb50c5105..3f12296c3688 100644
--- a/arch/frv/mm/fault.c
+++ b/arch/frv/mm/fault.c
@@ -78,7 +78,7 @@ asmlinkage void do_page_fault(int datammu, unsigned long esr0, unsigned long ear
78 * If we're in an interrupt or have no user 78 * If we're in an interrupt or have no user
79 * context, we must not take the fault.. 79 * context, we must not take the fault..
80 */ 80 */
81 if (in_interrupt() || !mm) 81 if (in_atomic() || !mm)
82 goto no_context; 82 goto no_context;
83 83
84 down_read(&mm->mmap_sem); 84 down_read(&mm->mmap_sem);
diff --git a/arch/frv/mm/pgalloc.c b/arch/frv/mm/pgalloc.c
index f76dd03ddd99..19b13be114a2 100644
--- a/arch/frv/mm/pgalloc.c
+++ b/arch/frv/mm/pgalloc.c
@@ -18,7 +18,7 @@
18#include <asm/cacheflush.h> 18#include <asm/cacheflush.h>
19 19
20pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((aligned(PAGE_SIZE))); 20pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__((aligned(PAGE_SIZE)));
21kmem_cache_t *pgd_cache; 21struct kmem_cache *pgd_cache;
22 22
23pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 23pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
24{ 24{
@@ -100,7 +100,7 @@ static inline void pgd_list_del(pgd_t *pgd)
100 set_page_private(next, (unsigned long) pprev); 100 set_page_private(next, (unsigned long) pprev);
101} 101}
102 102
103void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused) 103void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused)
104{ 104{
105 unsigned long flags; 105 unsigned long flags;
106 106
@@ -120,7 +120,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
120} 120}
121 121
122/* never called when PTRS_PER_PMD > 1 */ 122/* never called when PTRS_PER_PMD > 1 */
123void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused) 123void pgd_dtor(void *pgd, struct kmem_cache *cache, unsigned long unused)
124{ 124{
125 unsigned long flags; /* can be called from interrupt context */ 125 unsigned long flags; /* can be called from interrupt context */
126 126
diff --git a/arch/h8300/kernel/setup.c b/arch/h8300/kernel/setup.c
index 1077b71d5226..6adf8f41d2a1 100644
--- a/arch/h8300/kernel/setup.c
+++ b/arch/h8300/kernel/setup.c
@@ -116,7 +116,7 @@ void __init setup_arch(char **cmdline_p)
116#endif 116#endif
117#else 117#else
118 if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) && 118 if ((memory_end < CONFIG_BLKDEV_RESERVE_ADDRESS) &&
119 (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS) 119 (memory_end > CONFIG_BLKDEV_RESERVE_ADDRESS))
120 /* overlap userarea */ 120 /* overlap userarea */
121 memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS; 121 memory_end = CONFIG_BLKDEV_RESERVE_ADDRESS;
122#endif 122#endif
diff --git a/arch/h8300/kernel/signal.c b/arch/h8300/kernel/signal.c
index 7787f70a05bb..02955604d760 100644
--- a/arch/h8300/kernel/signal.c
+++ b/arch/h8300/kernel/signal.c
@@ -38,7 +38,7 @@
38#include <linux/personality.h> 38#include <linux/personality.h>
39#include <linux/tty.h> 39#include <linux/tty.h>
40#include <linux/binfmts.h> 40#include <linux/binfmts.h>
41#include <linux/suspend.h> 41#include <linux/freezer.h>
42 42
43#include <asm/setup.h> 43#include <asm/setup.h>
44#include <asm/uaccess.h> 44#include <asm/uaccess.h>
diff --git a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S
index 756325dd480e..f05288be8878 100644
--- a/arch/h8300/kernel/vmlinux.lds.S
+++ b/arch/h8300/kernel/vmlinux.lds.S
@@ -70,6 +70,7 @@ SECTIONS
70#endif 70#endif
71 .text : 71 .text :
72 { 72 {
73 _text = .;
73#if defined(CONFIG_ROMKERNEL) 74#if defined(CONFIG_ROMKERNEL)
74 *(.int_redirect) 75 *(.int_redirect)
75#endif 76#endif
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 8ff1c6fb5aa1..ea70359b02d0 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -182,6 +182,17 @@ config X86_ES7000
182 182
183endchoice 183endchoice
184 184
185config PARAVIRT
186 bool "Paravirtualization support (EXPERIMENTAL)"
187 depends on EXPERIMENTAL
188 help
189 Paravirtualization is a way of running multiple instances of
190 Linux on the same machine, under a hypervisor. This option
191 changes the kernel so it can modify itself when it is run
192 under a hypervisor, improving performance significantly.
193 However, when run without a hypervisor the kernel is
194 theoretically slower. If in doubt, say N.
195
185config ACPI_SRAT 196config ACPI_SRAT
186 bool 197 bool
187 default y 198 default y
@@ -443,7 +454,8 @@ source "drivers/firmware/Kconfig"
443 454
444choice 455choice
445 prompt "High Memory Support" 456 prompt "High Memory Support"
446 default NOHIGHMEM 457 default HIGHMEM4G if !X86_NUMAQ
458 default HIGHMEM64G if X86_NUMAQ
447 459
448config NOHIGHMEM 460config NOHIGHMEM
449 bool "off" 461 bool "off"
@@ -710,20 +722,6 @@ config BOOT_IOREMAP
710 depends on (((X86_SUMMIT || X86_GENERICARCH) && NUMA) || (X86 && EFI)) 722 depends on (((X86_SUMMIT || X86_GENERICARCH) && NUMA) || (X86 && EFI))
711 default y 723 default y
712 724
713config REGPARM
714 bool "Use register arguments"
715 default y
716 help
717 Compile the kernel with -mregparm=3. This instructs gcc to use
718 a more efficient function call ABI which passes the first three
719 arguments of a function call via registers, which results in denser
720 and faster code.
721
722 If this option is disabled, then the default ABI of passing
723 arguments via the stack is used.
724
725 If unsure, say Y.
726
727config SECCOMP 725config SECCOMP
728 bool "Enable seccomp to safely compute untrusted bytecode" 726 bool "Enable seccomp to safely compute untrusted bytecode"
729 depends on PROC_FS 727 depends on PROC_FS
@@ -773,23 +771,39 @@ config CRASH_DUMP
773 PHYSICAL_START. 771 PHYSICAL_START.
774 For more details see Documentation/kdump/kdump.txt 772 For more details see Documentation/kdump/kdump.txt
775 773
776config PHYSICAL_START 774config RELOCATABLE
777 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) 775 bool "Build a relocatable kernel(EXPERIMENTAL)"
776 depends on EXPERIMENTAL
777 help
778 This build a kernel image that retains relocation information
779 so it can be loaded someplace besides the default 1MB.
780 The relocations tend to the kernel binary about 10% larger,
781 but are discarded at runtime.
782
783 One use is for the kexec on panic case where the recovery kernel
784 must live at a different physical address than the primary
785 kernel.
778 786
779 default "0x1000000" if CRASH_DUMP 787config PHYSICAL_ALIGN
788 hex "Alignment value to which kernel should be aligned"
780 default "0x100000" 789 default "0x100000"
790 range 0x2000 0x400000
781 help 791 help
782 This gives the physical address where the kernel is loaded. Normally 792 This value puts the alignment restrictions on physical address
783 for regular kernels this value is 0x100000 (1MB). But in the case 793 where kernel is loaded and run from. Kernel is compiled for an
784 of kexec on panic the fail safe kernel needs to run at a different 794 address which meets above alignment restriction.
785 address than the panic-ed kernel. This option is used to set the load 795
786 address for kernels used to capture crash dump on being kexec'ed 796 If bootloader loads the kernel at a non-aligned address and
787 after panic. The default value for crash dump kernels is 797 CONFIG_RELOCATABLE is set, kernel will move itself to nearest
788 0x1000000 (16MB). This can also be set based on the "X" value as 798 address aligned to above value and run from there.
789 specified in the "crashkernel=YM@XM" command line boot parameter 799
790 passed to the panic-ed kernel. Typically this parameter is set as 800 If bootloader loads the kernel at a non-aligned address and
791 crashkernel=64M@16M. Please take a look at 801 CONFIG_RELOCATABLE is not set, kernel will ignore the run time
792 Documentation/kdump/kdump.txt for more details about crash dumps. 802 load address and decompress itself to the address it has been
803 compiled for and run from there. The address for which kernel is
804 compiled already meets above alignment restrictions. Hence the
805 end result is that kernel runs from a physical address meeting
806 above alignment restrictions.
793 807
794 Don't change this unless you know what you are doing. 808 Don't change this unless you know what you are doing.
795 809
diff --git a/arch/i386/Kconfig.cpu b/arch/i386/Kconfig.cpu
index fc4f2abccf06..821fd269ca58 100644
--- a/arch/i386/Kconfig.cpu
+++ b/arch/i386/Kconfig.cpu
@@ -103,8 +103,15 @@ config MPENTIUMM
103 Select this for Intel Pentium M (not Pentium-4 M) 103 Select this for Intel Pentium M (not Pentium-4 M)
104 notebook chips. 104 notebook chips.
105 105
106config MCORE2
107 bool "Core 2/newer Xeon"
108 help
109 Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and 53xx)
110 CPUs. You can distingush newer from older Xeons by the CPU family
111 in /proc/cpuinfo. Newer ones have 6.
112
106config MPENTIUM4 113config MPENTIUM4
107 bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/Xeon" 114 bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon"
108 help 115 help
109 Select this for Intel Pentium 4 chips. This includes the 116 Select this for Intel Pentium 4 chips. This includes the
110 Pentium 4, P4-based Celeron and Xeon, and Pentium-4 M 117 Pentium 4, P4-based Celeron and Xeon, and Pentium-4 M
@@ -229,7 +236,7 @@ config X86_L1_CACHE_SHIFT
229 default "7" if MPENTIUM4 || X86_GENERIC 236 default "7" if MPENTIUM4 || X86_GENERIC
230 default "4" if X86_ELAN || M486 || M386 || MGEODEGX1 237 default "4" if X86_ELAN || M486 || M386 || MGEODEGX1
231 default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX 238 default "5" if MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX
232 default "6" if MK7 || MK8 || MPENTIUMM 239 default "6" if MK7 || MK8 || MPENTIUMM || MCORE2
233 240
234config RWSEM_GENERIC_SPINLOCK 241config RWSEM_GENERIC_SPINLOCK
235 bool 242 bool
@@ -287,17 +294,17 @@ config X86_ALIGNMENT_16
287 294
288config X86_GOOD_APIC 295config X86_GOOD_APIC
289 bool 296 bool
290 depends on MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8 || MEFFICEON 297 depends on MK7 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || MK8 || MEFFICEON || MCORE2
291 default y 298 default y
292 299
293config X86_INTEL_USERCOPY 300config X86_INTEL_USERCOPY
294 bool 301 bool
295 depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON 302 depends on MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M586MMX || X86_GENERIC || MK8 || MK7 || MEFFICEON || MCORE2
296 default y 303 default y
297 304
298config X86_USE_PPRO_CHECKSUM 305config X86_USE_PPRO_CHECKSUM
299 bool 306 bool
300 depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MEFFICEON || MGEODE_LX 307 depends on MWINCHIP3D || MWINCHIP2 || MWINCHIPC6 || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC3_2 || MEFFICEON || MGEODE_LX || MCORE2
301 default y 308 default y
302 309
303config X86_USE_3DNOW 310config X86_USE_3DNOW
@@ -312,5 +319,5 @@ config X86_OOSTORE
312 319
313config X86_TSC 320config X86_TSC
314 bool 321 bool
315 depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1 || MGEODE_LX) && !X86_NUMAQ 322 depends on (MWINCHIP3D || MWINCHIP2 || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MGEODEGX1 || MGEODE_LX || MCORE2) && !X86_NUMAQ
316 default y 323 default y
diff --git a/arch/i386/Kconfig.debug b/arch/i386/Kconfig.debug
index b31c0802e1cc..f68cc6f215f8 100644
--- a/arch/i386/Kconfig.debug
+++ b/arch/i386/Kconfig.debug
@@ -85,4 +85,14 @@ config DOUBLEFAULT
85 option saves about 4k and might cause you much additional grey 85 option saves about 4k and might cause you much additional grey
86 hair. 86 hair.
87 87
88config DEBUG_PARAVIRT
89 bool "Enable some paravirtualization debugging"
90 default y
91 depends on PARAVIRT && DEBUG_KERNEL
92 help
93 Currently deliberately clobbers regs which are allowed to be
94 clobbered in inlined paravirt hooks, even in native mode.
95 If turning this off solves a problem, then DISABLE_INTERRUPTS() or
96 ENABLE_INTERRUPTS() is lying about what registers can be clobbered.
97
88endmenu 98endmenu
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 0677908dfa06..f7ac1aea1d8a 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -26,10 +26,12 @@ endif
26 26
27LDFLAGS := -m elf_i386 27LDFLAGS := -m elf_i386
28OBJCOPYFLAGS := -O binary -R .note -R .comment -S 28OBJCOPYFLAGS := -O binary -R .note -R .comment -S
29LDFLAGS_vmlinux := 29ifdef CONFIG_RELOCATABLE
30LDFLAGS_vmlinux := --emit-relocs
31endif
30CHECKFLAGS += -D__i386__ 32CHECKFLAGS += -D__i386__
31 33
32CFLAGS += -pipe -msoft-float 34CFLAGS += -pipe -msoft-float -mregparm=3
33 35
34# prevent gcc from keeping the stack 16 byte aligned 36# prevent gcc from keeping the stack 16 byte aligned
35CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2) 37CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
@@ -37,8 +39,6 @@ CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
37# CPU-specific tuning. Anything which can be shared with UML should go here. 39# CPU-specific tuning. Anything which can be shared with UML should go here.
38include $(srctree)/arch/i386/Makefile.cpu 40include $(srctree)/arch/i386/Makefile.cpu
39 41
40cflags-$(CONFIG_REGPARM) += -mregparm=3
41
42# temporary until string.h is fixed 42# temporary until string.h is fixed
43cflags-y += -ffreestanding 43cflags-y += -ffreestanding
44 44
diff --git a/arch/i386/Makefile.cpu b/arch/i386/Makefile.cpu
index a11befba26d5..a32c031c90d7 100644
--- a/arch/i386/Makefile.cpu
+++ b/arch/i386/Makefile.cpu
@@ -32,6 +32,7 @@ cflags-$(CONFIG_MWINCHIP2) += $(call cc-option,-march=winchip2,-march=i586)
32cflags-$(CONFIG_MWINCHIP3D) += $(call cc-option,-march=winchip2,-march=i586) 32cflags-$(CONFIG_MWINCHIP3D) += $(call cc-option,-march=winchip2,-march=i586)
33cflags-$(CONFIG_MCYRIXIII) += $(call cc-option,-march=c3,-march=i486) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0 33cflags-$(CONFIG_MCYRIXIII) += $(call cc-option,-march=c3,-march=i486) $(align)-functions=0 $(align)-jumps=0 $(align)-loops=0
34cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686) 34cflags-$(CONFIG_MVIAC3_2) += $(call cc-option,-march=c3-2,-march=i686)
35cflags-$(CONFIG_MCORE2) += -march=i686 $(call cc-option,-mtune=core2,$(call cc-option,-mtune=generic,-mtune=i686))
35 36
36# AMD Elan support 37# AMD Elan support
37cflags-$(CONFIG_X86_ELAN) += -march=i486 38cflags-$(CONFIG_X86_ELAN) += -march=i486
diff --git a/arch/i386/boot/compressed/Makefile b/arch/i386/boot/compressed/Makefile
index 258ea95224f6..a661217f33ec 100644
--- a/arch/i386/boot/compressed/Makefile
+++ b/arch/i386/boot/compressed/Makefile
@@ -4,22 +4,42 @@
4# create a compressed vmlinux image from the original vmlinux 4# create a compressed vmlinux image from the original vmlinux
5# 5#
6 6
7targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o 7targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o \
8 vmlinux.bin.all vmlinux.relocs
8EXTRA_AFLAGS := -traditional 9EXTRA_AFLAGS := -traditional
9 10
10LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32 11LDFLAGS_vmlinux := -T
12CFLAGS_misc.o += -fPIC
13hostprogs-y := relocs
11 14
12$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE 15$(obj)/vmlinux: $(src)/vmlinux.lds $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE
13 $(call if_changed,ld) 16 $(call if_changed,ld)
14 @: 17 @:
15 18
16$(obj)/vmlinux.bin: vmlinux FORCE 19$(obj)/vmlinux.bin: vmlinux FORCE
17 $(call if_changed,objcopy) 20 $(call if_changed,objcopy)
18 21
22quiet_cmd_relocs = RELOCS $@
23 cmd_relocs = $(obj)/relocs $< > $@;$(obj)/relocs --abs-relocs $<
24$(obj)/vmlinux.relocs: vmlinux $(obj)/relocs FORCE
25 $(call if_changed,relocs)
26
27vmlinux.bin.all-y := $(obj)/vmlinux.bin
28vmlinux.bin.all-$(CONFIG_RELOCATABLE) += $(obj)/vmlinux.relocs
29quiet_cmd_relocbin = BUILD $@
30 cmd_relocbin = cat $(filter-out FORCE,$^) > $@
31$(obj)/vmlinux.bin.all: $(vmlinux.bin.all-y) FORCE
32 $(call if_changed,relocbin)
33
34ifdef CONFIG_RELOCATABLE
35$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin.all FORCE
36 $(call if_changed,gzip)
37else
19$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE 38$(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE
20 $(call if_changed,gzip) 39 $(call if_changed,gzip)
40endif
21 41
22LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T 42LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T
23 43
24$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE 44$(obj)/piggy.o: $(src)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE
25 $(call if_changed,ld) 45 $(call if_changed,ld)
diff --git a/arch/i386/boot/compressed/head.S b/arch/i386/boot/compressed/head.S
index b5893e4ecd37..f395a4bb38bb 100644
--- a/arch/i386/boot/compressed/head.S
+++ b/arch/i386/boot/compressed/head.S
@@ -26,9 +26,11 @@
26#include <linux/linkage.h> 26#include <linux/linkage.h>
27#include <asm/segment.h> 27#include <asm/segment.h>
28#include <asm/page.h> 28#include <asm/page.h>
29#include <asm/boot.h>
29 30
31.section ".text.head"
30 .globl startup_32 32 .globl startup_32
31 33
32startup_32: 34startup_32:
33 cld 35 cld
34 cli 36 cli
@@ -37,93 +39,142 @@ startup_32:
37 movl %eax,%es 39 movl %eax,%es
38 movl %eax,%fs 40 movl %eax,%fs
39 movl %eax,%gs 41 movl %eax,%gs
42 movl %eax,%ss
40 43
41 lss stack_start,%esp 44/* Calculate the delta between where we were compiled to run
42 xorl %eax,%eax 45 * at and where we were actually loaded at. This can only be done
431: incl %eax # check that A20 really IS enabled 46 * with a short local call on x86. Nothing else will tell us what
44 movl %eax,0x000000 # loop forever if it isn't 47 * address we are running at. The reserved chunk of the real-mode
45 cmpl %eax,0x100000 48 * data at 0x34-0x3f are used as the stack for this calculation.
46 je 1b 49 * Only 4 bytes are needed.
50 */
51 leal 0x40(%esi), %esp
52 call 1f
531: popl %ebp
54 subl $1b, %ebp
55
56/* %ebp contains the address we are loaded at by the boot loader and %ebx
57 * contains the address where we should move the kernel image temporarily
58 * for safe in-place decompression.
59 */
60
61#ifdef CONFIG_RELOCATABLE
62 movl %ebp, %ebx
63 addl $(CONFIG_PHYSICAL_ALIGN - 1), %ebx
64 andl $(~(CONFIG_PHYSICAL_ALIGN - 1)), %ebx
65#else
66 movl $LOAD_PHYSICAL_ADDR, %ebx
67#endif
68
69 /* Replace the compressed data size with the uncompressed size */
70 subl input_len(%ebp), %ebx
71 movl output_len(%ebp), %eax
72 addl %eax, %ebx
73 /* Add 8 bytes for every 32K input block */
74 shrl $12, %eax
75 addl %eax, %ebx
76 /* Add 32K + 18 bytes of extra slack */
77 addl $(32768 + 18), %ebx
78 /* Align on a 4K boundary */
79 addl $4095, %ebx
80 andl $~4095, %ebx
81
82/* Copy the compressed kernel to the end of our buffer
83 * where decompression in place becomes safe.
84 */
85 pushl %esi
86 leal _end(%ebp), %esi
87 leal _end(%ebx), %edi
88 movl $(_end - startup_32), %ecx
89 std
90 rep
91 movsb
92 cld
93 popl %esi
94
95/* Compute the kernel start address.
96 */
97#ifdef CONFIG_RELOCATABLE
98 addl $(CONFIG_PHYSICAL_ALIGN - 1), %ebp
99 andl $(~(CONFIG_PHYSICAL_ALIGN - 1)), %ebp
100#else
101 movl $LOAD_PHYSICAL_ADDR, %ebp
102#endif
47 103
48/* 104/*
49 * Initialize eflags. Some BIOS's leave bits like NT set. This would 105 * Jump to the relocated address.
50 * confuse the debugger if this code is traced.
51 * XXX - best to initialize before switching to protected mode.
52 */ 106 */
53 pushl $0 107 leal relocated(%ebx), %eax
54 popfl 108 jmp *%eax
109.section ".text"
110relocated:
111
55/* 112/*
56 * Clear BSS 113 * Clear BSS
57 */ 114 */
58 xorl %eax,%eax 115 xorl %eax,%eax
59 movl $_edata,%edi 116 leal _edata(%ebx),%edi
60 movl $_end,%ecx 117 leal _end(%ebx), %ecx
61 subl %edi,%ecx 118 subl %edi,%ecx
62 cld 119 cld
63 rep 120 rep
64 stosb 121 stosb
122
123/*
124 * Setup the stack for the decompressor
125 */
126 leal stack_end(%ebx), %esp
127
65/* 128/*
66 * Do the decompression, and jump to the new kernel.. 129 * Do the decompression, and jump to the new kernel..
67 */ 130 */
68 subl $16,%esp # place for structure on the stack 131 movl output_len(%ebx), %eax
69 movl %esp,%eax 132 pushl %eax
133 pushl %ebp # output address
134 movl input_len(%ebx), %eax
135 pushl %eax # input_len
136 leal input_data(%ebx), %eax
137 pushl %eax # input_data
138 leal _end(%ebx), %eax
139 pushl %eax # end of the image as third argument
70 pushl %esi # real mode pointer as second arg 140 pushl %esi # real mode pointer as second arg
71 pushl %eax # address of structure as first arg
72 call decompress_kernel 141 call decompress_kernel
73 orl %eax,%eax 142 addl $20, %esp
74 jnz 3f 143 popl %ecx
75 popl %esi # discard address
76 popl %esi # real mode pointer
77 xorl %ebx,%ebx
78 ljmp $(__BOOT_CS), $__PHYSICAL_START
79 144
145#if CONFIG_RELOCATABLE
146/* Find the address of the relocations.
147 */
148 movl %ebp, %edi
149 addl %ecx, %edi
150
151/* Calculate the delta between where vmlinux was compiled to run
152 * and where it was actually loaded.
153 */
154 movl %ebp, %ebx
155 subl $LOAD_PHYSICAL_ADDR, %ebx
156 jz 2f /* Nothing to be done if loaded at compiled addr. */
80/* 157/*
81 * We come here, if we were loaded high. 158 * Process relocations.
82 * We need to move the move-in-place routine down to 0x1000
83 * and then start it with the buffer addresses in registers,
84 * which we got from the stack.
85 */ 159 */
863: 160
87 movl $move_routine_start,%esi 1611: subl $4, %edi
88 movl $0x1000,%edi 162 movl 0(%edi), %ecx
89 movl $move_routine_end,%ecx 163 testl %ecx, %ecx
90 subl %esi,%ecx 164 jz 2f
91 addl $3,%ecx 165 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
92 shrl $2,%ecx 166 jmp 1b
93 cld 1672:
94 rep 168#endif
95 movsl
96
97 popl %esi # discard the address
98 popl %ebx # real mode pointer
99 popl %esi # low_buffer_start
100 popl %ecx # lcount
101 popl %edx # high_buffer_start
102 popl %eax # hcount
103 movl $__PHYSICAL_START,%edi
104 cli # make sure we don't get interrupted
105 ljmp $(__BOOT_CS), $0x1000 # and jump to the move routine
106 169
107/* 170/*
108 * Routine (template) for moving the decompressed kernel in place, 171 * Jump to the decompressed kernel.
109 * if we were high loaded. This _must_ PIC-code !
110 */ 172 */
111move_routine_start:
112 movl %ecx,%ebp
113 shrl $2,%ecx
114 rep
115 movsl
116 movl %ebp,%ecx
117 andl $3,%ecx
118 rep
119 movsb
120 movl %edx,%esi
121 movl %eax,%ecx # NOTE: rep movsb won't move if %ecx == 0
122 addl $3,%ecx
123 shrl $2,%ecx
124 rep
125 movsl
126 movl %ebx,%esi # Restore setup pointer
127 xorl %ebx,%ebx 173 xorl %ebx,%ebx
128 ljmp $(__BOOT_CS), $__PHYSICAL_START 174 jmp *%ebp
129move_routine_end: 175
176.bss
177.balign 4
178stack:
179 .fill 4096, 1, 0
180stack_end:
diff --git a/arch/i386/boot/compressed/misc.c b/arch/i386/boot/compressed/misc.c
index b2ccd543410d..1ce7017fd627 100644
--- a/arch/i386/boot/compressed/misc.c
+++ b/arch/i386/boot/compressed/misc.c
@@ -9,11 +9,94 @@
9 * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996 9 * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996
10 */ 10 */
11 11
12#undef CONFIG_PARAVIRT
12#include <linux/linkage.h> 13#include <linux/linkage.h>
13#include <linux/vmalloc.h> 14#include <linux/vmalloc.h>
14#include <linux/screen_info.h> 15#include <linux/screen_info.h>
15#include <asm/io.h> 16#include <asm/io.h>
16#include <asm/page.h> 17#include <asm/page.h>
18#include <asm/boot.h>
19
20/* WARNING!!
21 * This code is compiled with -fPIC and it is relocated dynamically
22 * at run time, but no relocation processing is performed.
23 * This means that it is not safe to place pointers in static structures.
24 */
25
26/*
27 * Getting to provable safe in place decompression is hard.
28 * Worst case behaviours need to be analized.
29 * Background information:
30 *
31 * The file layout is:
32 * magic[2]
33 * method[1]
34 * flags[1]
35 * timestamp[4]
36 * extraflags[1]
37 * os[1]
38 * compressed data blocks[N]
39 * crc[4] orig_len[4]
40 *
41 * resulting in 18 bytes of non compressed data overhead.
42 *
43 * Files divided into blocks
44 * 1 bit (last block flag)
45 * 2 bits (block type)
46 *
47 * 1 block occurs every 32K -1 bytes or when there 50% compression has been achieved.
48 * The smallest block type encoding is always used.
49 *
50 * stored:
51 * 32 bits length in bytes.
52 *
53 * fixed:
54 * magic fixed tree.
55 * symbols.
56 *
57 * dynamic:
58 * dynamic tree encoding.
59 * symbols.
60 *
61 *
62 * The buffer for decompression in place is the length of the
63 * uncompressed data, plus a small amount extra to keep the algorithm safe.
64 * The compressed data is placed at the end of the buffer. The output
65 * pointer is placed at the start of the buffer and the input pointer
66 * is placed where the compressed data starts. Problems will occur
67 * when the output pointer overruns the input pointer.
68 *
69 * The output pointer can only overrun the input pointer if the input
70 * pointer is moving faster than the output pointer. A condition only
71 * triggered by data whose compressed form is larger than the uncompressed
72 * form.
73 *
74 * The worst case at the block level is a growth of the compressed data
75 * of 5 bytes per 32767 bytes.
76 *
77 * The worst case internal to a compressed block is very hard to figure.
78 * The worst case can at least be boundined by having one bit that represents
79 * 32764 bytes and then all of the rest of the bytes representing the very
80 * very last byte.
81 *
82 * All of which is enough to compute an amount of extra data that is required
83 * to be safe. To avoid problems at the block level allocating 5 extra bytes
84 * per 32767 bytes of data is sufficient. To avoind problems internal to a block
85 * adding an extra 32767 bytes (the worst case uncompressed block size) is
86 * sufficient, to ensure that in the worst case the decompressed data for
87 * block will stop the byte before the compressed data for a block begins.
88 * To avoid problems with the compressed data's meta information an extra 18
89 * bytes are needed. Leading to the formula:
90 *
91 * extra_bytes = (uncompressed_size >> 12) + 32768 + 18 + decompressor_size.
92 *
93 * Adding 8 bytes per 32K is a bit excessive but much easier to calculate.
94 * Adding 32768 instead of 32767 just makes for round numbers.
95 * Adding the decompressor_size is necessary as it musht live after all
96 * of the data as well. Last I measured the decompressor is about 14K.
97 * 10K of actuall data and 4K of bss.
98 *
99 */
17 100
18/* 101/*
19 * gzip declarations 102 * gzip declarations
@@ -30,15 +113,20 @@ typedef unsigned char uch;
30typedef unsigned short ush; 113typedef unsigned short ush;
31typedef unsigned long ulg; 114typedef unsigned long ulg;
32 115
33#define WSIZE 0x8000 /* Window size must be at least 32k, */ 116#define WSIZE 0x80000000 /* Window size must be at least 32k,
34 /* and a power of two */ 117 * and a power of two
118 * We don't actually have a window just
119 * a huge output buffer so I report
120 * a 2G windows size, as that should
121 * always be larger than our output buffer.
122 */
35 123
36static uch *inbuf; /* input buffer */ 124static uch *inbuf; /* input buffer */
37static uch window[WSIZE]; /* Sliding window buffer */ 125static uch *window; /* Sliding window buffer, (and final output buffer) */
38 126
39static unsigned insize = 0; /* valid bytes in inbuf */ 127static unsigned insize; /* valid bytes in inbuf */
40static unsigned inptr = 0; /* index of next byte to be processed in inbuf */ 128static unsigned inptr; /* index of next byte to be processed in inbuf */
41static unsigned outcnt = 0; /* bytes in output buffer */ 129static unsigned outcnt; /* bytes in output buffer */
42 130
43/* gzip flag byte */ 131/* gzip flag byte */
44#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */ 132#define ASCII_FLAG 0x01 /* bit 0 set: file probably ASCII text */
@@ -89,8 +177,6 @@ extern unsigned char input_data[];
89extern int input_len; 177extern int input_len;
90 178
91static long bytes_out = 0; 179static long bytes_out = 0;
92static uch *output_data;
93static unsigned long output_ptr = 0;
94 180
95static void *malloc(int size); 181static void *malloc(int size);
96static void free(void *where); 182static void free(void *where);
@@ -100,24 +186,17 @@ static void *memcpy(void *dest, const void *src, unsigned n);
100 186
101static void putstr(const char *); 187static void putstr(const char *);
102 188
103extern int end; 189static unsigned long free_mem_ptr;
104static long free_mem_ptr = (long)&end; 190static unsigned long free_mem_end_ptr;
105static long free_mem_end_ptr;
106 191
107#define INPLACE_MOVE_ROUTINE 0x1000
108#define LOW_BUFFER_START 0x2000
109#define LOW_BUFFER_MAX 0x90000
110#define HEAP_SIZE 0x3000 192#define HEAP_SIZE 0x3000
111static unsigned int low_buffer_end, low_buffer_size;
112static int high_loaded =0;
113static uch *high_buffer_start /* = (uch *)(((ulg)&end) + HEAP_SIZE)*/;
114 193
115static char *vidmem = (char *)0xb8000; 194static char *vidmem = (char *)0xb8000;
116static int vidport; 195static int vidport;
117static int lines, cols; 196static int lines, cols;
118 197
119#ifdef CONFIG_X86_NUMAQ 198#ifdef CONFIG_X86_NUMAQ
120static void * xquad_portio = NULL; 199void *xquad_portio;
121#endif 200#endif
122 201
123#include "../../../../lib/inflate.c" 202#include "../../../../lib/inflate.c"
@@ -151,7 +230,7 @@ static void gzip_mark(void **ptr)
151 230
152static void gzip_release(void **ptr) 231static void gzip_release(void **ptr)
153{ 232{
154 free_mem_ptr = (long) *ptr; 233 free_mem_ptr = (unsigned long) *ptr;
155} 234}
156 235
157static void scroll(void) 236static void scroll(void)
@@ -179,7 +258,7 @@ static void putstr(const char *s)
179 y--; 258 y--;
180 } 259 }
181 } else { 260 } else {
182 vidmem [ ( x + cols * y ) * 2 ] = c; 261 vidmem [ ( x + cols * y ) * 2 ] = c;
183 if ( ++x >= cols ) { 262 if ( ++x >= cols ) {
184 x = 0; 263 x = 0;
185 if ( ++y >= lines ) { 264 if ( ++y >= lines ) {
@@ -224,58 +303,31 @@ static void* memcpy(void* dest, const void* src, unsigned n)
224 */ 303 */
225static int fill_inbuf(void) 304static int fill_inbuf(void)
226{ 305{
227 if (insize != 0) { 306 error("ran out of input data");
228 error("ran out of input data"); 307 return 0;
229 }
230
231 inbuf = input_data;
232 insize = input_len;
233 inptr = 1;
234 return inbuf[0];
235} 308}
236 309
237/* =========================================================================== 310/* ===========================================================================
238 * Write the output window window[0..outcnt-1] and update crc and bytes_out. 311 * Write the output window window[0..outcnt-1] and update crc and bytes_out.
239 * (Used for the decompressed data only.) 312 * (Used for the decompressed data only.)
240 */ 313 */
241static void flush_window_low(void)
242{
243 ulg c = crc; /* temporary variable */
244 unsigned n;
245 uch *in, *out, ch;
246
247 in = window;
248 out = &output_data[output_ptr];
249 for (n = 0; n < outcnt; n++) {
250 ch = *out++ = *in++;
251 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
252 }
253 crc = c;
254 bytes_out += (ulg)outcnt;
255 output_ptr += (ulg)outcnt;
256 outcnt = 0;
257}
258
259static void flush_window_high(void)
260{
261 ulg c = crc; /* temporary variable */
262 unsigned n;
263 uch *in, ch;
264 in = window;
265 for (n = 0; n < outcnt; n++) {
266 ch = *output_data++ = *in++;
267 if ((ulg)output_data == low_buffer_end) output_data=high_buffer_start;
268 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
269 }
270 crc = c;
271 bytes_out += (ulg)outcnt;
272 outcnt = 0;
273}
274
275static void flush_window(void) 314static void flush_window(void)
276{ 315{
277 if (high_loaded) flush_window_high(); 316 /* With my window equal to my output buffer
278 else flush_window_low(); 317 * I only need to compute the crc here.
318 */
319 ulg c = crc; /* temporary variable */
320 unsigned n;
321 uch *in, ch;
322
323 in = window;
324 for (n = 0; n < outcnt; n++) {
325 ch = *in++;
326 c = crc_32_tab[((int)c ^ ch) & 0xff] ^ (c >> 8);
327 }
328 crc = c;
329 bytes_out += (ulg)outcnt;
330 outcnt = 0;
279} 331}
280 332
281static void error(char *x) 333static void error(char *x)
@@ -287,66 +339,8 @@ static void error(char *x)
287 while(1); /* Halt */ 339 while(1); /* Halt */
288} 340}
289 341
290#define STACK_SIZE (4096) 342asmlinkage void decompress_kernel(void *rmode, unsigned long end,
291 343 uch *input_data, unsigned long input_len, uch *output)
292long user_stack [STACK_SIZE];
293
294struct {
295 long * a;
296 short b;
297 } stack_start = { & user_stack [STACK_SIZE] , __BOOT_DS };
298
299static void setup_normal_output_buffer(void)
300{
301#ifdef STANDARD_MEMORY_BIOS_CALL
302 if (RM_EXT_MEM_K < 1024) error("Less than 2MB of memory");
303#else
304 if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < 1024) error("Less than 2MB of memory");
305#endif
306 output_data = (unsigned char *)__PHYSICAL_START; /* Normally Points to 1M */
307 free_mem_end_ptr = (long)real_mode;
308}
309
310struct moveparams {
311 uch *low_buffer_start; int lcount;
312 uch *high_buffer_start; int hcount;
313};
314
315static void setup_output_buffer_if_we_run_high(struct moveparams *mv)
316{
317 high_buffer_start = (uch *)(((ulg)&end) + HEAP_SIZE);
318#ifdef STANDARD_MEMORY_BIOS_CALL
319 if (RM_EXT_MEM_K < (3*1024)) error("Less than 4MB of memory");
320#else
321 if ((RM_ALT_MEM_K > RM_EXT_MEM_K ? RM_ALT_MEM_K : RM_EXT_MEM_K) < (3*1024)) error("Less than 4MB of memory");
322#endif
323 mv->low_buffer_start = output_data = (unsigned char *)LOW_BUFFER_START;
324 low_buffer_end = ((unsigned int)real_mode > LOW_BUFFER_MAX
325 ? LOW_BUFFER_MAX : (unsigned int)real_mode) & ~0xfff;
326 low_buffer_size = low_buffer_end - LOW_BUFFER_START;
327 high_loaded = 1;
328 free_mem_end_ptr = (long)high_buffer_start;
329 if ( (__PHYSICAL_START + low_buffer_size) > ((ulg)high_buffer_start)) {
330 high_buffer_start = (uch *)(__PHYSICAL_START + low_buffer_size);
331 mv->hcount = 0; /* say: we need not to move high_buffer */
332 }
333 else mv->hcount = -1;
334 mv->high_buffer_start = high_buffer_start;
335}
336
337static void close_output_buffer_if_we_run_high(struct moveparams *mv)
338{
339 if (bytes_out > low_buffer_size) {
340 mv->lcount = low_buffer_size;
341 if (mv->hcount)
342 mv->hcount = bytes_out - low_buffer_size;
343 } else {
344 mv->lcount = bytes_out;
345 mv->hcount = 0;
346 }
347}
348
349asmlinkage int decompress_kernel(struct moveparams *mv, void *rmode)
350{ 344{
351 real_mode = rmode; 345 real_mode = rmode;
352 346
@@ -361,13 +355,25 @@ asmlinkage int decompress_kernel(struct moveparams *mv, void *rmode)
361 lines = RM_SCREEN_INFO.orig_video_lines; 355 lines = RM_SCREEN_INFO.orig_video_lines;
362 cols = RM_SCREEN_INFO.orig_video_cols; 356 cols = RM_SCREEN_INFO.orig_video_cols;
363 357
364 if (free_mem_ptr < 0x100000) setup_normal_output_buffer(); 358 window = output; /* Output buffer (Normally at 1M) */
365 else setup_output_buffer_if_we_run_high(mv); 359 free_mem_ptr = end; /* Heap */
360 free_mem_end_ptr = end + HEAP_SIZE;
361 inbuf = input_data; /* Input buffer */
362 insize = input_len;
363 inptr = 0;
364
365 if ((u32)output & (CONFIG_PHYSICAL_ALIGN -1))
366 error("Destination address not CONFIG_PHYSICAL_ALIGN aligned");
367 if (end > ((-__PAGE_OFFSET-(512 <<20)-1) & 0x7fffffff))
368 error("Destination address too large");
369#ifndef CONFIG_RELOCATABLE
370 if ((u32)output != LOAD_PHYSICAL_ADDR)
371 error("Wrong destination address");
372#endif
366 373
367 makecrc(); 374 makecrc();
368 putstr("Uncompressing Linux... "); 375 putstr("Uncompressing Linux... ");
369 gunzip(); 376 gunzip();
370 putstr("Ok, booting the kernel.\n"); 377 putstr("Ok, booting the kernel.\n");
371 if (high_loaded) close_output_buffer_if_we_run_high(mv); 378 return;
372 return high_loaded;
373} 379}
diff --git a/arch/i386/boot/compressed/relocs.c b/arch/i386/boot/compressed/relocs.c
new file mode 100644
index 000000000000..468da89153c4
--- /dev/null
+++ b/arch/i386/boot/compressed/relocs.c
@@ -0,0 +1,625 @@
1#include <stdio.h>
2#include <stdarg.h>
3#include <stdlib.h>
4#include <stdint.h>
5#include <string.h>
6#include <errno.h>
7#include <unistd.h>
8#include <elf.h>
9#include <byteswap.h>
10#define USE_BSD
11#include <endian.h>
12
13#define MAX_SHDRS 100
14static Elf32_Ehdr ehdr;
15static Elf32_Shdr shdr[MAX_SHDRS];
16static Elf32_Sym *symtab[MAX_SHDRS];
17static Elf32_Rel *reltab[MAX_SHDRS];
18static char *strtab[MAX_SHDRS];
19static unsigned long reloc_count, reloc_idx;
20static unsigned long *relocs;
21
22/*
23 * Following symbols have been audited. There values are constant and do
24 * not change if bzImage is loaded at a different physical address than
25 * the address for which it has been compiled. Don't warn user about
26 * absolute relocations present w.r.t these symbols.
27 */
28static const char* safe_abs_relocs[] = {
29 "__kernel_vsyscall",
30 "__kernel_rt_sigreturn",
31 "__kernel_sigreturn",
32 "SYSENTER_RETURN",
33};
34
35static int is_safe_abs_reloc(const char* sym_name)
36{
37 int i, array_size;
38
39 array_size = sizeof(safe_abs_relocs)/sizeof(char*);
40
41 for(i = 0; i < array_size; i++) {
42 if (!strcmp(sym_name, safe_abs_relocs[i]))
43 /* Match found */
44 return 1;
45 }
46 return 0;
47}
48
49static void die(char *fmt, ...)
50{
51 va_list ap;
52 va_start(ap, fmt);
53 vfprintf(stderr, fmt, ap);
54 va_end(ap);
55 exit(1);
56}
57
58static const char *sym_type(unsigned type)
59{
60 static const char *type_name[] = {
61#define SYM_TYPE(X) [X] = #X
62 SYM_TYPE(STT_NOTYPE),
63 SYM_TYPE(STT_OBJECT),
64 SYM_TYPE(STT_FUNC),
65 SYM_TYPE(STT_SECTION),
66 SYM_TYPE(STT_FILE),
67 SYM_TYPE(STT_COMMON),
68 SYM_TYPE(STT_TLS),
69#undef SYM_TYPE
70 };
71 const char *name = "unknown sym type name";
72 if (type < sizeof(type_name)/sizeof(type_name[0])) {
73 name = type_name[type];
74 }
75 return name;
76}
77
78static const char *sym_bind(unsigned bind)
79{
80 static const char *bind_name[] = {
81#define SYM_BIND(X) [X] = #X
82 SYM_BIND(STB_LOCAL),
83 SYM_BIND(STB_GLOBAL),
84 SYM_BIND(STB_WEAK),
85#undef SYM_BIND
86 };
87 const char *name = "unknown sym bind name";
88 if (bind < sizeof(bind_name)/sizeof(bind_name[0])) {
89 name = bind_name[bind];
90 }
91 return name;
92}
93
94static const char *sym_visibility(unsigned visibility)
95{
96 static const char *visibility_name[] = {
97#define SYM_VISIBILITY(X) [X] = #X
98 SYM_VISIBILITY(STV_DEFAULT),
99 SYM_VISIBILITY(STV_INTERNAL),
100 SYM_VISIBILITY(STV_HIDDEN),
101 SYM_VISIBILITY(STV_PROTECTED),
102#undef SYM_VISIBILITY
103 };
104 const char *name = "unknown sym visibility name";
105 if (visibility < sizeof(visibility_name)/sizeof(visibility_name[0])) {
106 name = visibility_name[visibility];
107 }
108 return name;
109}
110
111static const char *rel_type(unsigned type)
112{
113 static const char *type_name[] = {
114#define REL_TYPE(X) [X] = #X
115 REL_TYPE(R_386_NONE),
116 REL_TYPE(R_386_32),
117 REL_TYPE(R_386_PC32),
118 REL_TYPE(R_386_GOT32),
119 REL_TYPE(R_386_PLT32),
120 REL_TYPE(R_386_COPY),
121 REL_TYPE(R_386_GLOB_DAT),
122 REL_TYPE(R_386_JMP_SLOT),
123 REL_TYPE(R_386_RELATIVE),
124 REL_TYPE(R_386_GOTOFF),
125 REL_TYPE(R_386_GOTPC),
126#undef REL_TYPE
127 };
128 const char *name = "unknown type rel type name";
129 if (type < sizeof(type_name)/sizeof(type_name[0])) {
130 name = type_name[type];
131 }
132 return name;
133}
134
135static const char *sec_name(unsigned shndx)
136{
137 const char *sec_strtab;
138 const char *name;
139 sec_strtab = strtab[ehdr.e_shstrndx];
140 name = "<noname>";
141 if (shndx < ehdr.e_shnum) {
142 name = sec_strtab + shdr[shndx].sh_name;
143 }
144 else if (shndx == SHN_ABS) {
145 name = "ABSOLUTE";
146 }
147 else if (shndx == SHN_COMMON) {
148 name = "COMMON";
149 }
150 return name;
151}
152
153static const char *sym_name(const char *sym_strtab, Elf32_Sym *sym)
154{
155 const char *name;
156 name = "<noname>";
157 if (sym->st_name) {
158 name = sym_strtab + sym->st_name;
159 }
160 else {
161 name = sec_name(shdr[sym->st_shndx].sh_name);
162 }
163 return name;
164}
165
166
167
168#if BYTE_ORDER == LITTLE_ENDIAN
169#define le16_to_cpu(val) (val)
170#define le32_to_cpu(val) (val)
171#endif
172#if BYTE_ORDER == BIG_ENDIAN
173#define le16_to_cpu(val) bswap_16(val)
174#define le32_to_cpu(val) bswap_32(val)
175#endif
176
177static uint16_t elf16_to_cpu(uint16_t val)
178{
179 return le16_to_cpu(val);
180}
181
182static uint32_t elf32_to_cpu(uint32_t val)
183{
184 return le32_to_cpu(val);
185}
186
187static void read_ehdr(FILE *fp)
188{
189 if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) {
190 die("Cannot read ELF header: %s\n",
191 strerror(errno));
192 }
193 if (memcmp(ehdr.e_ident, ELFMAG, 4) != 0) {
194 die("No ELF magic\n");
195 }
196 if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
197 die("Not a 32 bit executable\n");
198 }
199 if (ehdr.e_ident[EI_DATA] != ELFDATA2LSB) {
200 die("Not a LSB ELF executable\n");
201 }
202 if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) {
203 die("Unknown ELF version\n");
204 }
205 /* Convert the fields to native endian */
206 ehdr.e_type = elf16_to_cpu(ehdr.e_type);
207 ehdr.e_machine = elf16_to_cpu(ehdr.e_machine);
208 ehdr.e_version = elf32_to_cpu(ehdr.e_version);
209 ehdr.e_entry = elf32_to_cpu(ehdr.e_entry);
210 ehdr.e_phoff = elf32_to_cpu(ehdr.e_phoff);
211 ehdr.e_shoff = elf32_to_cpu(ehdr.e_shoff);
212 ehdr.e_flags = elf32_to_cpu(ehdr.e_flags);
213 ehdr.e_ehsize = elf16_to_cpu(ehdr.e_ehsize);
214 ehdr.e_phentsize = elf16_to_cpu(ehdr.e_phentsize);
215 ehdr.e_phnum = elf16_to_cpu(ehdr.e_phnum);
216 ehdr.e_shentsize = elf16_to_cpu(ehdr.e_shentsize);
217 ehdr.e_shnum = elf16_to_cpu(ehdr.e_shnum);
218 ehdr.e_shstrndx = elf16_to_cpu(ehdr.e_shstrndx);
219
220 if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) {
221 die("Unsupported ELF header type\n");
222 }
223 if (ehdr.e_machine != EM_386) {
224 die("Not for x86\n");
225 }
226 if (ehdr.e_version != EV_CURRENT) {
227 die("Unknown ELF version\n");
228 }
229 if (ehdr.e_ehsize != sizeof(Elf32_Ehdr)) {
230 die("Bad Elf header size\n");
231 }
232 if (ehdr.e_phentsize != sizeof(Elf32_Phdr)) {
233 die("Bad program header entry\n");
234 }
235 if (ehdr.e_shentsize != sizeof(Elf32_Shdr)) {
236 die("Bad section header entry\n");
237 }
238 if (ehdr.e_shstrndx >= ehdr.e_shnum) {
239 die("String table index out of bounds\n");
240 }
241}
242
243static void read_shdrs(FILE *fp)
244{
245 int i;
246 if (ehdr.e_shnum > MAX_SHDRS) {
247 die("%d section headers supported: %d\n",
248 ehdr.e_shnum, MAX_SHDRS);
249 }
250 if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
251 die("Seek to %d failed: %s\n",
252 ehdr.e_shoff, strerror(errno));
253 }
254 if (fread(&shdr, sizeof(shdr[0]), ehdr.e_shnum, fp) != ehdr.e_shnum) {
255 die("Cannot read ELF section headers: %s\n",
256 strerror(errno));
257 }
258 for(i = 0; i < ehdr.e_shnum; i++) {
259 shdr[i].sh_name = elf32_to_cpu(shdr[i].sh_name);
260 shdr[i].sh_type = elf32_to_cpu(shdr[i].sh_type);
261 shdr[i].sh_flags = elf32_to_cpu(shdr[i].sh_flags);
262 shdr[i].sh_addr = elf32_to_cpu(shdr[i].sh_addr);
263 shdr[i].sh_offset = elf32_to_cpu(shdr[i].sh_offset);
264 shdr[i].sh_size = elf32_to_cpu(shdr[i].sh_size);
265 shdr[i].sh_link = elf32_to_cpu(shdr[i].sh_link);
266 shdr[i].sh_info = elf32_to_cpu(shdr[i].sh_info);
267 shdr[i].sh_addralign = elf32_to_cpu(shdr[i].sh_addralign);
268 shdr[i].sh_entsize = elf32_to_cpu(shdr[i].sh_entsize);
269 }
270
271}
272
273static void read_strtabs(FILE *fp)
274{
275 int i;
276 for(i = 0; i < ehdr.e_shnum; i++) {
277 if (shdr[i].sh_type != SHT_STRTAB) {
278 continue;
279 }
280 strtab[i] = malloc(shdr[i].sh_size);
281 if (!strtab[i]) {
282 die("malloc of %d bytes for strtab failed\n",
283 shdr[i].sh_size);
284 }
285 if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
286 die("Seek to %d failed: %s\n",
287 shdr[i].sh_offset, strerror(errno));
288 }
289 if (fread(strtab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
290 die("Cannot read symbol table: %s\n",
291 strerror(errno));
292 }
293 }
294}
295
296static void read_symtabs(FILE *fp)
297{
298 int i,j;
299 for(i = 0; i < ehdr.e_shnum; i++) {
300 if (shdr[i].sh_type != SHT_SYMTAB) {
301 continue;
302 }
303 symtab[i] = malloc(shdr[i].sh_size);
304 if (!symtab[i]) {
305 die("malloc of %d bytes for symtab failed\n",
306 shdr[i].sh_size);
307 }
308 if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
309 die("Seek to %d failed: %s\n",
310 shdr[i].sh_offset, strerror(errno));
311 }
312 if (fread(symtab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
313 die("Cannot read symbol table: %s\n",
314 strerror(errno));
315 }
316 for(j = 0; j < shdr[i].sh_size/sizeof(symtab[i][0]); j++) {
317 symtab[i][j].st_name = elf32_to_cpu(symtab[i][j].st_name);
318 symtab[i][j].st_value = elf32_to_cpu(symtab[i][j].st_value);
319 symtab[i][j].st_size = elf32_to_cpu(symtab[i][j].st_size);
320 symtab[i][j].st_shndx = elf16_to_cpu(symtab[i][j].st_shndx);
321 }
322 }
323}
324
325
326static void read_relocs(FILE *fp)
327{
328 int i,j;
329 for(i = 0; i < ehdr.e_shnum; i++) {
330 if (shdr[i].sh_type != SHT_REL) {
331 continue;
332 }
333 reltab[i] = malloc(shdr[i].sh_size);
334 if (!reltab[i]) {
335 die("malloc of %d bytes for relocs failed\n",
336 shdr[i].sh_size);
337 }
338 if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
339 die("Seek to %d failed: %s\n",
340 shdr[i].sh_offset, strerror(errno));
341 }
342 if (fread(reltab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
343 die("Cannot read symbol table: %s\n",
344 strerror(errno));
345 }
346 for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
347 reltab[i][j].r_offset = elf32_to_cpu(reltab[i][j].r_offset);
348 reltab[i][j].r_info = elf32_to_cpu(reltab[i][j].r_info);
349 }
350 }
351}
352
353
354static void print_absolute_symbols(void)
355{
356 int i;
357 printf("Absolute symbols\n");
358 printf(" Num: Value Size Type Bind Visibility Name\n");
359 for(i = 0; i < ehdr.e_shnum; i++) {
360 char *sym_strtab;
361 Elf32_Sym *sh_symtab;
362 int j;
363 if (shdr[i].sh_type != SHT_SYMTAB) {
364 continue;
365 }
366 sh_symtab = symtab[i];
367 sym_strtab = strtab[shdr[i].sh_link];
368 for(j = 0; j < shdr[i].sh_size/sizeof(symtab[0][0]); j++) {
369 Elf32_Sym *sym;
370 const char *name;
371 sym = &symtab[i][j];
372 name = sym_name(sym_strtab, sym);
373 if (sym->st_shndx != SHN_ABS) {
374 continue;
375 }
376 printf("%5d %08x %5d %10s %10s %12s %s\n",
377 j, sym->st_value, sym->st_size,
378 sym_type(ELF32_ST_TYPE(sym->st_info)),
379 sym_bind(ELF32_ST_BIND(sym->st_info)),
380 sym_visibility(ELF32_ST_VISIBILITY(sym->st_other)),
381 name);
382 }
383 }
384 printf("\n");
385}
386
387static void print_absolute_relocs(void)
388{
389 int i, printed = 0;
390
391 for(i = 0; i < ehdr.e_shnum; i++) {
392 char *sym_strtab;
393 Elf32_Sym *sh_symtab;
394 unsigned sec_applies, sec_symtab;
395 int j;
396 if (shdr[i].sh_type != SHT_REL) {
397 continue;
398 }
399 sec_symtab = shdr[i].sh_link;
400 sec_applies = shdr[i].sh_info;
401 if (!(shdr[sec_applies].sh_flags & SHF_ALLOC)) {
402 continue;
403 }
404 sh_symtab = symtab[sec_symtab];
405 sym_strtab = strtab[shdr[sec_symtab].sh_link];
406 for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
407 Elf32_Rel *rel;
408 Elf32_Sym *sym;
409 const char *name;
410 rel = &reltab[i][j];
411 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
412 name = sym_name(sym_strtab, sym);
413 if (sym->st_shndx != SHN_ABS) {
414 continue;
415 }
416
417 /* Absolute symbols are not relocated if bzImage is
418 * loaded at a non-compiled address. Display a warning
419 * to user at compile time about the absolute
420 * relocations present.
421 *
422 * User need to audit the code to make sure
423 * some symbols which should have been section
424 * relative have not become absolute because of some
425 * linker optimization or wrong programming usage.
426 *
427 * Before warning check if this absolute symbol
428 * relocation is harmless.
429 */
430 if (is_safe_abs_reloc(name))
431 continue;
432
433 if (!printed) {
434 printf("WARNING: Absolute relocations"
435 " present\n");
436 printf("Offset Info Type Sym.Value "
437 "Sym.Name\n");
438 printed = 1;
439 }
440
441 printf("%08x %08x %10s %08x %s\n",
442 rel->r_offset,
443 rel->r_info,
444 rel_type(ELF32_R_TYPE(rel->r_info)),
445 sym->st_value,
446 name);
447 }
448 }
449
450 if (printed)
451 printf("\n");
452}
453
454static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym))
455{
456 int i;
457 /* Walk through the relocations */
458 for(i = 0; i < ehdr.e_shnum; i++) {
459 char *sym_strtab;
460 Elf32_Sym *sh_symtab;
461 unsigned sec_applies, sec_symtab;
462 int j;
463 if (shdr[i].sh_type != SHT_REL) {
464 continue;
465 }
466 sec_symtab = shdr[i].sh_link;
467 sec_applies = shdr[i].sh_info;
468 if (!(shdr[sec_applies].sh_flags & SHF_ALLOC)) {
469 continue;
470 }
471 sh_symtab = symtab[sec_symtab];
472 sym_strtab = strtab[shdr[sec_symtab].sh_link];
473 for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
474 Elf32_Rel *rel;
475 Elf32_Sym *sym;
476 unsigned r_type;
477 rel = &reltab[i][j];
478 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
479 r_type = ELF32_R_TYPE(rel->r_info);
480 /* Don't visit relocations to absolute symbols */
481 if (sym->st_shndx == SHN_ABS) {
482 continue;
483 }
484 if (r_type == R_386_PC32) {
485 /* PC relative relocations don't need to be adjusted */
486 }
487 else if (r_type == R_386_32) {
488 /* Visit relocations that need to be adjusted */
489 visit(rel, sym);
490 }
491 else {
492 die("Unsupported relocation type: %d\n", r_type);
493 }
494 }
495 }
496}
497
498static void count_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
499{
500 reloc_count += 1;
501}
502
503static void collect_reloc(Elf32_Rel *rel, Elf32_Sym *sym)
504{
505 /* Remember the address that needs to be adjusted. */
506 relocs[reloc_idx++] = rel->r_offset;
507}
508
509static int cmp_relocs(const void *va, const void *vb)
510{
511 const unsigned long *a, *b;
512 a = va; b = vb;
513 return (*a == *b)? 0 : (*a > *b)? 1 : -1;
514}
515
516static void emit_relocs(int as_text)
517{
518 int i;
519 /* Count how many relocations I have and allocate space for them. */
520 reloc_count = 0;
521 walk_relocs(count_reloc);
522 relocs = malloc(reloc_count * sizeof(relocs[0]));
523 if (!relocs) {
524 die("malloc of %d entries for relocs failed\n",
525 reloc_count);
526 }
527 /* Collect up the relocations */
528 reloc_idx = 0;
529 walk_relocs(collect_reloc);
530
531 /* Order the relocations for more efficient processing */
532 qsort(relocs, reloc_count, sizeof(relocs[0]), cmp_relocs);
533
534 /* Print the relocations */
535 if (as_text) {
536 /* Print the relocations in a form suitable that
537 * gas will like.
538 */
539 printf(".section \".data.reloc\",\"a\"\n");
540 printf(".balign 4\n");
541 for(i = 0; i < reloc_count; i++) {
542 printf("\t .long 0x%08lx\n", relocs[i]);
543 }
544 printf("\n");
545 }
546 else {
547 unsigned char buf[4];
548 buf[0] = buf[1] = buf[2] = buf[3] = 0;
549 /* Print a stop */
550 printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
551 /* Now print each relocation */
552 for(i = 0; i < reloc_count; i++) {
553 buf[0] = (relocs[i] >> 0) & 0xff;
554 buf[1] = (relocs[i] >> 8) & 0xff;
555 buf[2] = (relocs[i] >> 16) & 0xff;
556 buf[3] = (relocs[i] >> 24) & 0xff;
557 printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
558 }
559 }
560}
561
562static void usage(void)
563{
564 die("relocs [--abs-syms |--abs-relocs | --text] vmlinux\n");
565}
566
567int main(int argc, char **argv)
568{
569 int show_absolute_syms, show_absolute_relocs;
570 int as_text;
571 const char *fname;
572 FILE *fp;
573 int i;
574
575 show_absolute_syms = 0;
576 show_absolute_relocs = 0;
577 as_text = 0;
578 fname = NULL;
579 for(i = 1; i < argc; i++) {
580 char *arg = argv[i];
581 if (*arg == '-') {
582 if (strcmp(argv[1], "--abs-syms") == 0) {
583 show_absolute_syms = 1;
584 continue;
585 }
586
587 if (strcmp(argv[1], "--abs-relocs") == 0) {
588 show_absolute_relocs = 1;
589 continue;
590 }
591 else if (strcmp(argv[1], "--text") == 0) {
592 as_text = 1;
593 continue;
594 }
595 }
596 else if (!fname) {
597 fname = arg;
598 continue;
599 }
600 usage();
601 }
602 if (!fname) {
603 usage();
604 }
605 fp = fopen(fname, "r");
606 if (!fp) {
607 die("Cannot open %s: %s\n",
608 fname, strerror(errno));
609 }
610 read_ehdr(fp);
611 read_shdrs(fp);
612 read_strtabs(fp);
613 read_symtabs(fp);
614 read_relocs(fp);
615 if (show_absolute_syms) {
616 print_absolute_symbols();
617 return 0;
618 }
619 if (show_absolute_relocs) {
620 print_absolute_relocs();
621 return 0;
622 }
623 emit_relocs(as_text);
624 return 0;
625}
diff --git a/arch/i386/boot/compressed/vmlinux.lds b/arch/i386/boot/compressed/vmlinux.lds
new file mode 100644
index 000000000000..cc4854f6c6c1
--- /dev/null
+++ b/arch/i386/boot/compressed/vmlinux.lds
@@ -0,0 +1,43 @@
1OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
2OUTPUT_ARCH(i386)
3ENTRY(startup_32)
4SECTIONS
5{
6 /* Be careful parts of head.S assume startup_32 is at
7 * address 0.
8 */
9 . = 0 ;
10 .text.head : {
11 _head = . ;
12 *(.text.head)
13 _ehead = . ;
14 }
15 .data.compressed : {
16 *(.data.compressed)
17 }
18 .text : {
19 _text = .; /* Text */
20 *(.text)
21 *(.text.*)
22 _etext = . ;
23 }
24 .rodata : {
25 _rodata = . ;
26 *(.rodata) /* read-only data */
27 *(.rodata.*)
28 _erodata = . ;
29 }
30 .data : {
31 _data = . ;
32 *(.data)
33 *(.data.*)
34 _edata = . ;
35 }
36 .bss : {
37 _bss = . ;
38 *(.bss)
39 *(.bss.*)
40 *(COMMON)
41 _end = . ;
42 }
43}
diff --git a/arch/i386/boot/compressed/vmlinux.scr b/arch/i386/boot/compressed/vmlinux.scr
index 1ed9d791f863..707a88f7f29e 100644
--- a/arch/i386/boot/compressed/vmlinux.scr
+++ b/arch/i386/boot/compressed/vmlinux.scr
@@ -1,9 +1,10 @@
1SECTIONS 1SECTIONS
2{ 2{
3 .data : { 3 .data.compressed : {
4 input_len = .; 4 input_len = .;
5 LONG(input_data_end - input_data) input_data = .; 5 LONG(input_data_end - input_data) input_data = .;
6 *(.data) 6 *(.data)
7 output_len = . - 4;
7 input_data_end = .; 8 input_data_end = .;
8 } 9 }
9} 10}
diff --git a/arch/i386/boot/setup.S b/arch/i386/boot/setup.S
index 3aec4538a113..06edf1c66242 100644
--- a/arch/i386/boot/setup.S
+++ b/arch/i386/boot/setup.S
@@ -81,7 +81,7 @@ start:
81# This is the setup header, and it must start at %cs:2 (old 0x9020:2) 81# This is the setup header, and it must start at %cs:2 (old 0x9020:2)
82 82
83 .ascii "HdrS" # header signature 83 .ascii "HdrS" # header signature
84 .word 0x0204 # header version number (>= 0x0105) 84 .word 0x0205 # header version number (>= 0x0105)
85 # or else old loadlin-1.5 will fail) 85 # or else old loadlin-1.5 will fail)
86realmode_swtch: .word 0, 0 # default_switch, SETUPSEG 86realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
87start_sys_seg: .word SYSSEG 87start_sys_seg: .word SYSSEG
@@ -160,6 +160,17 @@ ramdisk_max: .long (-__PAGE_OFFSET-(512 << 20)-1) & 0x7fffffff
160 # The highest safe address for 160 # The highest safe address for
161 # the contents of an initrd 161 # the contents of an initrd
162 162
163kernel_alignment: .long CONFIG_PHYSICAL_ALIGN #physical addr alignment
164 #required for protected mode
165 #kernel
166#ifdef CONFIG_RELOCATABLE
167relocatable_kernel: .byte 1
168#else
169relocatable_kernel: .byte 0
170#endif
171pad2: .byte 0
172pad3: .word 0
173
163trampoline: call start_of_setup 174trampoline: call start_of_setup
164 .align 16 175 .align 16
165 # The offset at this point is 0x240 176 # The offset at this point is 0x240
@@ -588,11 +599,6 @@ rmodeswtch_normal:
588 call default_switch 599 call default_switch
589 600
590rmodeswtch_end: 601rmodeswtch_end:
591# we get the code32 start address and modify the below 'jmpi'
592# (loader may have changed it)
593 movl %cs:code32_start, %eax
594 movl %eax, %cs:code32
595
596# Now we move the system to its rightful place ... but we check if we have a 602# Now we move the system to its rightful place ... but we check if we have a
597# big-kernel. In that case we *must* not move it ... 603# big-kernel. In that case we *must* not move it ...
598 testb $LOADED_HIGH, %cs:loadflags 604 testb $LOADED_HIGH, %cs:loadflags
@@ -788,11 +794,12 @@ a20_err_msg:
788a20_done: 794a20_done:
789 795
790#endif /* CONFIG_X86_VOYAGER */ 796#endif /* CONFIG_X86_VOYAGER */
791# set up gdt and idt 797# set up gdt and idt and 32bit start address
792 lidt idt_48 # load idt with 0,0 798 lidt idt_48 # load idt with 0,0
793 xorl %eax, %eax # Compute gdt_base 799 xorl %eax, %eax # Compute gdt_base
794 movw %ds, %ax # (Convert %ds:gdt to a linear ptr) 800 movw %ds, %ax # (Convert %ds:gdt to a linear ptr)
795 shll $4, %eax 801 shll $4, %eax
802 addl %eax, code32
796 addl $gdt, %eax 803 addl $gdt, %eax
797 movl %eax, (gdt_48+2) 804 movl %eax, (gdt_48+2)
798 lgdt gdt_48 # load gdt with whatever is 805 lgdt gdt_48 # load gdt with whatever is
@@ -851,9 +858,26 @@ flush_instr:
851# Manual, Mixing 16-bit and 32-bit code, page 16-6) 858# Manual, Mixing 16-bit and 32-bit code, page 16-6)
852 859
853 .byte 0x66, 0xea # prefix + jmpi-opcode 860 .byte 0x66, 0xea # prefix + jmpi-opcode
854code32: .long 0x1000 # will be set to 0x100000 861code32: .long startup_32 # will be set to %cs+startup_32
855 # for big kernels
856 .word __BOOT_CS 862 .word __BOOT_CS
863.code32
864startup_32:
865 movl $(__BOOT_DS), %eax
866 movl %eax, %ds
867 movl %eax, %es
868 movl %eax, %fs
869 movl %eax, %gs
870 movl %eax, %ss
871
872 xorl %eax, %eax
8731: incl %eax # check that A20 really IS enabled
874 movl %eax, 0x00000000 # loop forever if it isn't
875 cmpl %eax, 0x00100000
876 je 1b
877
878 # Jump to the 32bit entry point
879 jmpl *(code32_start - start + (DELTA_INITSEG << 4))(%esi)
880.code16
857 881
858# Here's a bunch of information about your current kernel.. 882# Here's a bunch of information about your current kernel..
859kernel_version: .ascii UTS_RELEASE 883kernel_version: .ascii UTS_RELEASE
diff --git a/arch/i386/defconfig b/arch/i386/defconfig
index 97aacd6bd7d8..65891f11aced 100644
--- a/arch/i386/defconfig
+++ b/arch/i386/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc2-git4 3# Linux kernel version: 2.6.19-git7
4# Sat Oct 21 03:38:56 2006 4# Wed Dec 6 23:50:49 2006
5# 5#
6CONFIG_X86_32=y 6CONFIG_X86_32=y
7CONFIG_GENERIC_TIME=y 7CONFIG_GENERIC_TIME=y
@@ -40,13 +40,14 @@ CONFIG_POSIX_MQUEUE=y
40CONFIG_IKCONFIG=y 40CONFIG_IKCONFIG=y
41CONFIG_IKCONFIG_PROC=y 41CONFIG_IKCONFIG_PROC=y
42# CONFIG_CPUSETS is not set 42# CONFIG_CPUSETS is not set
43CONFIG_SYSFS_DEPRECATED=y
43# CONFIG_RELAY is not set 44# CONFIG_RELAY is not set
44CONFIG_INITRAMFS_SOURCE="" 45CONFIG_INITRAMFS_SOURCE=""
45CONFIG_CC_OPTIMIZE_FOR_SIZE=y 46CONFIG_CC_OPTIMIZE_FOR_SIZE=y
46CONFIG_SYSCTL=y 47CONFIG_SYSCTL=y
47# CONFIG_EMBEDDED is not set 48# CONFIG_EMBEDDED is not set
48CONFIG_UID16=y 49CONFIG_UID16=y
49# CONFIG_SYSCTL_SYSCALL is not set 50CONFIG_SYSCTL_SYSCALL=y
50CONFIG_KALLSYMS=y 51CONFIG_KALLSYMS=y
51CONFIG_KALLSYMS_ALL=y 52CONFIG_KALLSYMS_ALL=y
52# CONFIG_KALLSYMS_EXTRA_PASS is not set 53# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -110,6 +111,7 @@ CONFIG_SMP=y
110# CONFIG_X86_VISWS is not set 111# CONFIG_X86_VISWS is not set
111CONFIG_X86_GENERICARCH=y 112CONFIG_X86_GENERICARCH=y
112# CONFIG_X86_ES7000 is not set 113# CONFIG_X86_ES7000 is not set
114# CONFIG_PARAVIRT is not set
113CONFIG_X86_CYCLONE_TIMER=y 115CONFIG_X86_CYCLONE_TIMER=y
114# CONFIG_M386 is not set 116# CONFIG_M386 is not set
115# CONFIG_M486 is not set 117# CONFIG_M486 is not set
@@ -120,6 +122,7 @@ CONFIG_X86_CYCLONE_TIMER=y
120# CONFIG_MPENTIUMII is not set 122# CONFIG_MPENTIUMII is not set
121CONFIG_MPENTIUMIII=y 123CONFIG_MPENTIUMIII=y
122# CONFIG_MPENTIUMM is not set 124# CONFIG_MPENTIUMM is not set
125# CONFIG_MCORE2 is not set
123# CONFIG_MPENTIUM4 is not set 126# CONFIG_MPENTIUM4 is not set
124# CONFIG_MK6 is not set 127# CONFIG_MK6 is not set
125# CONFIG_MK7 is not set 128# CONFIG_MK7 is not set
@@ -197,7 +200,6 @@ CONFIG_RESOURCES_64BIT=y
197CONFIG_MTRR=y 200CONFIG_MTRR=y
198# CONFIG_EFI is not set 201# CONFIG_EFI is not set
199# CONFIG_IRQBALANCE is not set 202# CONFIG_IRQBALANCE is not set
200CONFIG_REGPARM=y
201CONFIG_SECCOMP=y 203CONFIG_SECCOMP=y
202# CONFIG_HZ_100 is not set 204# CONFIG_HZ_100 is not set
203CONFIG_HZ_250=y 205CONFIG_HZ_250=y
@@ -205,7 +207,8 @@ CONFIG_HZ_250=y
205CONFIG_HZ=250 207CONFIG_HZ=250
206# CONFIG_KEXEC is not set 208# CONFIG_KEXEC is not set
207# CONFIG_CRASH_DUMP is not set 209# CONFIG_CRASH_DUMP is not set
208CONFIG_PHYSICAL_START=0x100000 210# CONFIG_RELOCATABLE is not set
211CONFIG_PHYSICAL_ALIGN=0x100000
209# CONFIG_HOTPLUG_CPU is not set 212# CONFIG_HOTPLUG_CPU is not set
210CONFIG_COMPAT_VDSO=y 213CONFIG_COMPAT_VDSO=y
211CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y 214CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
@@ -367,6 +370,7 @@ CONFIG_INET_TCP_DIAG=y
367# CONFIG_TCP_CONG_ADVANCED is not set 370# CONFIG_TCP_CONG_ADVANCED is not set
368CONFIG_TCP_CONG_CUBIC=y 371CONFIG_TCP_CONG_CUBIC=y
369CONFIG_DEFAULT_TCP_CONG="cubic" 372CONFIG_DEFAULT_TCP_CONG="cubic"
373# CONFIG_TCP_MD5SIG is not set
370CONFIG_IPV6=y 374CONFIG_IPV6=y
371# CONFIG_IPV6_PRIVACY is not set 375# CONFIG_IPV6_PRIVACY is not set
372# CONFIG_IPV6_ROUTER_PREF is not set 376# CONFIG_IPV6_ROUTER_PREF is not set
@@ -677,6 +681,7 @@ CONFIG_SATA_INTEL_COMBINED=y
677# CONFIG_PATA_IT821X is not set 681# CONFIG_PATA_IT821X is not set
678# CONFIG_PATA_JMICRON is not set 682# CONFIG_PATA_JMICRON is not set
679# CONFIG_PATA_TRIFLEX is not set 683# CONFIG_PATA_TRIFLEX is not set
684# CONFIG_PATA_MARVELL is not set
680# CONFIG_PATA_MPIIX is not set 685# CONFIG_PATA_MPIIX is not set
681# CONFIG_PATA_OLDPIIX is not set 686# CONFIG_PATA_OLDPIIX is not set
682# CONFIG_PATA_NETCELL is not set 687# CONFIG_PATA_NETCELL is not set
@@ -850,6 +855,7 @@ CONFIG_BNX2=y
850# CONFIG_IXGB is not set 855# CONFIG_IXGB is not set
851# CONFIG_S2IO is not set 856# CONFIG_S2IO is not set
852# CONFIG_MYRI10GE is not set 857# CONFIG_MYRI10GE is not set
858# CONFIG_NETXEN_NIC is not set
853 859
854# 860#
855# Token Ring devices 861# Token Ring devices
@@ -984,10 +990,6 @@ CONFIG_RTC=y
984# CONFIG_R3964 is not set 990# CONFIG_R3964 is not set
985# CONFIG_APPLICOM is not set 991# CONFIG_APPLICOM is not set
986# CONFIG_SONYPI is not set 992# CONFIG_SONYPI is not set
987
988#
989# Ftape, the floppy tape device driver
990#
991CONFIG_AGP=y 993CONFIG_AGP=y
992# CONFIG_AGP_ALI is not set 994# CONFIG_AGP_ALI is not set
993# CONFIG_AGP_ATI is not set 995# CONFIG_AGP_ATI is not set
@@ -1108,6 +1110,7 @@ CONFIG_USB_DEVICEFS=y
1108# CONFIG_USB_BANDWIDTH is not set 1110# CONFIG_USB_BANDWIDTH is not set
1109# CONFIG_USB_DYNAMIC_MINORS is not set 1111# CONFIG_USB_DYNAMIC_MINORS is not set
1110# CONFIG_USB_SUSPEND is not set 1112# CONFIG_USB_SUSPEND is not set
1113# CONFIG_USB_MULTITHREAD_PROBE is not set
1111# CONFIG_USB_OTG is not set 1114# CONFIG_USB_OTG is not set
1112 1115
1113# 1116#
@@ -1185,6 +1188,7 @@ CONFIG_USB_HIDINPUT=y
1185# CONFIG_USB_KAWETH is not set 1188# CONFIG_USB_KAWETH is not set
1186# CONFIG_USB_PEGASUS is not set 1189# CONFIG_USB_PEGASUS is not set
1187# CONFIG_USB_RTL8150 is not set 1190# CONFIG_USB_RTL8150 is not set
1191# CONFIG_USB_USBNET_MII is not set
1188# CONFIG_USB_USBNET is not set 1192# CONFIG_USB_USBNET is not set
1189CONFIG_USB_MON=y 1193CONFIG_USB_MON=y
1190 1194
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index 1a884b6e6e5c..1e8988e558c5 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -6,7 +6,7 @@ extra-y := head.o init_task.o vmlinux.lds
6 6
7obj-y := process.o signal.o entry.o traps.o irq.o \ 7obj-y := process.o signal.o entry.o traps.o irq.o \
8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ 8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
9 pci-dma.o i386_ksyms.o i387.o bootflag.o \ 9 pci-dma.o i386_ksyms.o i387.o bootflag.o e820.o\
10 quirks.o i8237.o topology.o alternative.o i8253.o tsc.o 10 quirks.o i8237.o topology.o alternative.o i8253.o tsc.o
11 11
12obj-$(CONFIG_STACKTRACE) += stacktrace.o 12obj-$(CONFIG_STACKTRACE) += stacktrace.o
@@ -40,6 +40,9 @@ obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
40obj-$(CONFIG_HPET_TIMER) += hpet.o 40obj-$(CONFIG_HPET_TIMER) += hpet.o
41obj-$(CONFIG_K8_NB) += k8.o 41obj-$(CONFIG_K8_NB) += k8.o
42 42
43# Make sure this is linked after any other paravirt_ops structs: see head.S
44obj-$(CONFIG_PARAVIRT) += paravirt.o
45
43EXTRA_AFLAGS := -traditional 46EXTRA_AFLAGS := -traditional
44 47
45obj-$(CONFIG_SCx200) += scx200.o 48obj-$(CONFIG_SCx200) += scx200.o
diff --git a/arch/i386/kernel/acpi/cstate.c b/arch/i386/kernel/acpi/cstate.c
index 4664b55f623e..12e937c1ce4b 100644
--- a/arch/i386/kernel/acpi/cstate.c
+++ b/arch/i386/kernel/acpi/cstate.c
@@ -156,10 +156,8 @@ static int __init ffh_cstate_init(void)
156 156
157static void __exit ffh_cstate_exit(void) 157static void __exit ffh_cstate_exit(void)
158{ 158{
159 if (cpu_cstate_entry) { 159 free_percpu(cpu_cstate_entry);
160 free_percpu(cpu_cstate_entry); 160 cpu_cstate_entry = NULL;
161 cpu_cstate_entry = NULL;
162 }
163} 161}
164 162
165arch_initcall(ffh_cstate_init); 163arch_initcall(ffh_cstate_init);
diff --git a/arch/i386/kernel/acpi/earlyquirk.c b/arch/i386/kernel/acpi/earlyquirk.c
index c9841692bb7c..4b60af7f91dd 100644
--- a/arch/i386/kernel/acpi/earlyquirk.c
+++ b/arch/i386/kernel/acpi/earlyquirk.c
@@ -10,6 +10,7 @@
10#include <asm/pci-direct.h> 10#include <asm/pci-direct.h>
11#include <asm/acpi.h> 11#include <asm/acpi.h>
12#include <asm/apic.h> 12#include <asm/apic.h>
13#include <asm/irq.h>
13 14
14#ifdef CONFIG_ACPI 15#ifdef CONFIG_ACPI
15 16
@@ -49,6 +50,24 @@ static int __init check_bridge(int vendor, int device)
49 return 0; 50 return 0;
50} 51}
51 52
53static void check_intel(void)
54{
55 u16 vendor, device;
56
57 vendor = read_pci_config_16(0, 0, 0, PCI_VENDOR_ID);
58
59 if (vendor != PCI_VENDOR_ID_INTEL)
60 return;
61
62 device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID);
63#ifdef CONFIG_SMP
64 if (device == PCI_DEVICE_ID_INTEL_E7320_MCH ||
65 device == PCI_DEVICE_ID_INTEL_E7520_MCH ||
66 device == PCI_DEVICE_ID_INTEL_E7525_MCH)
67 quirk_intel_irqbalance();
68#endif
69}
70
52void __init check_acpi_pci(void) 71void __init check_acpi_pci(void)
53{ 72{
54 int num, slot, func; 73 int num, slot, func;
@@ -60,6 +79,8 @@ void __init check_acpi_pci(void)
60 if (!early_pci_allowed()) 79 if (!early_pci_allowed())
61 return; 80 return;
62 81
82 check_intel();
83
63 /* Poor man's PCI discovery */ 84 /* Poor man's PCI discovery */
64 for (num = 0; num < 32; num++) { 85 for (num = 0; num < 32; num++) {
65 for (slot = 0; slot < 32; slot++) { 86 for (slot = 0; slot < 32; slot++) {
diff --git a/arch/i386/kernel/alternative.c b/arch/i386/kernel/alternative.c
index 535f9794fba1..9eca21b49f6b 100644
--- a/arch/i386/kernel/alternative.c
+++ b/arch/i386/kernel/alternative.c
@@ -124,6 +124,20 @@ static unsigned char** find_nop_table(void)
124 124
125#endif /* CONFIG_X86_64 */ 125#endif /* CONFIG_X86_64 */
126 126
127static void nop_out(void *insns, unsigned int len)
128{
129 unsigned char **noptable = find_nop_table();
130
131 while (len > 0) {
132 unsigned int noplen = len;
133 if (noplen > ASM_NOP_MAX)
134 noplen = ASM_NOP_MAX;
135 memcpy(insns, noptable[noplen], noplen);
136 insns += noplen;
137 len -= noplen;
138 }
139}
140
127extern struct alt_instr __alt_instructions[], __alt_instructions_end[]; 141extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
128extern struct alt_instr __smp_alt_instructions[], __smp_alt_instructions_end[]; 142extern struct alt_instr __smp_alt_instructions[], __smp_alt_instructions_end[];
129extern u8 *__smp_locks[], *__smp_locks_end[]; 143extern u8 *__smp_locks[], *__smp_locks_end[];
@@ -138,10 +152,9 @@ extern u8 __smp_alt_begin[], __smp_alt_end[];
138 152
139void apply_alternatives(struct alt_instr *start, struct alt_instr *end) 153void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
140{ 154{
141 unsigned char **noptable = find_nop_table();
142 struct alt_instr *a; 155 struct alt_instr *a;
143 u8 *instr; 156 u8 *instr;
144 int diff, i, k; 157 int diff;
145 158
146 DPRINTK("%s: alt table %p -> %p\n", __FUNCTION__, start, end); 159 DPRINTK("%s: alt table %p -> %p\n", __FUNCTION__, start, end);
147 for (a = start; a < end; a++) { 160 for (a = start; a < end; a++) {
@@ -159,13 +172,7 @@ void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
159#endif 172#endif
160 memcpy(instr, a->replacement, a->replacementlen); 173 memcpy(instr, a->replacement, a->replacementlen);
161 diff = a->instrlen - a->replacementlen; 174 diff = a->instrlen - a->replacementlen;
162 /* Pad the rest with nops */ 175 nop_out(instr + a->replacementlen, diff);
163 for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
164 k = diff;
165 if (k > ASM_NOP_MAX)
166 k = ASM_NOP_MAX;
167 memcpy(a->instr + i, noptable[k], k);
168 }
169 } 176 }
170} 177}
171 178
@@ -209,7 +216,6 @@ static void alternatives_smp_lock(u8 **start, u8 **end, u8 *text, u8 *text_end)
209 216
210static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end) 217static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end)
211{ 218{
212 unsigned char **noptable = find_nop_table();
213 u8 **ptr; 219 u8 **ptr;
214 220
215 for (ptr = start; ptr < end; ptr++) { 221 for (ptr = start; ptr < end; ptr++) {
@@ -217,7 +223,7 @@ static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end
217 continue; 223 continue;
218 if (*ptr > text_end) 224 if (*ptr > text_end)
219 continue; 225 continue;
220 **ptr = noptable[1][0]; 226 nop_out(*ptr, 1);
221 }; 227 };
222} 228}
223 229
@@ -343,6 +349,40 @@ void alternatives_smp_switch(int smp)
343 349
344#endif 350#endif
345 351
352#ifdef CONFIG_PARAVIRT
353void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
354{
355 struct paravirt_patch *p;
356
357 for (p = start; p < end; p++) {
358 unsigned int used;
359
360 used = paravirt_ops.patch(p->instrtype, p->clobbers, p->instr,
361 p->len);
362#ifdef CONFIG_DEBUG_PARAVIRT
363 {
364 int i;
365 /* Deliberately clobber regs using "not %reg" to find bugs. */
366 for (i = 0; i < 3; i++) {
367 if (p->len - used >= 2 && (p->clobbers & (1 << i))) {
368 memcpy(p->instr + used, "\xf7\xd0", 2);
369 p->instr[used+1] |= i;
370 used += 2;
371 }
372 }
373 }
374#endif
375 /* Pad the rest with nops */
376 nop_out(p->instr + used, p->len - used);
377 }
378
379 /* Sync to be conservative, in case we patched following instructions */
380 sync_core();
381}
382extern struct paravirt_patch __start_parainstructions[],
383 __stop_parainstructions[];
384#endif /* CONFIG_PARAVIRT */
385
346void __init alternative_instructions(void) 386void __init alternative_instructions(void)
347{ 387{
348 unsigned long flags; 388 unsigned long flags;
@@ -390,5 +430,6 @@ void __init alternative_instructions(void)
390 alternatives_smp_switch(0); 430 alternatives_smp_switch(0);
391 } 431 }
392#endif 432#endif
433 apply_paravirt(__start_parainstructions, __stop_parainstructions);
393 local_irq_restore(flags); 434 local_irq_restore(flags);
394} 435}
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 2fd4b7d927c2..776d9be26af9 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -647,23 +647,30 @@ static struct {
647static int lapic_suspend(struct sys_device *dev, pm_message_t state) 647static int lapic_suspend(struct sys_device *dev, pm_message_t state)
648{ 648{
649 unsigned long flags; 649 unsigned long flags;
650 int maxlvt;
650 651
651 if (!apic_pm_state.active) 652 if (!apic_pm_state.active)
652 return 0; 653 return 0;
653 654
655 maxlvt = get_maxlvt();
656
654 apic_pm_state.apic_id = apic_read(APIC_ID); 657 apic_pm_state.apic_id = apic_read(APIC_ID);
655 apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI); 658 apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI);
656 apic_pm_state.apic_ldr = apic_read(APIC_LDR); 659 apic_pm_state.apic_ldr = apic_read(APIC_LDR);
657 apic_pm_state.apic_dfr = apic_read(APIC_DFR); 660 apic_pm_state.apic_dfr = apic_read(APIC_DFR);
658 apic_pm_state.apic_spiv = apic_read(APIC_SPIV); 661 apic_pm_state.apic_spiv = apic_read(APIC_SPIV);
659 apic_pm_state.apic_lvtt = apic_read(APIC_LVTT); 662 apic_pm_state.apic_lvtt = apic_read(APIC_LVTT);
660 apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC); 663 if (maxlvt >= 4)
664 apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
661 apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0); 665 apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0);
662 apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1); 666 apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1);
663 apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR); 667 apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
664 apic_pm_state.apic_tmict = apic_read(APIC_TMICT); 668 apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
665 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR); 669 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
666 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR); 670#ifdef CONFIG_X86_MCE_P4THERMAL
671 if (maxlvt >= 5)
672 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
673#endif
667 674
668 local_irq_save(flags); 675 local_irq_save(flags);
669 disable_local_APIC(); 676 disable_local_APIC();
@@ -675,10 +682,13 @@ static int lapic_resume(struct sys_device *dev)
675{ 682{
676 unsigned int l, h; 683 unsigned int l, h;
677 unsigned long flags; 684 unsigned long flags;
685 int maxlvt;
678 686
679 if (!apic_pm_state.active) 687 if (!apic_pm_state.active)
680 return 0; 688 return 0;
681 689
690 maxlvt = get_maxlvt();
691
682 local_irq_save(flags); 692 local_irq_save(flags);
683 693
684 /* 694 /*
@@ -700,8 +710,12 @@ static int lapic_resume(struct sys_device *dev)
700 apic_write(APIC_SPIV, apic_pm_state.apic_spiv); 710 apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
701 apic_write(APIC_LVT0, apic_pm_state.apic_lvt0); 711 apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
702 apic_write(APIC_LVT1, apic_pm_state.apic_lvt1); 712 apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
703 apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr); 713#ifdef CONFIG_X86_MCE_P4THERMAL
704 apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc); 714 if (maxlvt >= 5)
715 apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
716#endif
717 if (maxlvt >= 4)
718 apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
705 apic_write(APIC_LVTT, apic_pm_state.apic_lvtt); 719 apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
706 apic_write(APIC_TDCR, apic_pm_state.apic_tdcr); 720 apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
707 apic_write(APIC_TMICT, apic_pm_state.apic_tmict); 721 apic_write(APIC_TMICT, apic_pm_state.apic_tmict);
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index a60358fe9a49..a97847da9ed5 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -231,6 +231,7 @@
231#include <asm/uaccess.h> 231#include <asm/uaccess.h>
232#include <asm/desc.h> 232#include <asm/desc.h>
233#include <asm/i8253.h> 233#include <asm/i8253.h>
234#include <asm/paravirt.h>
234 235
235#include "io_ports.h" 236#include "io_ports.h"
236 237
@@ -2235,7 +2236,7 @@ static int __init apm_init(void)
2235 2236
2236 dmi_check_system(apm_dmi_table); 2237 dmi_check_system(apm_dmi_table);
2237 2238
2238 if (apm_info.bios.version == 0) { 2239 if (apm_info.bios.version == 0 || paravirt_enabled()) {
2239 printk(KERN_INFO "apm: BIOS not found.\n"); 2240 printk(KERN_INFO "apm: BIOS not found.\n");
2240 return -ENODEV; 2241 return -ENODEV;
2241 } 2242 }
diff --git a/arch/i386/kernel/asm-offsets.c b/arch/i386/kernel/asm-offsets.c
index c80271f8f084..1b2f3cd33270 100644
--- a/arch/i386/kernel/asm-offsets.c
+++ b/arch/i386/kernel/asm-offsets.c
@@ -15,6 +15,7 @@
15#include <asm/processor.h> 15#include <asm/processor.h>
16#include <asm/thread_info.h> 16#include <asm/thread_info.h>
17#include <asm/elf.h> 17#include <asm/elf.h>
18#include <asm/pda.h>
18 19
19#define DEFINE(sym, val) \ 20#define DEFINE(sym, val) \
20 asm volatile("\n->" #sym " %0 " #val : : "i" (val)) 21 asm volatile("\n->" #sym " %0 " #val : : "i" (val))
@@ -51,13 +52,35 @@ void foo(void)
51 OFFSET(TI_exec_domain, thread_info, exec_domain); 52 OFFSET(TI_exec_domain, thread_info, exec_domain);
52 OFFSET(TI_flags, thread_info, flags); 53 OFFSET(TI_flags, thread_info, flags);
53 OFFSET(TI_status, thread_info, status); 54 OFFSET(TI_status, thread_info, status);
54 OFFSET(TI_cpu, thread_info, cpu);
55 OFFSET(TI_preempt_count, thread_info, preempt_count); 55 OFFSET(TI_preempt_count, thread_info, preempt_count);
56 OFFSET(TI_addr_limit, thread_info, addr_limit); 56 OFFSET(TI_addr_limit, thread_info, addr_limit);
57 OFFSET(TI_restart_block, thread_info, restart_block); 57 OFFSET(TI_restart_block, thread_info, restart_block);
58 OFFSET(TI_sysenter_return, thread_info, sysenter_return); 58 OFFSET(TI_sysenter_return, thread_info, sysenter_return);
59 BLANK(); 59 BLANK();
60 60
61 OFFSET(GDS_size, Xgt_desc_struct, size);
62 OFFSET(GDS_address, Xgt_desc_struct, address);
63 OFFSET(GDS_pad, Xgt_desc_struct, pad);
64 BLANK();
65
66 OFFSET(PT_EBX, pt_regs, ebx);
67 OFFSET(PT_ECX, pt_regs, ecx);
68 OFFSET(PT_EDX, pt_regs, edx);
69 OFFSET(PT_ESI, pt_regs, esi);
70 OFFSET(PT_EDI, pt_regs, edi);
71 OFFSET(PT_EBP, pt_regs, ebp);
72 OFFSET(PT_EAX, pt_regs, eax);
73 OFFSET(PT_DS, pt_regs, xds);
74 OFFSET(PT_ES, pt_regs, xes);
75 OFFSET(PT_GS, pt_regs, xgs);
76 OFFSET(PT_ORIG_EAX, pt_regs, orig_eax);
77 OFFSET(PT_EIP, pt_regs, eip);
78 OFFSET(PT_CS, pt_regs, xcs);
79 OFFSET(PT_EFLAGS, pt_regs, eflags);
80 OFFSET(PT_OLDESP, pt_regs, esp);
81 OFFSET(PT_OLDSS, pt_regs, xss);
82 BLANK();
83
61 OFFSET(EXEC_DOMAIN_handler, exec_domain, handler); 84 OFFSET(EXEC_DOMAIN_handler, exec_domain, handler);
62 OFFSET(RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext); 85 OFFSET(RT_SIGFRAME_sigcontext, rt_sigframe, uc.uc_mcontext);
63 BLANK(); 86 BLANK();
@@ -74,4 +97,18 @@ void foo(void)
74 DEFINE(VDSO_PRELINK, VDSO_PRELINK); 97 DEFINE(VDSO_PRELINK, VDSO_PRELINK);
75 98
76 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx); 99 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
100
101 BLANK();
102 OFFSET(PDA_cpu, i386_pda, cpu_number);
103 OFFSET(PDA_pcurrent, i386_pda, pcurrent);
104
105#ifdef CONFIG_PARAVIRT
106 BLANK();
107 OFFSET(PARAVIRT_enabled, paravirt_ops, paravirt_enabled);
108 OFFSET(PARAVIRT_irq_disable, paravirt_ops, irq_disable);
109 OFFSET(PARAVIRT_irq_enable, paravirt_ops, irq_enable);
110 OFFSET(PARAVIRT_irq_enable_sysexit, paravirt_ops, irq_enable_sysexit);
111 OFFSET(PARAVIRT_iret, paravirt_ops, iret);
112 OFFSET(PARAVIRT_read_cr0, paravirt_ops, read_cr0);
113#endif
77} 114}
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index e4758095d87a..41cfea57232b 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -104,10 +104,7 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
104 f_vide(); 104 f_vide();
105 rdtscl(d2); 105 rdtscl(d2);
106 d = d2-d; 106 d = d2-d;
107 107
108 /* Knock these two lines out if it debugs out ok */
109 printk(KERN_INFO "AMD K6 stepping B detected - ");
110 /* -- cut here -- */
111 if (d > 20*K6_BUG_LOOP) 108 if (d > 20*K6_BUG_LOOP)
112 printk("system stability may be impaired when more than 32 MB are used.\n"); 109 printk("system stability may be impaired when more than 32 MB are used.\n");
113 else 110 else
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index d9f3e3c31f05..1b34c56f8123 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -18,14 +18,15 @@
18#include <asm/apic.h> 18#include <asm/apic.h>
19#include <mach_apic.h> 19#include <mach_apic.h>
20#endif 20#endif
21#include <asm/pda.h>
21 22
22#include "cpu.h" 23#include "cpu.h"
23 24
24DEFINE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr); 25DEFINE_PER_CPU(struct Xgt_desc_struct, cpu_gdt_descr);
25EXPORT_PER_CPU_SYMBOL(cpu_gdt_descr); 26EXPORT_PER_CPU_SYMBOL(cpu_gdt_descr);
26 27
27DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]); 28struct i386_pda *_cpu_pda[NR_CPUS] __read_mostly;
28EXPORT_PER_CPU_SYMBOL(cpu_16bit_stack); 29EXPORT_SYMBOL(_cpu_pda);
29 30
30static int cachesize_override __cpuinitdata = -1; 31static int cachesize_override __cpuinitdata = -1;
31static int disable_x86_fxsr __cpuinitdata; 32static int disable_x86_fxsr __cpuinitdata;
@@ -235,29 +236,14 @@ static int __cpuinit have_cpuid_p(void)
235 return flag_is_changeable_p(X86_EFLAGS_ID); 236 return flag_is_changeable_p(X86_EFLAGS_ID);
236} 237}
237 238
238/* Do minimum CPU detection early. 239void __init cpu_detect(struct cpuinfo_x86 *c)
239 Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment.
240 The others are not touched to avoid unwanted side effects.
241
242 WARNING: this function is only called on the BP. Don't add code here
243 that is supposed to run on all CPUs. */
244static void __init early_cpu_detect(void)
245{ 240{
246 struct cpuinfo_x86 *c = &boot_cpu_data;
247
248 c->x86_cache_alignment = 32;
249
250 if (!have_cpuid_p())
251 return;
252
253 /* Get vendor name */ 241 /* Get vendor name */
254 cpuid(0x00000000, &c->cpuid_level, 242 cpuid(0x00000000, &c->cpuid_level,
255 (int *)&c->x86_vendor_id[0], 243 (int *)&c->x86_vendor_id[0],
256 (int *)&c->x86_vendor_id[8], 244 (int *)&c->x86_vendor_id[8],
257 (int *)&c->x86_vendor_id[4]); 245 (int *)&c->x86_vendor_id[4]);
258 246
259 get_cpu_vendor(c, 1);
260
261 c->x86 = 4; 247 c->x86 = 4;
262 if (c->cpuid_level >= 0x00000001) { 248 if (c->cpuid_level >= 0x00000001) {
263 u32 junk, tfms, cap0, misc; 249 u32 junk, tfms, cap0, misc;
@@ -274,6 +260,26 @@ static void __init early_cpu_detect(void)
274 } 260 }
275} 261}
276 262
263/* Do minimum CPU detection early.
264 Fields really needed: vendor, cpuid_level, family, model, mask, cache alignment.
265 The others are not touched to avoid unwanted side effects.
266
267 WARNING: this function is only called on the BP. Don't add code here
268 that is supposed to run on all CPUs. */
269static void __init early_cpu_detect(void)
270{
271 struct cpuinfo_x86 *c = &boot_cpu_data;
272
273 c->x86_cache_alignment = 32;
274
275 if (!have_cpuid_p())
276 return;
277
278 cpu_detect(c);
279
280 get_cpu_vendor(c, 1);
281}
282
277static void __cpuinit generic_identify(struct cpuinfo_x86 * c) 283static void __cpuinit generic_identify(struct cpuinfo_x86 * c)
278{ 284{
279 u32 tfms, xlvl; 285 u32 tfms, xlvl;
@@ -308,6 +314,8 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 * c)
308#else 314#else
309 c->apicid = (ebx >> 24) & 0xFF; 315 c->apicid = (ebx >> 24) & 0xFF;
310#endif 316#endif
317 if (c->x86_capability[0] & (1<<19))
318 c->x86_clflush_size = ((ebx >> 8) & 0xff) * 8;
311 } else { 319 } else {
312 /* Have CPUID level 0 only - unheard of */ 320 /* Have CPUID level 0 only - unheard of */
313 c->x86 = 4; 321 c->x86 = 4;
@@ -372,6 +380,7 @@ void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
372 c->x86_vendor_id[0] = '\0'; /* Unset */ 380 c->x86_vendor_id[0] = '\0'; /* Unset */
373 c->x86_model_id[0] = '\0'; /* Unset */ 381 c->x86_model_id[0] = '\0'; /* Unset */
374 c->x86_max_cores = 1; 382 c->x86_max_cores = 1;
383 c->x86_clflush_size = 32;
375 memset(&c->x86_capability, 0, sizeof c->x86_capability); 384 memset(&c->x86_capability, 0, sizeof c->x86_capability);
376 385
377 if (!have_cpuid_p()) { 386 if (!have_cpuid_p()) {
@@ -591,42 +600,24 @@ void __init early_cpu_init(void)
591 disable_pse = 1; 600 disable_pse = 1;
592#endif 601#endif
593} 602}
594/* 603
595 * cpu_init() initializes state that is per-CPU. Some data is already 604/* Make sure %gs is initialized properly in idle threads */
596 * initialized (naturally) in the bootstrap process, such as the GDT 605struct pt_regs * __devinit idle_regs(struct pt_regs *regs)
597 * and IDT. We reload them nevertheless, this function acts as a
598 * 'CPU state barrier', nothing should get across.
599 */
600void __cpuinit cpu_init(void)
601{ 606{
602 int cpu = smp_processor_id(); 607 memset(regs, 0, sizeof(struct pt_regs));
603 struct tss_struct * t = &per_cpu(init_tss, cpu); 608 regs->xgs = __KERNEL_PDA;
604 struct thread_struct *thread = &current->thread; 609 return regs;
605 struct desc_struct *gdt; 610}
606 __u32 stk16_off = (__u32)&per_cpu(cpu_16bit_stack, cpu);
607 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
608 611
609 if (cpu_test_and_set(cpu, cpu_initialized)) { 612static __cpuinit int alloc_gdt(int cpu)
610 printk(KERN_WARNING "CPU#%d already initialized!\n", cpu); 613{
611 for (;;) local_irq_enable(); 614 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
612 } 615 struct desc_struct *gdt;
613 printk(KERN_INFO "Initializing CPU#%d\n", cpu); 616 struct i386_pda *pda;
614 617
615 if (cpu_has_vme || cpu_has_tsc || cpu_has_de) 618 gdt = (struct desc_struct *)cpu_gdt_descr->address;
616 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE); 619 pda = cpu_pda(cpu);
617 if (tsc_disable && cpu_has_tsc) {
618 printk(KERN_NOTICE "Disabling TSC...\n");
619 /**** FIX-HPA: DOES THIS REALLY BELONG HERE? ****/
620 clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
621 set_in_cr4(X86_CR4_TSD);
622 }
623 620
624 /* The CPU hotplug case */
625 if (cpu_gdt_descr->address) {
626 gdt = (struct desc_struct *)cpu_gdt_descr->address;
627 memset(gdt, 0, PAGE_SIZE);
628 goto old_gdt;
629 }
630 /* 621 /*
631 * This is a horrible hack to allocate the GDT. The problem 622 * This is a horrible hack to allocate the GDT. The problem
632 * is that cpu_init() is called really early for the boot CPU 623 * is that cpu_init() is called really early for the boot CPU
@@ -634,43 +625,130 @@ void __cpuinit cpu_init(void)
634 * CPUs, when bootmem will have gone away 625 * CPUs, when bootmem will have gone away
635 */ 626 */
636 if (NODE_DATA(0)->bdata->node_bootmem_map) { 627 if (NODE_DATA(0)->bdata->node_bootmem_map) {
637 gdt = (struct desc_struct *)alloc_bootmem_pages(PAGE_SIZE); 628 BUG_ON(gdt != NULL || pda != NULL);
638 /* alloc_bootmem_pages panics on failure, so no check */ 629
630 gdt = alloc_bootmem_pages(PAGE_SIZE);
631 pda = alloc_bootmem(sizeof(*pda));
632 /* alloc_bootmem(_pages) panics on failure, so no check */
633
639 memset(gdt, 0, PAGE_SIZE); 634 memset(gdt, 0, PAGE_SIZE);
635 memset(pda, 0, sizeof(*pda));
640 } else { 636 } else {
641 gdt = (struct desc_struct *)get_zeroed_page(GFP_KERNEL); 637 /* GDT and PDA might already have been allocated if
642 if (unlikely(!gdt)) { 638 this is a CPU hotplug re-insertion. */
643 printk(KERN_CRIT "CPU%d failed to allocate GDT\n", cpu); 639 if (gdt == NULL)
644 for (;;) 640 gdt = (struct desc_struct *)get_zeroed_page(GFP_KERNEL);
645 local_irq_enable(); 641
642 if (pda == NULL)
643 pda = kmalloc_node(sizeof(*pda), GFP_KERNEL, cpu_to_node(cpu));
644
645 if (unlikely(!gdt || !pda)) {
646 free_pages((unsigned long)gdt, 0);
647 kfree(pda);
648 return 0;
646 } 649 }
647 } 650 }
648old_gdt: 651
652 cpu_gdt_descr->address = (unsigned long)gdt;
653 cpu_pda(cpu) = pda;
654
655 return 1;
656}
657
658/* Initial PDA used by boot CPU */
659struct i386_pda boot_pda = {
660 ._pda = &boot_pda,
661 .cpu_number = 0,
662 .pcurrent = &init_task,
663};
664
665static inline void set_kernel_gs(void)
666{
667 /* Set %gs for this CPU's PDA. Memory clobber is to create a
668 barrier with respect to any PDA operations, so the compiler
669 doesn't move any before here. */
670 asm volatile ("mov %0, %%gs" : : "r" (__KERNEL_PDA) : "memory");
671}
672
673/* Initialize the CPU's GDT and PDA. The boot CPU does this for
674 itself, but secondaries find this done for them. */
675__cpuinit int init_gdt(int cpu, struct task_struct *idle)
676{
677 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
678 struct desc_struct *gdt;
679 struct i386_pda *pda;
680
681 /* For non-boot CPUs, the GDT and PDA should already have been
682 allocated. */
683 if (!alloc_gdt(cpu)) {
684 printk(KERN_CRIT "CPU%d failed to allocate GDT or PDA\n", cpu);
685 return 0;
686 }
687
688 gdt = (struct desc_struct *)cpu_gdt_descr->address;
689 pda = cpu_pda(cpu);
690
691 BUG_ON(gdt == NULL || pda == NULL);
692
649 /* 693 /*
650 * Initialize the per-CPU GDT with the boot GDT, 694 * Initialize the per-CPU GDT with the boot GDT,
651 * and set up the GDT descriptor: 695 * and set up the GDT descriptor:
652 */ 696 */
653 memcpy(gdt, cpu_gdt_table, GDT_SIZE); 697 memcpy(gdt, cpu_gdt_table, GDT_SIZE);
698 cpu_gdt_descr->size = GDT_SIZE - 1;
654 699
655 /* Set up GDT entry for 16bit stack */ 700 pack_descriptor((u32 *)&gdt[GDT_ENTRY_PDA].a,
656 *(__u64 *)(&gdt[GDT_ENTRY_ESPFIX_SS]) |= 701 (u32 *)&gdt[GDT_ENTRY_PDA].b,
657 ((((__u64)stk16_off) << 16) & 0x000000ffffff0000ULL) | 702 (unsigned long)pda, sizeof(*pda) - 1,
658 ((((__u64)stk16_off) << 32) & 0xff00000000000000ULL) | 703 0x80 | DESCTYPE_S | 0x2, 0); /* present read-write data segment */
659 (CPU_16BIT_STACK_SIZE - 1);
660 704
661 cpu_gdt_descr->size = GDT_SIZE - 1; 705 memset(pda, 0, sizeof(*pda));
662 cpu_gdt_descr->address = (unsigned long)gdt; 706 pda->_pda = pda;
707 pda->cpu_number = cpu;
708 pda->pcurrent = idle;
709
710 return 1;
711}
712
713/* Common CPU init for both boot and secondary CPUs */
714static void __cpuinit _cpu_init(int cpu, struct task_struct *curr)
715{
716 struct tss_struct * t = &per_cpu(init_tss, cpu);
717 struct thread_struct *thread = &curr->thread;
718 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
663 719
720 /* Reinit these anyway, even if they've already been done (on
721 the boot CPU, this will transition from the boot gdt+pda to
722 the real ones). */
664 load_gdt(cpu_gdt_descr); 723 load_gdt(cpu_gdt_descr);
724 set_kernel_gs();
725
726 if (cpu_test_and_set(cpu, cpu_initialized)) {
727 printk(KERN_WARNING "CPU#%d already initialized!\n", cpu);
728 for (;;) local_irq_enable();
729 }
730
731 printk(KERN_INFO "Initializing CPU#%d\n", cpu);
732
733 if (cpu_has_vme || cpu_has_tsc || cpu_has_de)
734 clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
735 if (tsc_disable && cpu_has_tsc) {
736 printk(KERN_NOTICE "Disabling TSC...\n");
737 /**** FIX-HPA: DOES THIS REALLY BELONG HERE? ****/
738 clear_bit(X86_FEATURE_TSC, boot_cpu_data.x86_capability);
739 set_in_cr4(X86_CR4_TSD);
740 }
741
665 load_idt(&idt_descr); 742 load_idt(&idt_descr);
666 743
667 /* 744 /*
668 * Set up and load the per-CPU TSS and LDT 745 * Set up and load the per-CPU TSS and LDT
669 */ 746 */
670 atomic_inc(&init_mm.mm_count); 747 atomic_inc(&init_mm.mm_count);
671 current->active_mm = &init_mm; 748 curr->active_mm = &init_mm;
672 BUG_ON(current->mm); 749 if (curr->mm)
673 enter_lazy_tlb(&init_mm, current); 750 BUG();
751 enter_lazy_tlb(&init_mm, curr);
674 752
675 load_esp0(t, thread); 753 load_esp0(t, thread);
676 set_tss_desc(cpu,t); 754 set_tss_desc(cpu,t);
@@ -682,8 +760,8 @@ old_gdt:
682 __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss); 760 __set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss);
683#endif 761#endif
684 762
685 /* Clear %fs and %gs. */ 763 /* Clear %fs. */
686 asm volatile ("movl %0, %%fs; movl %0, %%gs" : : "r" (0)); 764 asm volatile ("mov %0, %%fs" : : "r" (0));
687 765
688 /* Clear all 6 debug registers: */ 766 /* Clear all 6 debug registers: */
689 set_debugreg(0, 0); 767 set_debugreg(0, 0);
@@ -701,6 +779,37 @@ old_gdt:
701 mxcsr_feature_mask_init(); 779 mxcsr_feature_mask_init();
702} 780}
703 781
782/* Entrypoint to initialize secondary CPU */
783void __cpuinit secondary_cpu_init(void)
784{
785 int cpu = smp_processor_id();
786 struct task_struct *curr = current;
787
788 _cpu_init(cpu, curr);
789}
790
791/*
792 * cpu_init() initializes state that is per-CPU. Some data is already
793 * initialized (naturally) in the bootstrap process, such as the GDT
794 * and IDT. We reload them nevertheless, this function acts as a
795 * 'CPU state barrier', nothing should get across.
796 */
797void __cpuinit cpu_init(void)
798{
799 int cpu = smp_processor_id();
800 struct task_struct *curr = current;
801
802 /* Set up the real GDT and PDA, so we can transition from the
803 boot versions. */
804 if (!init_gdt(cpu, curr)) {
805 /* failed to allocate something; not much we can do... */
806 for (;;)
807 local_irq_enable();
808 }
809
810 _cpu_init(cpu, curr);
811}
812
704#ifdef CONFIG_HOTPLUG_CPU 813#ifdef CONFIG_HOTPLUG_CPU
705void __cpuinit cpu_uninit(void) 814void __cpuinit cpu_uninit(void)
706{ 815{
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
index 94a95aa5227e..56fe26584957 100644
--- a/arch/i386/kernel/cpu/intel.c
+++ b/arch/i386/kernel/cpu/intel.c
@@ -107,7 +107,7 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
107 * Note that the workaround only should be initialized once... 107 * Note that the workaround only should be initialized once...
108 */ 108 */
109 c->f00f_bug = 0; 109 c->f00f_bug = 0;
110 if ( c->x86 == 5 ) { 110 if (!paravirt_enabled() && c->x86 == 5) {
111 static int f00f_workaround_enabled = 0; 111 static int f00f_workaround_enabled = 0;
112 112
113 c->f00f_bug = 1; 113 c->f00f_bug = 1;
@@ -195,8 +195,16 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
195 if ((c->x86 == 0xf && c->x86_model >= 0x03) || 195 if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
196 (c->x86 == 0x6 && c->x86_model >= 0x0e)) 196 (c->x86 == 0x6 && c->x86_model >= 0x0e))
197 set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability); 197 set_bit(X86_FEATURE_CONSTANT_TSC, c->x86_capability);
198}
199 198
199 if (cpu_has_ds) {
200 unsigned int l1;
201 rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
202 if (!(l1 & (1<<11)))
203 set_bit(X86_FEATURE_BTS, c->x86_capability);
204 if (!(l1 & (1<<12)))
205 set_bit(X86_FEATURE_PEBS, c->x86_capability);
206 }
207}
200 208
201static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 * c, unsigned int size) 209static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 * c, unsigned int size)
202{ 210{
diff --git a/arch/i386/kernel/cpu/intel_cacheinfo.c b/arch/i386/kernel/cpu/intel_cacheinfo.c
index 5c43be47587f..80b4c5d421b1 100644
--- a/arch/i386/kernel/cpu/intel_cacheinfo.c
+++ b/arch/i386/kernel/cpu/intel_cacheinfo.c
@@ -480,12 +480,10 @@ static int __cpuinit detect_cache_attributes(unsigned int cpu)
480 if (num_cache_leaves == 0) 480 if (num_cache_leaves == 0)
481 return -ENOENT; 481 return -ENOENT;
482 482
483 cpuid4_info[cpu] = kmalloc( 483 cpuid4_info[cpu] = kzalloc(
484 sizeof(struct _cpuid4_info) * num_cache_leaves, GFP_KERNEL); 484 sizeof(struct _cpuid4_info) * num_cache_leaves, GFP_KERNEL);
485 if (unlikely(cpuid4_info[cpu] == NULL)) 485 if (unlikely(cpuid4_info[cpu] == NULL))
486 return -ENOMEM; 486 return -ENOMEM;
487 memset(cpuid4_info[cpu], 0,
488 sizeof(struct _cpuid4_info) * num_cache_leaves);
489 487
490 oldmask = current->cpus_allowed; 488 oldmask = current->cpus_allowed;
491 retval = set_cpus_allowed(current, cpumask_of_cpu(cpu)); 489 retval = set_cpus_allowed(current, cpumask_of_cpu(cpu));
@@ -658,17 +656,14 @@ static int __cpuinit cpuid4_cache_sysfs_init(unsigned int cpu)
658 return -ENOENT; 656 return -ENOENT;
659 657
660 /* Allocate all required memory */ 658 /* Allocate all required memory */
661 cache_kobject[cpu] = kmalloc(sizeof(struct kobject), GFP_KERNEL); 659 cache_kobject[cpu] = kzalloc(sizeof(struct kobject), GFP_KERNEL);
662 if (unlikely(cache_kobject[cpu] == NULL)) 660 if (unlikely(cache_kobject[cpu] == NULL))
663 goto err_out; 661 goto err_out;
664 memset(cache_kobject[cpu], 0, sizeof(struct kobject));
665 662
666 index_kobject[cpu] = kmalloc( 663 index_kobject[cpu] = kzalloc(
667 sizeof(struct _index_kobject ) * num_cache_leaves, GFP_KERNEL); 664 sizeof(struct _index_kobject ) * num_cache_leaves, GFP_KERNEL);
668 if (unlikely(index_kobject[cpu] == NULL)) 665 if (unlikely(index_kobject[cpu] == NULL))
669 goto err_out; 666 goto err_out;
670 memset(index_kobject[cpu], 0,
671 sizeof(struct _index_kobject) * num_cache_leaves);
672 667
673 return 0; 668 return 0;
674 669
diff --git a/arch/i386/kernel/cpu/mcheck/therm_throt.c b/arch/i386/kernel/cpu/mcheck/therm_throt.c
index bad8b4420709..065005c3f168 100644
--- a/arch/i386/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/i386/kernel/cpu/mcheck/therm_throt.c
@@ -116,7 +116,6 @@ static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev)
116 return sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group); 116 return sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group);
117} 117}
118 118
119#ifdef CONFIG_HOTPLUG_CPU
120static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev) 119static __cpuinit void thermal_throttle_remove_dev(struct sys_device *sys_dev)
121{ 120{
122 return sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group); 121 return sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group);
@@ -153,7 +152,6 @@ static struct notifier_block thermal_throttle_cpu_notifier =
153{ 152{
154 .notifier_call = thermal_throttle_cpu_callback, 153 .notifier_call = thermal_throttle_cpu_callback,
155}; 154};
156#endif /* CONFIG_HOTPLUG_CPU */
157 155
158static __init int thermal_throttle_init_device(void) 156static __init int thermal_throttle_init_device(void)
159{ 157{
diff --git a/arch/i386/kernel/cpu/mtrr/Makefile b/arch/i386/kernel/cpu/mtrr/Makefile
index a25b701ab84e..191fc0533649 100644
--- a/arch/i386/kernel/cpu/mtrr/Makefile
+++ b/arch/i386/kernel/cpu/mtrr/Makefile
@@ -1,5 +1,3 @@
1obj-y := main.o if.o generic.o state.o 1obj-y := main.o if.o generic.o state.o
2obj-y += amd.o 2obj-$(CONFIG_X86_32) += amd.o cyrix.o centaur.o
3obj-y += cyrix.o
4obj-y += centaur.o
5 3
diff --git a/arch/i386/kernel/cpu/mtrr/amd.c b/arch/i386/kernel/cpu/mtrr/amd.c
index 1a1e04b6fd00..0949cdbf848a 100644
--- a/arch/i386/kernel/cpu/mtrr/amd.c
+++ b/arch/i386/kernel/cpu/mtrr/amd.c
@@ -7,7 +7,7 @@
7 7
8static void 8static void
9amd_get_mtrr(unsigned int reg, unsigned long *base, 9amd_get_mtrr(unsigned int reg, unsigned long *base,
10 unsigned int *size, mtrr_type * type) 10 unsigned long *size, mtrr_type * type)
11{ 11{
12 unsigned long low, high; 12 unsigned long low, high;
13 13
diff --git a/arch/i386/kernel/cpu/mtrr/centaur.c b/arch/i386/kernel/cpu/mtrr/centaur.c
index 33f00ac314ef..cb9aa3a7a7ab 100644
--- a/arch/i386/kernel/cpu/mtrr/centaur.c
+++ b/arch/i386/kernel/cpu/mtrr/centaur.c
@@ -17,7 +17,7 @@ static u8 centaur_mcr_type; /* 0 for winchip, 1 for winchip2 */
17 */ 17 */
18 18
19static int 19static int
20centaur_get_free_region(unsigned long base, unsigned long size) 20centaur_get_free_region(unsigned long base, unsigned long size, int replace_reg)
21/* [SUMMARY] Get a free MTRR. 21/* [SUMMARY] Get a free MTRR.
22 <base> The starting (base) address of the region. 22 <base> The starting (base) address of the region.
23 <size> The size (in bytes) of the region. 23 <size> The size (in bytes) of the region.
@@ -26,10 +26,11 @@ centaur_get_free_region(unsigned long base, unsigned long size)
26{ 26{
27 int i, max; 27 int i, max;
28 mtrr_type ltype; 28 mtrr_type ltype;
29 unsigned long lbase; 29 unsigned long lbase, lsize;
30 unsigned int lsize;
31 30
32 max = num_var_ranges; 31 max = num_var_ranges;
32 if (replace_reg >= 0 && replace_reg < max)
33 return replace_reg;
33 for (i = 0; i < max; ++i) { 34 for (i = 0; i < max; ++i) {
34 if (centaur_mcr_reserved & (1 << i)) 35 if (centaur_mcr_reserved & (1 << i))
35 continue; 36 continue;
@@ -49,7 +50,7 @@ mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi)
49 50
50static void 51static void
51centaur_get_mcr(unsigned int reg, unsigned long *base, 52centaur_get_mcr(unsigned int reg, unsigned long *base,
52 unsigned int *size, mtrr_type * type) 53 unsigned long *size, mtrr_type * type)
53{ 54{
54 *base = centaur_mcr[reg].high >> PAGE_SHIFT; 55 *base = centaur_mcr[reg].high >> PAGE_SHIFT;
55 *size = -(centaur_mcr[reg].low & 0xfffff000) >> PAGE_SHIFT; 56 *size = -(centaur_mcr[reg].low & 0xfffff000) >> PAGE_SHIFT;
diff --git a/arch/i386/kernel/cpu/mtrr/cyrix.c b/arch/i386/kernel/cpu/mtrr/cyrix.c
index 9027a987006b..0737a596db43 100644
--- a/arch/i386/kernel/cpu/mtrr/cyrix.c
+++ b/arch/i386/kernel/cpu/mtrr/cyrix.c
@@ -9,7 +9,7 @@ int arr3_protected;
9 9
10static void 10static void
11cyrix_get_arr(unsigned int reg, unsigned long *base, 11cyrix_get_arr(unsigned int reg, unsigned long *base,
12 unsigned int *size, mtrr_type * type) 12 unsigned long *size, mtrr_type * type)
13{ 13{
14 unsigned long flags; 14 unsigned long flags;
15 unsigned char arr, ccr3, rcr, shift; 15 unsigned char arr, ccr3, rcr, shift;
@@ -77,7 +77,7 @@ cyrix_get_arr(unsigned int reg, unsigned long *base,
77} 77}
78 78
79static int 79static int
80cyrix_get_free_region(unsigned long base, unsigned long size) 80cyrix_get_free_region(unsigned long base, unsigned long size, int replace_reg)
81/* [SUMMARY] Get a free ARR. 81/* [SUMMARY] Get a free ARR.
82 <base> The starting (base) address of the region. 82 <base> The starting (base) address of the region.
83 <size> The size (in bytes) of the region. 83 <size> The size (in bytes) of the region.
@@ -86,9 +86,24 @@ cyrix_get_free_region(unsigned long base, unsigned long size)
86{ 86{
87 int i; 87 int i;
88 mtrr_type ltype; 88 mtrr_type ltype;
89 unsigned long lbase; 89 unsigned long lbase, lsize;
90 unsigned int lsize;
91 90
91 switch (replace_reg) {
92 case 7:
93 if (size < 0x40)
94 break;
95 case 6:
96 case 5:
97 case 4:
98 return replace_reg;
99 case 3:
100 if (arr3_protected)
101 break;
102 case 2:
103 case 1:
104 case 0:
105 return replace_reg;
106 }
92 /* If we are to set up a region >32M then look at ARR7 immediately */ 107 /* If we are to set up a region >32M then look at ARR7 immediately */
93 if (size > 0x2000) { 108 if (size > 0x2000) {
94 cyrix_get_arr(7, &lbase, &lsize, &ltype); 109 cyrix_get_arr(7, &lbase, &lsize, &ltype);
@@ -214,7 +229,7 @@ static void cyrix_set_arr(unsigned int reg, unsigned long base,
214 229
215typedef struct { 230typedef struct {
216 unsigned long base; 231 unsigned long base;
217 unsigned int size; 232 unsigned long size;
218 mtrr_type type; 233 mtrr_type type;
219} arr_state_t; 234} arr_state_t;
220 235
diff --git a/arch/i386/kernel/cpu/mtrr/generic.c b/arch/i386/kernel/cpu/mtrr/generic.c
index 0b61eed8bbd8..f77fc53db654 100644
--- a/arch/i386/kernel/cpu/mtrr/generic.c
+++ b/arch/i386/kernel/cpu/mtrr/generic.c
@@ -3,6 +3,7 @@
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/slab.h> 4#include <linux/slab.h>
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <linux/module.h>
6#include <asm/io.h> 7#include <asm/io.h>
7#include <asm/mtrr.h> 8#include <asm/mtrr.h>
8#include <asm/msr.h> 9#include <asm/msr.h>
@@ -15,12 +16,19 @@ struct mtrr_state {
15 struct mtrr_var_range *var_ranges; 16 struct mtrr_var_range *var_ranges;
16 mtrr_type fixed_ranges[NUM_FIXED_RANGES]; 17 mtrr_type fixed_ranges[NUM_FIXED_RANGES];
17 unsigned char enabled; 18 unsigned char enabled;
19 unsigned char have_fixed;
18 mtrr_type def_type; 20 mtrr_type def_type;
19}; 21};
20 22
21static unsigned long smp_changes_mask; 23static unsigned long smp_changes_mask;
22static struct mtrr_state mtrr_state = {}; 24static struct mtrr_state mtrr_state = {};
23 25
26#undef MODULE_PARAM_PREFIX
27#define MODULE_PARAM_PREFIX "mtrr."
28
29static __initdata int mtrr_show;
30module_param_named(show, mtrr_show, bool, 0);
31
24/* Get the MSR pair relating to a var range */ 32/* Get the MSR pair relating to a var range */
25static void __init 33static void __init
26get_mtrr_var_range(unsigned int index, struct mtrr_var_range *vr) 34get_mtrr_var_range(unsigned int index, struct mtrr_var_range *vr)
@@ -43,6 +51,14 @@ get_fixed_ranges(mtrr_type * frs)
43 rdmsr(MTRRfix4K_C0000_MSR + i, p[6 + i * 2], p[7 + i * 2]); 51 rdmsr(MTRRfix4K_C0000_MSR + i, p[6 + i * 2], p[7 + i * 2]);
44} 52}
45 53
54static void __init print_fixed(unsigned base, unsigned step, const mtrr_type*types)
55{
56 unsigned i;
57
58 for (i = 0; i < 8; ++i, ++types, base += step)
59 printk(KERN_INFO "MTRR %05X-%05X %s\n", base, base + step - 1, mtrr_attrib_to_str(*types));
60}
61
46/* Grab all of the MTRR state for this CPU into *state */ 62/* Grab all of the MTRR state for this CPU into *state */
47void __init get_mtrr_state(void) 63void __init get_mtrr_state(void)
48{ 64{
@@ -58,13 +74,49 @@ void __init get_mtrr_state(void)
58 } 74 }
59 vrs = mtrr_state.var_ranges; 75 vrs = mtrr_state.var_ranges;
60 76
77 rdmsr(MTRRcap_MSR, lo, dummy);
78 mtrr_state.have_fixed = (lo >> 8) & 1;
79
61 for (i = 0; i < num_var_ranges; i++) 80 for (i = 0; i < num_var_ranges; i++)
62 get_mtrr_var_range(i, &vrs[i]); 81 get_mtrr_var_range(i, &vrs[i]);
63 get_fixed_ranges(mtrr_state.fixed_ranges); 82 if (mtrr_state.have_fixed)
83 get_fixed_ranges(mtrr_state.fixed_ranges);
64 84
65 rdmsr(MTRRdefType_MSR, lo, dummy); 85 rdmsr(MTRRdefType_MSR, lo, dummy);
66 mtrr_state.def_type = (lo & 0xff); 86 mtrr_state.def_type = (lo & 0xff);
67 mtrr_state.enabled = (lo & 0xc00) >> 10; 87 mtrr_state.enabled = (lo & 0xc00) >> 10;
88
89 if (mtrr_show) {
90 int high_width;
91
92 printk(KERN_INFO "MTRR default type: %s\n", mtrr_attrib_to_str(mtrr_state.def_type));
93 if (mtrr_state.have_fixed) {
94 printk(KERN_INFO "MTRR fixed ranges %sabled:\n",
95 mtrr_state.enabled & 1 ? "en" : "dis");
96 print_fixed(0x00000, 0x10000, mtrr_state.fixed_ranges + 0);
97 for (i = 0; i < 2; ++i)
98 print_fixed(0x80000 + i * 0x20000, 0x04000, mtrr_state.fixed_ranges + (i + 1) * 8);
99 for (i = 0; i < 8; ++i)
100 print_fixed(0xC0000 + i * 0x08000, 0x01000, mtrr_state.fixed_ranges + (i + 3) * 8);
101 }
102 printk(KERN_INFO "MTRR variable ranges %sabled:\n",
103 mtrr_state.enabled & 2 ? "en" : "dis");
104 high_width = ((size_or_mask ? ffs(size_or_mask) - 1 : 32) - (32 - PAGE_SHIFT) + 3) / 4;
105 for (i = 0; i < num_var_ranges; ++i) {
106 if (mtrr_state.var_ranges[i].mask_lo & (1 << 11))
107 printk(KERN_INFO "MTRR %u base %0*X%05X000 mask %0*X%05X000 %s\n",
108 i,
109 high_width,
110 mtrr_state.var_ranges[i].base_hi,
111 mtrr_state.var_ranges[i].base_lo >> 12,
112 high_width,
113 mtrr_state.var_ranges[i].mask_hi,
114 mtrr_state.var_ranges[i].mask_lo >> 12,
115 mtrr_attrib_to_str(mtrr_state.var_ranges[i].base_lo & 0xff));
116 else
117 printk(KERN_INFO "MTRR %u disabled\n", i);
118 }
119 }
68} 120}
69 121
70/* Some BIOS's are fucked and don't set all MTRRs the same! */ 122/* Some BIOS's are fucked and don't set all MTRRs the same! */
@@ -95,7 +147,7 @@ void mtrr_wrmsr(unsigned msr, unsigned a, unsigned b)
95 smp_processor_id(), msr, a, b); 147 smp_processor_id(), msr, a, b);
96} 148}
97 149
98int generic_get_free_region(unsigned long base, unsigned long size) 150int generic_get_free_region(unsigned long base, unsigned long size, int replace_reg)
99/* [SUMMARY] Get a free MTRR. 151/* [SUMMARY] Get a free MTRR.
100 <base> The starting (base) address of the region. 152 <base> The starting (base) address of the region.
101 <size> The size (in bytes) of the region. 153 <size> The size (in bytes) of the region.
@@ -104,10 +156,11 @@ int generic_get_free_region(unsigned long base, unsigned long size)
104{ 156{
105 int i, max; 157 int i, max;
106 mtrr_type ltype; 158 mtrr_type ltype;
107 unsigned long lbase; 159 unsigned long lbase, lsize;
108 unsigned lsize;
109 160
110 max = num_var_ranges; 161 max = num_var_ranges;
162 if (replace_reg >= 0 && replace_reg < max)
163 return replace_reg;
111 for (i = 0; i < max; ++i) { 164 for (i = 0; i < max; ++i) {
112 mtrr_if->get(i, &lbase, &lsize, &ltype); 165 mtrr_if->get(i, &lbase, &lsize, &ltype);
113 if (lsize == 0) 166 if (lsize == 0)
@@ -117,7 +170,7 @@ int generic_get_free_region(unsigned long base, unsigned long size)
117} 170}
118 171
119static void generic_get_mtrr(unsigned int reg, unsigned long *base, 172static void generic_get_mtrr(unsigned int reg, unsigned long *base,
120 unsigned int *size, mtrr_type * type) 173 unsigned long *size, mtrr_type *type)
121{ 174{
122 unsigned int mask_lo, mask_hi, base_lo, base_hi; 175 unsigned int mask_lo, mask_hi, base_lo, base_hi;
123 176
@@ -202,7 +255,9 @@ static int set_mtrr_var_ranges(unsigned int index, struct mtrr_var_range *vr)
202 return changed; 255 return changed;
203} 256}
204 257
205static unsigned long set_mtrr_state(u32 deftype_lo, u32 deftype_hi) 258static u32 deftype_lo, deftype_hi;
259
260static unsigned long set_mtrr_state(void)
206/* [SUMMARY] Set the MTRR state for this CPU. 261/* [SUMMARY] Set the MTRR state for this CPU.
207 <state> The MTRR state information to read. 262 <state> The MTRR state information to read.
208 <ctxt> Some relevant CPU context. 263 <ctxt> Some relevant CPU context.
@@ -217,14 +272,14 @@ static unsigned long set_mtrr_state(u32 deftype_lo, u32 deftype_hi)
217 if (set_mtrr_var_ranges(i, &mtrr_state.var_ranges[i])) 272 if (set_mtrr_var_ranges(i, &mtrr_state.var_ranges[i]))
218 change_mask |= MTRR_CHANGE_MASK_VARIABLE; 273 change_mask |= MTRR_CHANGE_MASK_VARIABLE;
219 274
220 if (set_fixed_ranges(mtrr_state.fixed_ranges)) 275 if (mtrr_state.have_fixed && set_fixed_ranges(mtrr_state.fixed_ranges))
221 change_mask |= MTRR_CHANGE_MASK_FIXED; 276 change_mask |= MTRR_CHANGE_MASK_FIXED;
222 277
223 /* Set_mtrr_restore restores the old value of MTRRdefType, 278 /* Set_mtrr_restore restores the old value of MTRRdefType,
224 so to set it we fiddle with the saved value */ 279 so to set it we fiddle with the saved value */
225 if ((deftype_lo & 0xff) != mtrr_state.def_type 280 if ((deftype_lo & 0xff) != mtrr_state.def_type
226 || ((deftype_lo & 0xc00) >> 10) != mtrr_state.enabled) { 281 || ((deftype_lo & 0xc00) >> 10) != mtrr_state.enabled) {
227 deftype_lo |= (mtrr_state.def_type | mtrr_state.enabled << 10); 282 deftype_lo = (deftype_lo & ~0xcff) | mtrr_state.def_type | (mtrr_state.enabled << 10);
228 change_mask |= MTRR_CHANGE_MASK_DEFTYPE; 283 change_mask |= MTRR_CHANGE_MASK_DEFTYPE;
229 } 284 }
230 285
@@ -233,7 +288,6 @@ static unsigned long set_mtrr_state(u32 deftype_lo, u32 deftype_hi)
233 288
234 289
235static unsigned long cr4 = 0; 290static unsigned long cr4 = 0;
236static u32 deftype_lo, deftype_hi;
237static DEFINE_SPINLOCK(set_atomicity_lock); 291static DEFINE_SPINLOCK(set_atomicity_lock);
238 292
239/* 293/*
@@ -271,7 +325,7 @@ static void prepare_set(void) __acquires(set_atomicity_lock)
271 rdmsr(MTRRdefType_MSR, deftype_lo, deftype_hi); 325 rdmsr(MTRRdefType_MSR, deftype_lo, deftype_hi);
272 326
273 /* Disable MTRRs, and set the default type to uncached */ 327 /* Disable MTRRs, and set the default type to uncached */
274 mtrr_wrmsr(MTRRdefType_MSR, deftype_lo & 0xf300UL, deftype_hi); 328 mtrr_wrmsr(MTRRdefType_MSR, deftype_lo & ~0xcff, deftype_hi);
275} 329}
276 330
277static void post_set(void) __releases(set_atomicity_lock) 331static void post_set(void) __releases(set_atomicity_lock)
@@ -300,7 +354,7 @@ static void generic_set_all(void)
300 prepare_set(); 354 prepare_set();
301 355
302 /* Actually set the state */ 356 /* Actually set the state */
303 mask = set_mtrr_state(deftype_lo,deftype_hi); 357 mask = set_mtrr_state();
304 358
305 post_set(); 359 post_set();
306 local_irq_restore(flags); 360 local_irq_restore(flags);
@@ -366,7 +420,7 @@ int generic_validate_add_page(unsigned long base, unsigned long size, unsigned i
366 printk(KERN_WARNING "mtrr: base(0x%lx000) is not 4 MiB aligned\n", base); 420 printk(KERN_WARNING "mtrr: base(0x%lx000) is not 4 MiB aligned\n", base);
367 return -EINVAL; 421 return -EINVAL;
368 } 422 }
369 if (!(base + size < 0x70000000 || base > 0x7003FFFF) && 423 if (!(base + size < 0x70000 || base > 0x7003F) &&
370 (type == MTRR_TYPE_WRCOMB 424 (type == MTRR_TYPE_WRCOMB
371 || type == MTRR_TYPE_WRBACK)) { 425 || type == MTRR_TYPE_WRBACK)) {
372 printk(KERN_WARNING "mtrr: writable mtrr between 0x70000000 and 0x7003FFFF may hang the CPU.\n"); 426 printk(KERN_WARNING "mtrr: writable mtrr between 0x70000000 and 0x7003FFFF may hang the CPU.\n");
diff --git a/arch/i386/kernel/cpu/mtrr/if.c b/arch/i386/kernel/cpu/mtrr/if.c
index 5ac051bb9d55..5ae1705eafa6 100644
--- a/arch/i386/kernel/cpu/mtrr/if.c
+++ b/arch/i386/kernel/cpu/mtrr/if.c
@@ -17,7 +17,7 @@ extern unsigned int *usage_table;
17 17
18#define FILE_FCOUNT(f) (((struct seq_file *)((f)->private_data))->private) 18#define FILE_FCOUNT(f) (((struct seq_file *)((f)->private_data))->private)
19 19
20static char *mtrr_strings[MTRR_NUM_TYPES] = 20static const char *const mtrr_strings[MTRR_NUM_TYPES] =
21{ 21{
22 "uncachable", /* 0 */ 22 "uncachable", /* 0 */
23 "write-combining", /* 1 */ 23 "write-combining", /* 1 */
@@ -28,7 +28,7 @@ static char *mtrr_strings[MTRR_NUM_TYPES] =
28 "write-back", /* 6 */ 28 "write-back", /* 6 */
29}; 29};
30 30
31char *mtrr_attrib_to_str(int x) 31const char *mtrr_attrib_to_str(int x)
32{ 32{
33 return (x <= 6) ? mtrr_strings[x] : "?"; 33 return (x <= 6) ? mtrr_strings[x] : "?";
34} 34}
@@ -44,10 +44,9 @@ mtrr_file_add(unsigned long base, unsigned long size,
44 44
45 max = num_var_ranges; 45 max = num_var_ranges;
46 if (fcount == NULL) { 46 if (fcount == NULL) {
47 fcount = kmalloc(max * sizeof *fcount, GFP_KERNEL); 47 fcount = kzalloc(max * sizeof *fcount, GFP_KERNEL);
48 if (!fcount) 48 if (!fcount)
49 return -ENOMEM; 49 return -ENOMEM;
50 memset(fcount, 0, max * sizeof *fcount);
51 FILE_FCOUNT(file) = fcount; 50 FILE_FCOUNT(file) = fcount;
52 } 51 }
53 if (!page) { 52 if (!page) {
@@ -155,6 +154,7 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
155{ 154{
156 int err = 0; 155 int err = 0;
157 mtrr_type type; 156 mtrr_type type;
157 unsigned long size;
158 struct mtrr_sentry sentry; 158 struct mtrr_sentry sentry;
159 struct mtrr_gentry gentry; 159 struct mtrr_gentry gentry;
160 void __user *arg = (void __user *) __arg; 160 void __user *arg = (void __user *) __arg;
@@ -235,15 +235,15 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
235 case MTRRIOC_GET_ENTRY: 235 case MTRRIOC_GET_ENTRY:
236 if (gentry.regnum >= num_var_ranges) 236 if (gentry.regnum >= num_var_ranges)
237 return -EINVAL; 237 return -EINVAL;
238 mtrr_if->get(gentry.regnum, &gentry.base, &gentry.size, &type); 238 mtrr_if->get(gentry.regnum, &gentry.base, &size, &type);
239 239
240 /* Hide entries that go above 4GB */ 240 /* Hide entries that go above 4GB */
241 if (gentry.base + gentry.size > 0x100000 241 if (gentry.base + size - 1 >= (1UL << (8 * sizeof(gentry.size) - PAGE_SHIFT))
242 || gentry.size == 0x100000) 242 || size >= (1UL << (8 * sizeof(gentry.size) - PAGE_SHIFT)))
243 gentry.base = gentry.size = gentry.type = 0; 243 gentry.base = gentry.size = gentry.type = 0;
244 else { 244 else {
245 gentry.base <<= PAGE_SHIFT; 245 gentry.base <<= PAGE_SHIFT;
246 gentry.size <<= PAGE_SHIFT; 246 gentry.size = size << PAGE_SHIFT;
247 gentry.type = type; 247 gentry.type = type;
248 } 248 }
249 249
@@ -273,8 +273,14 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
273 case MTRRIOC_GET_PAGE_ENTRY: 273 case MTRRIOC_GET_PAGE_ENTRY:
274 if (gentry.regnum >= num_var_ranges) 274 if (gentry.regnum >= num_var_ranges)
275 return -EINVAL; 275 return -EINVAL;
276 mtrr_if->get(gentry.regnum, &gentry.base, &gentry.size, &type); 276 mtrr_if->get(gentry.regnum, &gentry.base, &size, &type);
277 gentry.type = type; 277 /* Hide entries that would overflow */
278 if (size != (__typeof__(gentry.size))size)
279 gentry.base = gentry.size = gentry.type = 0;
280 else {
281 gentry.size = size;
282 gentry.type = type;
283 }
278 break; 284 break;
279 } 285 }
280 286
@@ -353,8 +359,7 @@ static int mtrr_seq_show(struct seq_file *seq, void *offset)
353 char factor; 359 char factor;
354 int i, max, len; 360 int i, max, len;
355 mtrr_type type; 361 mtrr_type type;
356 unsigned long base; 362 unsigned long base, size;
357 unsigned int size;
358 363
359 len = 0; 364 len = 0;
360 max = num_var_ranges; 365 max = num_var_ranges;
@@ -373,7 +378,7 @@ static int mtrr_seq_show(struct seq_file *seq, void *offset)
373 } 378 }
374 /* RED-PEN: base can be > 32bit */ 379 /* RED-PEN: base can be > 32bit */
375 len += seq_printf(seq, 380 len += seq_printf(seq,
376 "reg%02i: base=0x%05lx000 (%4liMB), size=%4i%cB: %s, count=%d\n", 381 "reg%02i: base=0x%05lx000 (%4luMB), size=%4lu%cB: %s, count=%d\n",
377 i, base, base >> (20 - PAGE_SHIFT), size, factor, 382 i, base, base >> (20 - PAGE_SHIFT), size, factor,
378 mtrr_attrib_to_str(type), usage_table[i]); 383 mtrr_attrib_to_str(type), usage_table[i]);
379 } 384 }
diff --git a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
index fff90bda4733..16bb7ea87145 100644
--- a/arch/i386/kernel/cpu/mtrr/main.c
+++ b/arch/i386/kernel/cpu/mtrr/main.c
@@ -59,7 +59,11 @@ struct mtrr_ops * mtrr_if = NULL;
59static void set_mtrr(unsigned int reg, unsigned long base, 59static void set_mtrr(unsigned int reg, unsigned long base,
60 unsigned long size, mtrr_type type); 60 unsigned long size, mtrr_type type);
61 61
62#ifndef CONFIG_X86_64
62extern int arr3_protected; 63extern int arr3_protected;
64#else
65#define arr3_protected 0
66#endif
63 67
64void set_mtrr_ops(struct mtrr_ops * ops) 68void set_mtrr_ops(struct mtrr_ops * ops)
65{ 69{
@@ -168,6 +172,13 @@ static void ipi_handler(void *info)
168 172
169#endif 173#endif
170 174
175static inline int types_compatible(mtrr_type type1, mtrr_type type2) {
176 return type1 == MTRR_TYPE_UNCACHABLE ||
177 type2 == MTRR_TYPE_UNCACHABLE ||
178 (type1 == MTRR_TYPE_WRTHROUGH && type2 == MTRR_TYPE_WRBACK) ||
179 (type1 == MTRR_TYPE_WRBACK && type2 == MTRR_TYPE_WRTHROUGH);
180}
181
171/** 182/**
172 * set_mtrr - update mtrrs on all processors 183 * set_mtrr - update mtrrs on all processors
173 * @reg: mtrr in question 184 * @reg: mtrr in question
@@ -263,8 +274,8 @@ static void set_mtrr(unsigned int reg, unsigned long base,
263 274
264/** 275/**
265 * mtrr_add_page - Add a memory type region 276 * mtrr_add_page - Add a memory type region
266 * @base: Physical base address of region in pages (4 KB) 277 * @base: Physical base address of region in pages (in units of 4 kB!)
267 * @size: Physical size of region in pages (4 KB) 278 * @size: Physical size of region in pages (4 kB)
268 * @type: Type of MTRR desired 279 * @type: Type of MTRR desired
269 * @increment: If this is true do usage counting on the region 280 * @increment: If this is true do usage counting on the region
270 * 281 *
@@ -300,11 +311,9 @@ static void set_mtrr(unsigned int reg, unsigned long base,
300int mtrr_add_page(unsigned long base, unsigned long size, 311int mtrr_add_page(unsigned long base, unsigned long size,
301 unsigned int type, char increment) 312 unsigned int type, char increment)
302{ 313{
303 int i; 314 int i, replace, error;
304 mtrr_type ltype; 315 mtrr_type ltype;
305 unsigned long lbase; 316 unsigned long lbase, lsize;
306 unsigned int lsize;
307 int error;
308 317
309 if (!mtrr_if) 318 if (!mtrr_if)
310 return -ENXIO; 319 return -ENXIO;
@@ -324,12 +333,18 @@ int mtrr_add_page(unsigned long base, unsigned long size,
324 return -ENOSYS; 333 return -ENOSYS;
325 } 334 }
326 335
336 if (!size) {
337 printk(KERN_WARNING "mtrr: zero sized request\n");
338 return -EINVAL;
339 }
340
327 if (base & size_or_mask || size & size_or_mask) { 341 if (base & size_or_mask || size & size_or_mask) {
328 printk(KERN_WARNING "mtrr: base or size exceeds the MTRR width\n"); 342 printk(KERN_WARNING "mtrr: base or size exceeds the MTRR width\n");
329 return -EINVAL; 343 return -EINVAL;
330 } 344 }
331 345
332 error = -EINVAL; 346 error = -EINVAL;
347 replace = -1;
333 348
334 /* No CPU hotplug when we change MTRR entries */ 349 /* No CPU hotplug when we change MTRR entries */
335 lock_cpu_hotplug(); 350 lock_cpu_hotplug();
@@ -337,21 +352,28 @@ int mtrr_add_page(unsigned long base, unsigned long size,
337 mutex_lock(&mtrr_mutex); 352 mutex_lock(&mtrr_mutex);
338 for (i = 0; i < num_var_ranges; ++i) { 353 for (i = 0; i < num_var_ranges; ++i) {
339 mtrr_if->get(i, &lbase, &lsize, &ltype); 354 mtrr_if->get(i, &lbase, &lsize, &ltype);
340 if (base >= lbase + lsize) 355 if (!lsize || base > lbase + lsize - 1 || base + size - 1 < lbase)
341 continue;
342 if ((base < lbase) && (base + size <= lbase))
343 continue; 356 continue;
344 /* At this point we know there is some kind of overlap/enclosure */ 357 /* At this point we know there is some kind of overlap/enclosure */
345 if ((base < lbase) || (base + size > lbase + lsize)) { 358 if (base < lbase || base + size - 1 > lbase + lsize - 1) {
359 if (base <= lbase && base + size - 1 >= lbase + lsize - 1) {
360 /* New region encloses an existing region */
361 if (type == ltype) {
362 replace = replace == -1 ? i : -2;
363 continue;
364 }
365 else if (types_compatible(type, ltype))
366 continue;
367 }
346 printk(KERN_WARNING 368 printk(KERN_WARNING
347 "mtrr: 0x%lx000,0x%lx000 overlaps existing" 369 "mtrr: 0x%lx000,0x%lx000 overlaps existing"
348 " 0x%lx000,0x%x000\n", base, size, lbase, 370 " 0x%lx000,0x%lx000\n", base, size, lbase,
349 lsize); 371 lsize);
350 goto out; 372 goto out;
351 } 373 }
352 /* New region is enclosed by an existing region */ 374 /* New region is enclosed by an existing region */
353 if (ltype != type) { 375 if (ltype != type) {
354 if (type == MTRR_TYPE_UNCACHABLE) 376 if (types_compatible(type, ltype))
355 continue; 377 continue;
356 printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n", 378 printk (KERN_WARNING "mtrr: type mismatch for %lx000,%lx000 old: %s new: %s\n",
357 base, size, mtrr_attrib_to_str(ltype), 379 base, size, mtrr_attrib_to_str(ltype),
@@ -364,10 +386,18 @@ int mtrr_add_page(unsigned long base, unsigned long size,
364 goto out; 386 goto out;
365 } 387 }
366 /* Search for an empty MTRR */ 388 /* Search for an empty MTRR */
367 i = mtrr_if->get_free_region(base, size); 389 i = mtrr_if->get_free_region(base, size, replace);
368 if (i >= 0) { 390 if (i >= 0) {
369 set_mtrr(i, base, size, type); 391 set_mtrr(i, base, size, type);
370 usage_table[i] = 1; 392 if (likely(replace < 0))
393 usage_table[i] = 1;
394 else {
395 usage_table[i] = usage_table[replace] + !!increment;
396 if (unlikely(replace != i)) {
397 set_mtrr(replace, 0, 0, 0);
398 usage_table[replace] = 0;
399 }
400 }
371 } else 401 } else
372 printk(KERN_INFO "mtrr: no more MTRRs available\n"); 402 printk(KERN_INFO "mtrr: no more MTRRs available\n");
373 error = i; 403 error = i;
@@ -455,8 +485,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
455{ 485{
456 int i, max; 486 int i, max;
457 mtrr_type ltype; 487 mtrr_type ltype;
458 unsigned long lbase; 488 unsigned long lbase, lsize;
459 unsigned int lsize;
460 int error = -EINVAL; 489 int error = -EINVAL;
461 490
462 if (!mtrr_if) 491 if (!mtrr_if)
@@ -544,9 +573,11 @@ extern void centaur_init_mtrr(void);
544 573
545static void __init init_ifs(void) 574static void __init init_ifs(void)
546{ 575{
576#ifndef CONFIG_X86_64
547 amd_init_mtrr(); 577 amd_init_mtrr();
548 cyrix_init_mtrr(); 578 cyrix_init_mtrr();
549 centaur_init_mtrr(); 579 centaur_init_mtrr();
580#endif
550} 581}
551 582
552/* The suspend/resume methods are only for CPU without MTRR. CPU using generic 583/* The suspend/resume methods are only for CPU without MTRR. CPU using generic
@@ -555,7 +586,7 @@ static void __init init_ifs(void)
555struct mtrr_value { 586struct mtrr_value {
556 mtrr_type ltype; 587 mtrr_type ltype;
557 unsigned long lbase; 588 unsigned long lbase;
558 unsigned int lsize; 589 unsigned long lsize;
559}; 590};
560 591
561static struct mtrr_value * mtrr_state; 592static struct mtrr_value * mtrr_state;
@@ -565,10 +596,8 @@ static int mtrr_save(struct sys_device * sysdev, pm_message_t state)
565 int i; 596 int i;
566 int size = num_var_ranges * sizeof(struct mtrr_value); 597 int size = num_var_ranges * sizeof(struct mtrr_value);
567 598
568 mtrr_state = kmalloc(size,GFP_ATOMIC); 599 mtrr_state = kzalloc(size,GFP_ATOMIC);
569 if (mtrr_state) 600 if (!mtrr_state)
570 memset(mtrr_state,0,size);
571 else
572 return -ENOMEM; 601 return -ENOMEM;
573 602
574 for (i = 0; i < num_var_ranges; i++) { 603 for (i = 0; i < num_var_ranges; i++) {
diff --git a/arch/i386/kernel/cpu/mtrr/mtrr.h b/arch/i386/kernel/cpu/mtrr/mtrr.h
index 99c9f2682041..d61ea9db6cfe 100644
--- a/arch/i386/kernel/cpu/mtrr/mtrr.h
+++ b/arch/i386/kernel/cpu/mtrr/mtrr.h
@@ -43,15 +43,16 @@ struct mtrr_ops {
43 void (*set_all)(void); 43 void (*set_all)(void);
44 44
45 void (*get)(unsigned int reg, unsigned long *base, 45 void (*get)(unsigned int reg, unsigned long *base,
46 unsigned int *size, mtrr_type * type); 46 unsigned long *size, mtrr_type * type);
47 int (*get_free_region) (unsigned long base, unsigned long size); 47 int (*get_free_region)(unsigned long base, unsigned long size,
48 48 int replace_reg);
49 int (*validate_add_page)(unsigned long base, unsigned long size, 49 int (*validate_add_page)(unsigned long base, unsigned long size,
50 unsigned int type); 50 unsigned int type);
51 int (*have_wrcomb)(void); 51 int (*have_wrcomb)(void);
52}; 52};
53 53
54extern int generic_get_free_region(unsigned long base, unsigned long size); 54extern int generic_get_free_region(unsigned long base, unsigned long size,
55 int replace_reg);
55extern int generic_validate_add_page(unsigned long base, unsigned long size, 56extern int generic_validate_add_page(unsigned long base, unsigned long size,
56 unsigned int type); 57 unsigned int type);
57 58
@@ -62,17 +63,17 @@ extern int positive_have_wrcomb(void);
62/* library functions for processor-specific routines */ 63/* library functions for processor-specific routines */
63struct set_mtrr_context { 64struct set_mtrr_context {
64 unsigned long flags; 65 unsigned long flags;
65 unsigned long deftype_lo;
66 unsigned long deftype_hi;
67 unsigned long cr4val; 66 unsigned long cr4val;
68 unsigned long ccr3; 67 u32 deftype_lo;
68 u32 deftype_hi;
69 u32 ccr3;
69}; 70};
70 71
71struct mtrr_var_range { 72struct mtrr_var_range {
72 unsigned long base_lo; 73 u32 base_lo;
73 unsigned long base_hi; 74 u32 base_hi;
74 unsigned long mask_lo; 75 u32 mask_lo;
75 unsigned long mask_hi; 76 u32 mask_hi;
76}; 77};
77 78
78void set_mtrr_done(struct set_mtrr_context *ctxt); 79void set_mtrr_done(struct set_mtrr_context *ctxt);
@@ -92,6 +93,6 @@ extern struct mtrr_ops * mtrr_if;
92extern unsigned int num_var_ranges; 93extern unsigned int num_var_ranges;
93 94
94void mtrr_state_warn(void); 95void mtrr_state_warn(void);
95char *mtrr_attrib_to_str(int x); 96const char *mtrr_attrib_to_str(int x);
96void mtrr_wrmsr(unsigned, unsigned, unsigned); 97void mtrr_wrmsr(unsigned, unsigned, unsigned);
97 98
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 76aac088a323..6624d8583c42 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -152,9 +152,10 @@ static int show_cpuinfo(struct seq_file *m, void *v)
152 seq_printf(m, " [%d]", i); 152 seq_printf(m, " [%d]", i);
153 } 153 }
154 154
155 seq_printf(m, "\nbogomips\t: %lu.%02lu\n\n", 155 seq_printf(m, "\nbogomips\t: %lu.%02lu\n",
156 c->loops_per_jiffy/(500000/HZ), 156 c->loops_per_jiffy/(500000/HZ),
157 (c->loops_per_jiffy/(5000/HZ)) % 100); 157 (c->loops_per_jiffy/(5000/HZ)) % 100);
158 seq_printf(m, "clflush size\t: %u\n\n", c->x86_clflush_size);
158 159
159 return 0; 160 return 0;
160} 161}
diff --git a/arch/i386/kernel/cpuid.c b/arch/i386/kernel/cpuid.c
index ab0c327e79dc..db6dd20c3589 100644
--- a/arch/i386/kernel/cpuid.c
+++ b/arch/i386/kernel/cpuid.c
@@ -34,7 +34,6 @@
34#include <linux/major.h> 34#include <linux/major.h>
35#include <linux/fs.h> 35#include <linux/fs.h>
36#include <linux/smp_lock.h> 36#include <linux/smp_lock.h>
37#include <linux/fs.h>
38#include <linux/device.h> 37#include <linux/device.h>
39#include <linux/cpu.h> 38#include <linux/cpu.h>
40#include <linux/notifier.h> 39#include <linux/notifier.h>
@@ -167,7 +166,6 @@ static int cpuid_device_create(int i)
167 return err; 166 return err;
168} 167}
169 168
170#ifdef CONFIG_HOTPLUG_CPU
171static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) 169static int cpuid_class_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
172{ 170{
173 unsigned int cpu = (unsigned long)hcpu; 171 unsigned int cpu = (unsigned long)hcpu;
@@ -187,7 +185,6 @@ static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier =
187{ 185{
188 .notifier_call = cpuid_class_cpu_callback, 186 .notifier_call = cpuid_class_cpu_callback,
189}; 187};
190#endif /* !CONFIG_HOTPLUG_CPU */
191 188
192static int __init cpuid_init(void) 189static int __init cpuid_init(void)
193{ 190{
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index 144b43288965..a5e0e990ea95 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -31,68 +31,6 @@
31/* This keeps a track of which one is crashing cpu. */ 31/* This keeps a track of which one is crashing cpu. */
32static int crashing_cpu; 32static int crashing_cpu;
33 33
34static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
35 size_t data_len)
36{
37 struct elf_note note;
38
39 note.n_namesz = strlen(name) + 1;
40 note.n_descsz = data_len;
41 note.n_type = type;
42 memcpy(buf, &note, sizeof(note));
43 buf += (sizeof(note) +3)/4;
44 memcpy(buf, name, note.n_namesz);
45 buf += (note.n_namesz + 3)/4;
46 memcpy(buf, data, note.n_descsz);
47 buf += (note.n_descsz + 3)/4;
48
49 return buf;
50}
51
52static void final_note(u32 *buf)
53{
54 struct elf_note note;
55
56 note.n_namesz = 0;
57 note.n_descsz = 0;
58 note.n_type = 0;
59 memcpy(buf, &note, sizeof(note));
60}
61
62static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
63{
64 struct elf_prstatus prstatus;
65 u32 *buf;
66
67 if ((cpu < 0) || (cpu >= NR_CPUS))
68 return;
69
70 /* Using ELF notes here is opportunistic.
71 * I need a well defined structure format
72 * for the data I pass, and I need tags
73 * on the data to indicate what information I have
74 * squirrelled away. ELF notes happen to provide
75 * all of that, so there is no need to invent something new.
76 */
77 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
78 if (!buf)
79 return;
80 memset(&prstatus, 0, sizeof(prstatus));
81 prstatus.pr_pid = current->pid;
82 elf_core_copy_regs(&prstatus.pr_reg, regs);
83 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
84 sizeof(prstatus));
85 final_note(buf);
86}
87
88static void crash_save_self(struct pt_regs *regs)
89{
90 int cpu;
91
92 cpu = safe_smp_processor_id();
93 crash_save_this_cpu(regs, cpu);
94}
95
96#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) 34#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
97static atomic_t waiting_for_crash_ipi; 35static atomic_t waiting_for_crash_ipi;
98 36
@@ -121,7 +59,7 @@ static int crash_nmi_callback(struct notifier_block *self,
121 crash_fixup_ss_esp(&fixed_regs, regs); 59 crash_fixup_ss_esp(&fixed_regs, regs);
122 regs = &fixed_regs; 60 regs = &fixed_regs;
123 } 61 }
124 crash_save_this_cpu(regs, cpu); 62 crash_save_cpu(regs, cpu);
125 disable_local_APIC(); 63 disable_local_APIC();
126 atomic_dec(&waiting_for_crash_ipi); 64 atomic_dec(&waiting_for_crash_ipi);
127 /* Assume hlt works */ 65 /* Assume hlt works */
@@ -195,5 +133,5 @@ void machine_crash_shutdown(struct pt_regs *regs)
195#if defined(CONFIG_X86_IO_APIC) 133#if defined(CONFIG_X86_IO_APIC)
196 disable_IO_APIC(); 134 disable_IO_APIC();
197#endif 135#endif
198 crash_save_self(regs); 136 crash_save_cpu(regs, safe_smp_processor_id());
199} 137}
diff --git a/arch/i386/kernel/e820.c b/arch/i386/kernel/e820.c
new file mode 100644
index 000000000000..2f7d0a92fd7c
--- /dev/null
+++ b/arch/i386/kernel/e820.c
@@ -0,0 +1,894 @@
1#include <linux/kernel.h>
2#include <linux/types.h>
3#include <linux/init.h>
4#include <linux/bootmem.h>
5#include <linux/ioport.h>
6#include <linux/string.h>
7#include <linux/kexec.h>
8#include <linux/module.h>
9#include <linux/mm.h>
10#include <linux/efi.h>
11#include <linux/pfn.h>
12#include <linux/uaccess.h>
13
14#include <asm/pgtable.h>
15#include <asm/page.h>
16#include <asm/e820.h>
17
18#ifdef CONFIG_EFI
19int efi_enabled = 0;
20EXPORT_SYMBOL(efi_enabled);
21#endif
22
23struct e820map e820;
24struct change_member {
25 struct e820entry *pbios; /* pointer to original bios entry */
26 unsigned long long addr; /* address for this change point */
27};
28static struct change_member change_point_list[2*E820MAX] __initdata;
29static struct change_member *change_point[2*E820MAX] __initdata;
30static struct e820entry *overlap_list[E820MAX] __initdata;
31static struct e820entry new_bios[E820MAX] __initdata;
32/* For PCI or other memory-mapped resources */
33unsigned long pci_mem_start = 0x10000000;
34#ifdef CONFIG_PCI
35EXPORT_SYMBOL(pci_mem_start);
36#endif
37extern int user_defined_memmap;
38struct resource data_resource = {
39 .name = "Kernel data",
40 .start = 0,
41 .end = 0,
42 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
43};
44
45struct resource code_resource = {
46 .name = "Kernel code",
47 .start = 0,
48 .end = 0,
49 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
50};
51
52static struct resource system_rom_resource = {
53 .name = "System ROM",
54 .start = 0xf0000,
55 .end = 0xfffff,
56 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
57};
58
59static struct resource extension_rom_resource = {
60 .name = "Extension ROM",
61 .start = 0xe0000,
62 .end = 0xeffff,
63 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
64};
65
66static struct resource adapter_rom_resources[] = { {
67 .name = "Adapter ROM",
68 .start = 0xc8000,
69 .end = 0,
70 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
71}, {
72 .name = "Adapter ROM",
73 .start = 0,
74 .end = 0,
75 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
76}, {
77 .name = "Adapter ROM",
78 .start = 0,
79 .end = 0,
80 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
81}, {
82 .name = "Adapter ROM",
83 .start = 0,
84 .end = 0,
85 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
86}, {
87 .name = "Adapter ROM",
88 .start = 0,
89 .end = 0,
90 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
91}, {
92 .name = "Adapter ROM",
93 .start = 0,
94 .end = 0,
95 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
96} };
97
98static struct resource video_rom_resource = {
99 .name = "Video ROM",
100 .start = 0xc0000,
101 .end = 0xc7fff,
102 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
103};
104
105static struct resource video_ram_resource = {
106 .name = "Video RAM area",
107 .start = 0xa0000,
108 .end = 0xbffff,
109 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
110};
111
112static struct resource standard_io_resources[] = { {
113 .name = "dma1",
114 .start = 0x0000,
115 .end = 0x001f,
116 .flags = IORESOURCE_BUSY | IORESOURCE_IO
117}, {
118 .name = "pic1",
119 .start = 0x0020,
120 .end = 0x0021,
121 .flags = IORESOURCE_BUSY | IORESOURCE_IO
122}, {
123 .name = "timer0",
124 .start = 0x0040,
125 .end = 0x0043,
126 .flags = IORESOURCE_BUSY | IORESOURCE_IO
127}, {
128 .name = "timer1",
129 .start = 0x0050,
130 .end = 0x0053,
131 .flags = IORESOURCE_BUSY | IORESOURCE_IO
132}, {
133 .name = "keyboard",
134 .start = 0x0060,
135 .end = 0x006f,
136 .flags = IORESOURCE_BUSY | IORESOURCE_IO
137}, {
138 .name = "dma page reg",
139 .start = 0x0080,
140 .end = 0x008f,
141 .flags = IORESOURCE_BUSY | IORESOURCE_IO
142}, {
143 .name = "pic2",
144 .start = 0x00a0,
145 .end = 0x00a1,
146 .flags = IORESOURCE_BUSY | IORESOURCE_IO
147}, {
148 .name = "dma2",
149 .start = 0x00c0,
150 .end = 0x00df,
151 .flags = IORESOURCE_BUSY | IORESOURCE_IO
152}, {
153 .name = "fpu",
154 .start = 0x00f0,
155 .end = 0x00ff,
156 .flags = IORESOURCE_BUSY | IORESOURCE_IO
157} };
158
159static int romsignature(const unsigned char *x)
160{
161 unsigned short sig;
162 int ret = 0;
163 if (probe_kernel_address((const unsigned short *)x, sig) == 0)
164 ret = (sig == 0xaa55);
165 return ret;
166}
167
168static int __init romchecksum(unsigned char *rom, unsigned long length)
169{
170 unsigned char *p, sum = 0;
171
172 for (p = rom; p < rom + length; p++)
173 sum += *p;
174 return sum == 0;
175}
176
177static void __init probe_roms(void)
178{
179 unsigned long start, length, upper;
180 unsigned char *rom;
181 int i;
182
183 /* video rom */
184 upper = adapter_rom_resources[0].start;
185 for (start = video_rom_resource.start; start < upper; start += 2048) {
186 rom = isa_bus_to_virt(start);
187 if (!romsignature(rom))
188 continue;
189
190 video_rom_resource.start = start;
191
192 /* 0 < length <= 0x7f * 512, historically */
193 length = rom[2] * 512;
194
195 /* if checksum okay, trust length byte */
196 if (length && romchecksum(rom, length))
197 video_rom_resource.end = start + length - 1;
198
199 request_resource(&iomem_resource, &video_rom_resource);
200 break;
201 }
202
203 start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
204 if (start < upper)
205 start = upper;
206
207 /* system rom */
208 request_resource(&iomem_resource, &system_rom_resource);
209 upper = system_rom_resource.start;
210
211 /* check for extension rom (ignore length byte!) */
212 rom = isa_bus_to_virt(extension_rom_resource.start);
213 if (romsignature(rom)) {
214 length = extension_rom_resource.end - extension_rom_resource.start + 1;
215 if (romchecksum(rom, length)) {
216 request_resource(&iomem_resource, &extension_rom_resource);
217 upper = extension_rom_resource.start;
218 }
219 }
220
221 /* check for adapter roms on 2k boundaries */
222 for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) {
223 rom = isa_bus_to_virt(start);
224 if (!romsignature(rom))
225 continue;
226
227 /* 0 < length <= 0x7f * 512, historically */
228 length = rom[2] * 512;
229
230 /* but accept any length that fits if checksum okay */
231 if (!length || start + length > upper || !romchecksum(rom, length))
232 continue;
233
234 adapter_rom_resources[i].start = start;
235 adapter_rom_resources[i].end = start + length - 1;
236 request_resource(&iomem_resource, &adapter_rom_resources[i]);
237
238 start = adapter_rom_resources[i++].end & ~2047UL;
239 }
240}
241
242/*
243 * Request address space for all standard RAM and ROM resources
244 * and also for regions reported as reserved by the e820.
245 */
246static void __init
247legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
248{
249 int i;
250
251 probe_roms();
252 for (i = 0; i < e820.nr_map; i++) {
253 struct resource *res;
254#ifndef CONFIG_RESOURCES_64BIT
255 if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
256 continue;
257#endif
258 res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
259 switch (e820.map[i].type) {
260 case E820_RAM: res->name = "System RAM"; break;
261 case E820_ACPI: res->name = "ACPI Tables"; break;
262 case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;
263 default: res->name = "reserved";
264 }
265 res->start = e820.map[i].addr;
266 res->end = res->start + e820.map[i].size - 1;
267 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
268 if (request_resource(&iomem_resource, res)) {
269 kfree(res);
270 continue;
271 }
272 if (e820.map[i].type == E820_RAM) {
273 /*
274 * We don't know which RAM region contains kernel data,
275 * so we try it repeatedly and let the resource manager
276 * test it.
277 */
278 request_resource(res, code_resource);
279 request_resource(res, data_resource);
280#ifdef CONFIG_KEXEC
281 request_resource(res, &crashk_res);
282#endif
283 }
284 }
285}
286
287/*
288 * Request address space for all standard resources
289 *
290 * This is called just before pcibios_init(), which is also a
291 * subsys_initcall, but is linked in later (in arch/i386/pci/common.c).
292 */
293static int __init request_standard_resources(void)
294{
295 int i;
296
297 printk("Setting up standard PCI resources\n");
298 if (efi_enabled)
299 efi_initialize_iomem_resources(&code_resource, &data_resource);
300 else
301 legacy_init_iomem_resources(&code_resource, &data_resource);
302
303 /* EFI systems may still have VGA */
304 request_resource(&iomem_resource, &video_ram_resource);
305
306 /* request I/O space for devices used on all i[345]86 PCs */
307 for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
308 request_resource(&ioport_resource, &standard_io_resources[i]);
309 return 0;
310}
311
312subsys_initcall(request_standard_resources);
313
314void __init add_memory_region(unsigned long long start,
315 unsigned long long size, int type)
316{
317 int x;
318
319 if (!efi_enabled) {
320 x = e820.nr_map;
321
322 if (x == E820MAX) {
323 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
324 return;
325 }
326
327 e820.map[x].addr = start;
328 e820.map[x].size = size;
329 e820.map[x].type = type;
330 e820.nr_map++;
331 }
332} /* add_memory_region */
333
334/*
335 * Sanitize the BIOS e820 map.
336 *
337 * Some e820 responses include overlapping entries. The following
338 * replaces the original e820 map with a new one, removing overlaps.
339 *
340 */
341int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
342{
343 struct change_member *change_tmp;
344 unsigned long current_type, last_type;
345 unsigned long long last_addr;
346 int chgidx, still_changing;
347 int overlap_entries;
348 int new_bios_entry;
349 int old_nr, new_nr, chg_nr;
350 int i;
351
352 /*
353 Visually we're performing the following (1,2,3,4 = memory types)...
354
355 Sample memory map (w/overlaps):
356 ____22__________________
357 ______________________4_
358 ____1111________________
359 _44_____________________
360 11111111________________
361 ____________________33__
362 ___________44___________
363 __________33333_________
364 ______________22________
365 ___________________2222_
366 _________111111111______
367 _____________________11_
368 _________________4______
369
370 Sanitized equivalent (no overlap):
371 1_______________________
372 _44_____________________
373 ___1____________________
374 ____22__________________
375 ______11________________
376 _________1______________
377 __________3_____________
378 ___________44___________
379 _____________33_________
380 _______________2________
381 ________________1_______
382 _________________4______
383 ___________________2____
384 ____________________33__
385 ______________________4_
386 */
387 printk("sanitize start\n");
388 /* if there's only one memory region, don't bother */
389 if (*pnr_map < 2) {
390 printk("sanitize bail 0\n");
391 return -1;
392 }
393
394 old_nr = *pnr_map;
395
396 /* bail out if we find any unreasonable addresses in bios map */
397 for (i=0; i<old_nr; i++)
398 if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr) {
399 printk("sanitize bail 1\n");
400 return -1;
401 }
402
403 /* create pointers for initial change-point information (for sorting) */
404 for (i=0; i < 2*old_nr; i++)
405 change_point[i] = &change_point_list[i];
406
407 /* record all known change-points (starting and ending addresses),
408 omitting those that are for empty memory regions */
409 chgidx = 0;
410 for (i=0; i < old_nr; i++) {
411 if (biosmap[i].size != 0) {
412 change_point[chgidx]->addr = biosmap[i].addr;
413 change_point[chgidx++]->pbios = &biosmap[i];
414 change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
415 change_point[chgidx++]->pbios = &biosmap[i];
416 }
417 }
418 chg_nr = chgidx; /* true number of change-points */
419
420 /* sort change-point list by memory addresses (low -> high) */
421 still_changing = 1;
422 while (still_changing) {
423 still_changing = 0;
424 for (i=1; i < chg_nr; i++) {
425 /* if <current_addr> > <last_addr>, swap */
426 /* or, if current=<start_addr> & last=<end_addr>, swap */
427 if ((change_point[i]->addr < change_point[i-1]->addr) ||
428 ((change_point[i]->addr == change_point[i-1]->addr) &&
429 (change_point[i]->addr == change_point[i]->pbios->addr) &&
430 (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
431 )
432 {
433 change_tmp = change_point[i];
434 change_point[i] = change_point[i-1];
435 change_point[i-1] = change_tmp;
436 still_changing=1;
437 }
438 }
439 }
440
441 /* create a new bios memory map, removing overlaps */
442 overlap_entries=0; /* number of entries in the overlap table */
443 new_bios_entry=0; /* index for creating new bios map entries */
444 last_type = 0; /* start with undefined memory type */
445 last_addr = 0; /* start with 0 as last starting address */
446 /* loop through change-points, determining affect on the new bios map */
447 for (chgidx=0; chgidx < chg_nr; chgidx++)
448 {
449 /* keep track of all overlapping bios entries */
450 if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
451 {
452 /* add map entry to overlap list (> 1 entry implies an overlap) */
453 overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
454 }
455 else
456 {
457 /* remove entry from list (order independent, so swap with last) */
458 for (i=0; i<overlap_entries; i++)
459 {
460 if (overlap_list[i] == change_point[chgidx]->pbios)
461 overlap_list[i] = overlap_list[overlap_entries-1];
462 }
463 overlap_entries--;
464 }
465 /* if there are overlapping entries, decide which "type" to use */
466 /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
467 current_type = 0;
468 for (i=0; i<overlap_entries; i++)
469 if (overlap_list[i]->type > current_type)
470 current_type = overlap_list[i]->type;
471 /* continue building up new bios map based on this information */
472 if (current_type != last_type) {
473 if (last_type != 0) {
474 new_bios[new_bios_entry].size =
475 change_point[chgidx]->addr - last_addr;
476 /* move forward only if the new size was non-zero */
477 if (new_bios[new_bios_entry].size != 0)
478 if (++new_bios_entry >= E820MAX)
479 break; /* no more space left for new bios entries */
480 }
481 if (current_type != 0) {
482 new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
483 new_bios[new_bios_entry].type = current_type;
484 last_addr=change_point[chgidx]->addr;
485 }
486 last_type = current_type;
487 }
488 }
489 new_nr = new_bios_entry; /* retain count for new bios entries */
490
491 /* copy new bios mapping into original location */
492 memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
493 *pnr_map = new_nr;
494
495 printk("sanitize end\n");
496 return 0;
497}
498
499/*
500 * Copy the BIOS e820 map into a safe place.
501 *
502 * Sanity-check it while we're at it..
503 *
504 * If we're lucky and live on a modern system, the setup code
505 * will have given us a memory map that we can use to properly
506 * set up memory. If we aren't, we'll fake a memory map.
507 *
508 * We check to see that the memory map contains at least 2 elements
509 * before we'll use it, because the detection code in setup.S may
510 * not be perfect and most every PC known to man has two memory
511 * regions: one from 0 to 640k, and one from 1mb up. (The IBM
512 * thinkpad 560x, for example, does not cooperate with the memory
513 * detection code.)
514 */
515int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
516{
517 /* Only one memory region (or negative)? Ignore it */
518 if (nr_map < 2)
519 return -1;
520
521 do {
522 unsigned long long start = biosmap->addr;
523 unsigned long long size = biosmap->size;
524 unsigned long long end = start + size;
525 unsigned long type = biosmap->type;
526 printk("copy_e820_map() start: %016Lx size: %016Lx end: %016Lx type: %ld\n", start, size, end, type);
527
528 /* Overflow in 64 bits? Ignore the memory map. */
529 if (start > end)
530 return -1;
531
532 /*
533 * Some BIOSes claim RAM in the 640k - 1M region.
534 * Not right. Fix it up.
535 */
536 if (type == E820_RAM) {
537 printk("copy_e820_map() type is E820_RAM\n");
538 if (start < 0x100000ULL && end > 0xA0000ULL) {
539 printk("copy_e820_map() lies in range...\n");
540 if (start < 0xA0000ULL) {
541 printk("copy_e820_map() start < 0xA0000ULL\n");
542 add_memory_region(start, 0xA0000ULL-start, type);
543 }
544 if (end <= 0x100000ULL) {
545 printk("copy_e820_map() end <= 0x100000ULL\n");
546 continue;
547 }
548 start = 0x100000ULL;
549 size = end - start;
550 }
551 }
552 add_memory_region(start, size, type);
553 } while (biosmap++,--nr_map);
554 return 0;
555}
556
557/*
558 * Callback for efi_memory_walk.
559 */
560static int __init
561efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
562{
563 unsigned long *max_pfn = arg, pfn;
564
565 if (start < end) {
566 pfn = PFN_UP(end -1);
567 if (pfn > *max_pfn)
568 *max_pfn = pfn;
569 }
570 return 0;
571}
572
573static int __init
574efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
575{
576 memory_present(0, PFN_UP(start), PFN_DOWN(end));
577 return 0;
578}
579
580/*
581 * Find the highest page frame number we have available
582 */
583void __init find_max_pfn(void)
584{
585 int i;
586
587 max_pfn = 0;
588 if (efi_enabled) {
589 efi_memmap_walk(efi_find_max_pfn, &max_pfn);
590 efi_memmap_walk(efi_memory_present_wrapper, NULL);
591 return;
592 }
593
594 for (i = 0; i < e820.nr_map; i++) {
595 unsigned long start, end;
596 /* RAM? */
597 if (e820.map[i].type != E820_RAM)
598 continue;
599 start = PFN_UP(e820.map[i].addr);
600 end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
601 if (start >= end)
602 continue;
603 if (end > max_pfn)
604 max_pfn = end;
605 memory_present(0, start, end);
606 }
607}
608
609/*
610 * Free all available memory for boot time allocation. Used
611 * as a callback function by efi_memory_walk()
612 */
613
614static int __init
615free_available_memory(unsigned long start, unsigned long end, void *arg)
616{
617 /* check max_low_pfn */
618 if (start >= (max_low_pfn << PAGE_SHIFT))
619 return 0;
620 if (end >= (max_low_pfn << PAGE_SHIFT))
621 end = max_low_pfn << PAGE_SHIFT;
622 if (start < end)
623 free_bootmem(start, end - start);
624
625 return 0;
626}
627/*
628 * Register fully available low RAM pages with the bootmem allocator.
629 */
630void __init register_bootmem_low_pages(unsigned long max_low_pfn)
631{
632 int i;
633
634 if (efi_enabled) {
635 efi_memmap_walk(free_available_memory, NULL);
636 return;
637 }
638 for (i = 0; i < e820.nr_map; i++) {
639 unsigned long curr_pfn, last_pfn, size;
640 /*
641 * Reserve usable low memory
642 */
643 if (e820.map[i].type != E820_RAM)
644 continue;
645 /*
646 * We are rounding up the start address of usable memory:
647 */
648 curr_pfn = PFN_UP(e820.map[i].addr);
649 if (curr_pfn >= max_low_pfn)
650 continue;
651 /*
652 * ... and at the end of the usable range downwards:
653 */
654 last_pfn = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
655
656 if (last_pfn > max_low_pfn)
657 last_pfn = max_low_pfn;
658
659 /*
660 * .. finally, did all the rounding and playing
661 * around just make the area go away?
662 */
663 if (last_pfn <= curr_pfn)
664 continue;
665
666 size = last_pfn - curr_pfn;
667 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size));
668 }
669}
670
671void __init register_memory(void)
672{
673 unsigned long gapstart, gapsize, round;
674 unsigned long long last;
675 int i;
676
677 /*
678 * Search for the bigest gap in the low 32 bits of the e820
679 * memory space.
680 */
681 last = 0x100000000ull;
682 gapstart = 0x10000000;
683 gapsize = 0x400000;
684 i = e820.nr_map;
685 while (--i >= 0) {
686 unsigned long long start = e820.map[i].addr;
687 unsigned long long end = start + e820.map[i].size;
688
689 /*
690 * Since "last" is at most 4GB, we know we'll
691 * fit in 32 bits if this condition is true
692 */
693 if (last > end) {
694 unsigned long gap = last - end;
695
696 if (gap > gapsize) {
697 gapsize = gap;
698 gapstart = end;
699 }
700 }
701 if (start < last)
702 last = start;
703 }
704
705 /*
706 * See how much we want to round up: start off with
707 * rounding to the next 1MB area.
708 */
709 round = 0x100000;
710 while ((gapsize >> 4) > round)
711 round += round;
712 /* Fun with two's complement */
713 pci_mem_start = (gapstart + round) & -round;
714
715 printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
716 pci_mem_start, gapstart, gapsize);
717}
718
719void __init print_memory_map(char *who)
720{
721 int i;
722
723 for (i = 0; i < e820.nr_map; i++) {
724 printk(" %s: %016Lx - %016Lx ", who,
725 e820.map[i].addr,
726 e820.map[i].addr + e820.map[i].size);
727 switch (e820.map[i].type) {
728 case E820_RAM: printk("(usable)\n");
729 break;
730 case E820_RESERVED:
731 printk("(reserved)\n");
732 break;
733 case E820_ACPI:
734 printk("(ACPI data)\n");
735 break;
736 case E820_NVS:
737 printk("(ACPI NVS)\n");
738 break;
739 default: printk("type %lu\n", e820.map[i].type);
740 break;
741 }
742 }
743}
744
745static __init __always_inline void efi_limit_regions(unsigned long long size)
746{
747 unsigned long long current_addr = 0;
748 efi_memory_desc_t *md, *next_md;
749 void *p, *p1;
750 int i, j;
751
752 j = 0;
753 p1 = memmap.map;
754 for (p = p1, i = 0; p < memmap.map_end; p += memmap.desc_size, i++) {
755 md = p;
756 next_md = p1;
757 current_addr = md->phys_addr +
758 PFN_PHYS(md->num_pages);
759 if (is_available_memory(md)) {
760 if (md->phys_addr >= size) continue;
761 memcpy(next_md, md, memmap.desc_size);
762 if (current_addr >= size) {
763 next_md->num_pages -=
764 PFN_UP(current_addr-size);
765 }
766 p1 += memmap.desc_size;
767 next_md = p1;
768 j++;
769 } else if ((md->attribute & EFI_MEMORY_RUNTIME) ==
770 EFI_MEMORY_RUNTIME) {
771 /* In order to make runtime services
772 * available we have to include runtime
773 * memory regions in memory map */
774 memcpy(next_md, md, memmap.desc_size);
775 p1 += memmap.desc_size;
776 next_md = p1;
777 j++;
778 }
779 }
780 memmap.nr_map = j;
781 memmap.map_end = memmap.map +
782 (memmap.nr_map * memmap.desc_size);
783}
784
785void __init limit_regions(unsigned long long size)
786{
787 unsigned long long current_addr;
788 int i;
789
790 print_memory_map("limit_regions start");
791 if (efi_enabled) {
792 efi_limit_regions(size);
793 return;
794 }
795 for (i = 0; i < e820.nr_map; i++) {
796 current_addr = e820.map[i].addr + e820.map[i].size;
797 if (current_addr < size)
798 continue;
799
800 if (e820.map[i].type != E820_RAM)
801 continue;
802
803 if (e820.map[i].addr >= size) {
804 /*
805 * This region starts past the end of the
806 * requested size, skip it completely.
807 */
808 e820.nr_map = i;
809 } else {
810 e820.nr_map = i + 1;
811 e820.map[i].size -= current_addr - size;
812 }
813 print_memory_map("limit_regions endfor");
814 return;
815 }
816 print_memory_map("limit_regions endfunc");
817}
818
819 /*
820 * This function checks if the entire range <start,end> is mapped with type.
821 *
822 * Note: this function only works correct if the e820 table is sorted and
823 * not-overlapping, which is the case
824 */
825int __init
826e820_all_mapped(unsigned long s, unsigned long e, unsigned type)
827{
828 u64 start = s;
829 u64 end = e;
830 int i;
831 for (i = 0; i < e820.nr_map; i++) {
832 struct e820entry *ei = &e820.map[i];
833 if (type && ei->type != type)
834 continue;
835 /* is the region (part) in overlap with the current region ?*/
836 if (ei->addr >= end || ei->addr + ei->size <= start)
837 continue;
838 /* if the region is at the beginning of <start,end> we move
839 * start to the end of the region since it's ok until there
840 */
841 if (ei->addr <= start)
842 start = ei->addr + ei->size;
843 /* if start is now at or beyond end, we're done, full
844 * coverage */
845 if (start >= end)
846 return 1; /* we're done */
847 }
848 return 0;
849}
850
851static int __init parse_memmap(char *arg)
852{
853 if (!arg)
854 return -EINVAL;
855
856 if (strcmp(arg, "exactmap") == 0) {
857#ifdef CONFIG_CRASH_DUMP
858 /* If we are doing a crash dump, we
859 * still need to know the real mem
860 * size before original memory map is
861 * reset.
862 */
863 find_max_pfn();
864 saved_max_pfn = max_pfn;
865#endif
866 e820.nr_map = 0;
867 user_defined_memmap = 1;
868 } else {
869 /* If the user specifies memory size, we
870 * limit the BIOS-provided memory map to
871 * that size. exactmap can be used to specify
872 * the exact map. mem=number can be used to
873 * trim the existing memory map.
874 */
875 unsigned long long start_at, mem_size;
876
877 mem_size = memparse(arg, &arg);
878 if (*arg == '@') {
879 start_at = memparse(arg+1, &arg);
880 add_memory_region(start_at, mem_size, E820_RAM);
881 } else if (*arg == '#') {
882 start_at = memparse(arg+1, &arg);
883 add_memory_region(start_at, mem_size, E820_ACPI);
884 } else if (*arg == '$') {
885 start_at = memparse(arg+1, &arg);
886 add_memory_region(start_at, mem_size, E820_RESERVED);
887 } else {
888 limit_regions(mem_size);
889 user_defined_memmap = 1;
890 }
891 }
892 return 0;
893}
894early_param("memmap", parse_memmap);
diff --git a/arch/i386/kernel/efi.c b/arch/i386/kernel/efi.c
index 8b40648d0ef0..b92c7f0a358a 100644
--- a/arch/i386/kernel/efi.c
+++ b/arch/i386/kernel/efi.c
@@ -194,17 +194,24 @@ inline int efi_set_rtc_mmss(unsigned long nowtime)
194 return 0; 194 return 0;
195} 195}
196/* 196/*
197 * This should only be used during kernel init and before runtime 197 * This is used during kernel init before runtime
198 * services have been remapped, therefore, we'll need to call in physical 198 * services have been remapped and also during suspend, therefore,
199 * mode. Note, this call isn't used later, so mark it __init. 199 * we'll need to call both in physical and virtual modes.
200 */ 200 */
201inline unsigned long __init efi_get_time(void) 201inline unsigned long efi_get_time(void)
202{ 202{
203 efi_status_t status; 203 efi_status_t status;
204 efi_time_t eft; 204 efi_time_t eft;
205 efi_time_cap_t cap; 205 efi_time_cap_t cap;
206 206
207 status = phys_efi_get_time(&eft, &cap); 207 if (efi.get_time) {
208 /* if we are in virtual mode use remapped function */
209 status = efi.get_time(&eft, &cap);
210 } else {
211 /* we are in physical mode */
212 status = phys_efi_get_time(&eft, &cap);
213 }
214
208 if (status != EFI_SUCCESS) 215 if (status != EFI_SUCCESS)
209 printk("Oops: efitime: can't read time status: 0x%lx\n",status); 216 printk("Oops: efitime: can't read time status: 0x%lx\n",status);
210 217
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index 5a63d6fdb70e..de34b7fed3c1 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -30,12 +30,13 @@
30 * 18(%esp) - %eax 30 * 18(%esp) - %eax
31 * 1C(%esp) - %ds 31 * 1C(%esp) - %ds
32 * 20(%esp) - %es 32 * 20(%esp) - %es
33 * 24(%esp) - orig_eax 33 * 24(%esp) - %gs
34 * 28(%esp) - %eip 34 * 28(%esp) - orig_eax
35 * 2C(%esp) - %cs 35 * 2C(%esp) - %eip
36 * 30(%esp) - %eflags 36 * 30(%esp) - %cs
37 * 34(%esp) - %oldesp 37 * 34(%esp) - %eflags
38 * 38(%esp) - %oldss 38 * 38(%esp) - %oldesp
39 * 3C(%esp) - %oldss
39 * 40 *
40 * "current" is in register %ebx during any slow entries. 41 * "current" is in register %ebx during any slow entries.
41 */ 42 */
@@ -48,26 +49,24 @@
48#include <asm/smp.h> 49#include <asm/smp.h>
49#include <asm/page.h> 50#include <asm/page.h>
50#include <asm/desc.h> 51#include <asm/desc.h>
52#include <asm/percpu.h>
51#include <asm/dwarf2.h> 53#include <asm/dwarf2.h>
52#include "irq_vectors.h" 54#include "irq_vectors.h"
53 55
54#define nr_syscalls ((syscall_table_size)/4) 56/*
57 * We use macros for low-level operations which need to be overridden
58 * for paravirtualization. The following will never clobber any registers:
59 * INTERRUPT_RETURN (aka. "iret")
60 * GET_CR0_INTO_EAX (aka. "movl %cr0, %eax")
61 * ENABLE_INTERRUPTS_SYSEXIT (aka "sti; sysexit").
62 *
63 * For DISABLE_INTERRUPTS/ENABLE_INTERRUPTS (aka "cli"/"sti"), you must
64 * specify what registers can be overwritten (CLBR_NONE, CLBR_EAX/EDX/ECX/ANY).
65 * Allowing a register to be clobbered can shrink the paravirt replacement
66 * enough to patch inline, increasing performance.
67 */
55 68
56EBX = 0x00 69#define nr_syscalls ((syscall_table_size)/4)
57ECX = 0x04
58EDX = 0x08
59ESI = 0x0C
60EDI = 0x10
61EBP = 0x14
62EAX = 0x18
63DS = 0x1C
64ES = 0x20
65ORIG_EAX = 0x24
66EIP = 0x28
67CS = 0x2C
68EFLAGS = 0x30
69OLDESP = 0x34
70OLDSS = 0x38
71 70
72CF_MASK = 0x00000001 71CF_MASK = 0x00000001
73TF_MASK = 0x00000100 72TF_MASK = 0x00000100
@@ -76,23 +75,16 @@ DF_MASK = 0x00000400
76NT_MASK = 0x00004000 75NT_MASK = 0x00004000
77VM_MASK = 0x00020000 76VM_MASK = 0x00020000
78 77
79/* These are replaces for paravirtualization */
80#define DISABLE_INTERRUPTS cli
81#define ENABLE_INTERRUPTS sti
82#define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
83#define INTERRUPT_RETURN iret
84#define GET_CR0_INTO_EAX movl %cr0, %eax
85
86#ifdef CONFIG_PREEMPT 78#ifdef CONFIG_PREEMPT
87#define preempt_stop DISABLE_INTERRUPTS; TRACE_IRQS_OFF 79#define preempt_stop(clobbers) DISABLE_INTERRUPTS(clobbers); TRACE_IRQS_OFF
88#else 80#else
89#define preempt_stop 81#define preempt_stop(clobbers)
90#define resume_kernel restore_nocheck 82#define resume_kernel restore_nocheck
91#endif 83#endif
92 84
93.macro TRACE_IRQS_IRET 85.macro TRACE_IRQS_IRET
94#ifdef CONFIG_TRACE_IRQFLAGS 86#ifdef CONFIG_TRACE_IRQFLAGS
95 testl $IF_MASK,EFLAGS(%esp) # interrupts off? 87 testl $IF_MASK,PT_EFLAGS(%esp) # interrupts off?
96 jz 1f 88 jz 1f
97 TRACE_IRQS_ON 89 TRACE_IRQS_ON
981: 901:
@@ -107,6 +99,9 @@ VM_MASK = 0x00020000
107 99
108#define SAVE_ALL \ 100#define SAVE_ALL \
109 cld; \ 101 cld; \
102 pushl %gs; \
103 CFI_ADJUST_CFA_OFFSET 4;\
104 /*CFI_REL_OFFSET gs, 0;*/\
110 pushl %es; \ 105 pushl %es; \
111 CFI_ADJUST_CFA_OFFSET 4;\ 106 CFI_ADJUST_CFA_OFFSET 4;\
112 /*CFI_REL_OFFSET es, 0;*/\ 107 /*CFI_REL_OFFSET es, 0;*/\
@@ -136,7 +131,9 @@ VM_MASK = 0x00020000
136 CFI_REL_OFFSET ebx, 0;\ 131 CFI_REL_OFFSET ebx, 0;\
137 movl $(__USER_DS), %edx; \ 132 movl $(__USER_DS), %edx; \
138 movl %edx, %ds; \ 133 movl %edx, %ds; \
139 movl %edx, %es; 134 movl %edx, %es; \
135 movl $(__KERNEL_PDA), %edx; \
136 movl %edx, %gs
140 137
141#define RESTORE_INT_REGS \ 138#define RESTORE_INT_REGS \
142 popl %ebx; \ 139 popl %ebx; \
@@ -169,17 +166,22 @@ VM_MASK = 0x00020000
1692: popl %es; \ 1662: popl %es; \
170 CFI_ADJUST_CFA_OFFSET -4;\ 167 CFI_ADJUST_CFA_OFFSET -4;\
171 /*CFI_RESTORE es;*/\ 168 /*CFI_RESTORE es;*/\
172.section .fixup,"ax"; \ 1693: popl %gs; \
1733: movl $0,(%esp); \ 170 CFI_ADJUST_CFA_OFFSET -4;\
174 jmp 1b; \ 171 /*CFI_RESTORE gs;*/\
172.pushsection .fixup,"ax"; \
1754: movl $0,(%esp); \ 1734: movl $0,(%esp); \
174 jmp 1b; \
1755: movl $0,(%esp); \
176 jmp 2b; \ 176 jmp 2b; \
177.previous; \ 1776: movl $0,(%esp); \
178 jmp 3b; \
178.section __ex_table,"a";\ 179.section __ex_table,"a";\
179 .align 4; \ 180 .align 4; \
180 .long 1b,3b; \ 181 .long 1b,4b; \
181 .long 2b,4b; \ 182 .long 2b,5b; \
182.previous 183 .long 3b,6b; \
184.popsection
183 185
184#define RING0_INT_FRAME \ 186#define RING0_INT_FRAME \
185 CFI_STARTPROC simple;\ 187 CFI_STARTPROC simple;\
@@ -198,18 +200,18 @@ VM_MASK = 0x00020000
198#define RING0_PTREGS_FRAME \ 200#define RING0_PTREGS_FRAME \
199 CFI_STARTPROC simple;\ 201 CFI_STARTPROC simple;\
200 CFI_SIGNAL_FRAME;\ 202 CFI_SIGNAL_FRAME;\
201 CFI_DEF_CFA esp, OLDESP-EBX;\ 203 CFI_DEF_CFA esp, PT_OLDESP-PT_EBX;\
202 /*CFI_OFFSET cs, CS-OLDESP;*/\ 204 /*CFI_OFFSET cs, PT_CS-PT_OLDESP;*/\
203 CFI_OFFSET eip, EIP-OLDESP;\ 205 CFI_OFFSET eip, PT_EIP-PT_OLDESP;\
204 /*CFI_OFFSET es, ES-OLDESP;*/\ 206 /*CFI_OFFSET es, PT_ES-PT_OLDESP;*/\
205 /*CFI_OFFSET ds, DS-OLDESP;*/\ 207 /*CFI_OFFSET ds, PT_DS-PT_OLDESP;*/\
206 CFI_OFFSET eax, EAX-OLDESP;\ 208 CFI_OFFSET eax, PT_EAX-PT_OLDESP;\
207 CFI_OFFSET ebp, EBP-OLDESP;\ 209 CFI_OFFSET ebp, PT_EBP-PT_OLDESP;\
208 CFI_OFFSET edi, EDI-OLDESP;\ 210 CFI_OFFSET edi, PT_EDI-PT_OLDESP;\
209 CFI_OFFSET esi, ESI-OLDESP;\ 211 CFI_OFFSET esi, PT_ESI-PT_OLDESP;\
210 CFI_OFFSET edx, EDX-OLDESP;\ 212 CFI_OFFSET edx, PT_EDX-PT_OLDESP;\
211 CFI_OFFSET ecx, ECX-OLDESP;\ 213 CFI_OFFSET ecx, PT_ECX-PT_OLDESP;\
212 CFI_OFFSET ebx, EBX-OLDESP 214 CFI_OFFSET ebx, PT_EBX-PT_OLDESP
213 215
214ENTRY(ret_from_fork) 216ENTRY(ret_from_fork)
215 CFI_STARTPROC 217 CFI_STARTPROC
@@ -237,17 +239,18 @@ ENTRY(ret_from_fork)
237 ALIGN 239 ALIGN
238 RING0_PTREGS_FRAME 240 RING0_PTREGS_FRAME
239ret_from_exception: 241ret_from_exception:
240 preempt_stop 242 preempt_stop(CLBR_ANY)
241ret_from_intr: 243ret_from_intr:
242 GET_THREAD_INFO(%ebp) 244 GET_THREAD_INFO(%ebp)
243check_userspace: 245check_userspace:
244 movl EFLAGS(%esp), %eax # mix EFLAGS and CS 246 movl PT_EFLAGS(%esp), %eax # mix EFLAGS and CS
245 movb CS(%esp), %al 247 movb PT_CS(%esp), %al
246 andl $(VM_MASK | SEGMENT_RPL_MASK), %eax 248 andl $(VM_MASK | SEGMENT_RPL_MASK), %eax
247 cmpl $USER_RPL, %eax 249 cmpl $USER_RPL, %eax
248 jb resume_kernel # not returning to v8086 or userspace 250 jb resume_kernel # not returning to v8086 or userspace
251
249ENTRY(resume_userspace) 252ENTRY(resume_userspace)
250 DISABLE_INTERRUPTS # make sure we don't miss an interrupt 253 DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
251 # setting need_resched or sigpending 254 # setting need_resched or sigpending
252 # between sampling and the iret 255 # between sampling and the iret
253 movl TI_flags(%ebp), %ecx 256 movl TI_flags(%ebp), %ecx
@@ -258,14 +261,14 @@ ENTRY(resume_userspace)
258 261
259#ifdef CONFIG_PREEMPT 262#ifdef CONFIG_PREEMPT
260ENTRY(resume_kernel) 263ENTRY(resume_kernel)
261 DISABLE_INTERRUPTS 264 DISABLE_INTERRUPTS(CLBR_ANY)
262 cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ? 265 cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ?
263 jnz restore_nocheck 266 jnz restore_nocheck
264need_resched: 267need_resched:
265 movl TI_flags(%ebp), %ecx # need_resched set ? 268 movl TI_flags(%ebp), %ecx # need_resched set ?
266 testb $_TIF_NEED_RESCHED, %cl 269 testb $_TIF_NEED_RESCHED, %cl
267 jz restore_all 270 jz restore_all
268 testl $IF_MASK,EFLAGS(%esp) # interrupts off (exception path) ? 271 testl $IF_MASK,PT_EFLAGS(%esp) # interrupts off (exception path) ?
269 jz restore_all 272 jz restore_all
270 call preempt_schedule_irq 273 call preempt_schedule_irq
271 jmp need_resched 274 jmp need_resched
@@ -287,7 +290,7 @@ sysenter_past_esp:
287 * No need to follow this irqs on/off section: the syscall 290 * No need to follow this irqs on/off section: the syscall
288 * disabled irqs and here we enable it straight after entry: 291 * disabled irqs and here we enable it straight after entry:
289 */ 292 */
290 ENABLE_INTERRUPTS 293 ENABLE_INTERRUPTS(CLBR_NONE)
291 pushl $(__USER_DS) 294 pushl $(__USER_DS)
292 CFI_ADJUST_CFA_OFFSET 4 295 CFI_ADJUST_CFA_OFFSET 4
293 /*CFI_REL_OFFSET ss, 0*/ 296 /*CFI_REL_OFFSET ss, 0*/
@@ -331,20 +334,27 @@ sysenter_past_esp:
331 cmpl $(nr_syscalls), %eax 334 cmpl $(nr_syscalls), %eax
332 jae syscall_badsys 335 jae syscall_badsys
333 call *sys_call_table(,%eax,4) 336 call *sys_call_table(,%eax,4)
334 movl %eax,EAX(%esp) 337 movl %eax,PT_EAX(%esp)
335 DISABLE_INTERRUPTS 338 DISABLE_INTERRUPTS(CLBR_ECX|CLBR_EDX)
336 TRACE_IRQS_OFF 339 TRACE_IRQS_OFF
337 movl TI_flags(%ebp), %ecx 340 movl TI_flags(%ebp), %ecx
338 testw $_TIF_ALLWORK_MASK, %cx 341 testw $_TIF_ALLWORK_MASK, %cx
339 jne syscall_exit_work 342 jne syscall_exit_work
340/* if something modifies registers it must also disable sysexit */ 343/* if something modifies registers it must also disable sysexit */
341 movl EIP(%esp), %edx 344 movl PT_EIP(%esp), %edx
342 movl OLDESP(%esp), %ecx 345 movl PT_OLDESP(%esp), %ecx
343 xorl %ebp,%ebp 346 xorl %ebp,%ebp
344 TRACE_IRQS_ON 347 TRACE_IRQS_ON
3481: mov PT_GS(%esp), %gs
345 ENABLE_INTERRUPTS_SYSEXIT 349 ENABLE_INTERRUPTS_SYSEXIT
346 CFI_ENDPROC 350 CFI_ENDPROC
347 351.pushsection .fixup,"ax"
3522: movl $0,PT_GS(%esp)
353 jmp 1b
354.section __ex_table,"a"
355 .align 4
356 .long 1b,2b
357.popsection
348 358
349 # system call handler stub 359 # system call handler stub
350ENTRY(system_call) 360ENTRY(system_call)
@@ -353,7 +363,7 @@ ENTRY(system_call)
353 CFI_ADJUST_CFA_OFFSET 4 363 CFI_ADJUST_CFA_OFFSET 4
354 SAVE_ALL 364 SAVE_ALL
355 GET_THREAD_INFO(%ebp) 365 GET_THREAD_INFO(%ebp)
356 testl $TF_MASK,EFLAGS(%esp) 366 testl $TF_MASK,PT_EFLAGS(%esp)
357 jz no_singlestep 367 jz no_singlestep
358 orl $_TIF_SINGLESTEP,TI_flags(%ebp) 368 orl $_TIF_SINGLESTEP,TI_flags(%ebp)
359no_singlestep: 369no_singlestep:
@@ -365,9 +375,9 @@ no_singlestep:
365 jae syscall_badsys 375 jae syscall_badsys
366syscall_call: 376syscall_call:
367 call *sys_call_table(,%eax,4) 377 call *sys_call_table(,%eax,4)
368 movl %eax,EAX(%esp) # store the return value 378 movl %eax,PT_EAX(%esp) # store the return value
369syscall_exit: 379syscall_exit:
370 DISABLE_INTERRUPTS # make sure we don't miss an interrupt 380 DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
371 # setting need_resched or sigpending 381 # setting need_resched or sigpending
372 # between sampling and the iret 382 # between sampling and the iret
373 TRACE_IRQS_OFF 383 TRACE_IRQS_OFF
@@ -376,12 +386,12 @@ syscall_exit:
376 jne syscall_exit_work 386 jne syscall_exit_work
377 387
378restore_all: 388restore_all:
379 movl EFLAGS(%esp), %eax # mix EFLAGS, SS and CS 389 movl PT_EFLAGS(%esp), %eax # mix EFLAGS, SS and CS
380 # Warning: OLDSS(%esp) contains the wrong/random values if we 390 # Warning: PT_OLDSS(%esp) contains the wrong/random values if we
381 # are returning to the kernel. 391 # are returning to the kernel.
382 # See comments in process.c:copy_thread() for details. 392 # See comments in process.c:copy_thread() for details.
383 movb OLDSS(%esp), %ah 393 movb PT_OLDSS(%esp), %ah
384 movb CS(%esp), %al 394 movb PT_CS(%esp), %al
385 andl $(VM_MASK | (SEGMENT_TI_MASK << 8) | SEGMENT_RPL_MASK), %eax 395 andl $(VM_MASK | (SEGMENT_TI_MASK << 8) | SEGMENT_RPL_MASK), %eax
386 cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax 396 cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax
387 CFI_REMEMBER_STATE 397 CFI_REMEMBER_STATE
@@ -390,13 +400,13 @@ restore_nocheck:
390 TRACE_IRQS_IRET 400 TRACE_IRQS_IRET
391restore_nocheck_notrace: 401restore_nocheck_notrace:
392 RESTORE_REGS 402 RESTORE_REGS
393 addl $4, %esp 403 addl $4, %esp # skip orig_eax/error_code
394 CFI_ADJUST_CFA_OFFSET -4 404 CFI_ADJUST_CFA_OFFSET -4
3951: INTERRUPT_RETURN 4051: INTERRUPT_RETURN
396.section .fixup,"ax" 406.section .fixup,"ax"
397iret_exc: 407iret_exc:
398 TRACE_IRQS_ON 408 TRACE_IRQS_ON
399 ENABLE_INTERRUPTS 409 ENABLE_INTERRUPTS(CLBR_NONE)
400 pushl $0 # no error code 410 pushl $0 # no error code
401 pushl $do_iret_error 411 pushl $do_iret_error
402 jmp error_code 412 jmp error_code
@@ -408,33 +418,42 @@ iret_exc:
408 418
409 CFI_RESTORE_STATE 419 CFI_RESTORE_STATE
410ldt_ss: 420ldt_ss:
411 larl OLDSS(%esp), %eax 421 larl PT_OLDSS(%esp), %eax
412 jnz restore_nocheck 422 jnz restore_nocheck
413 testl $0x00400000, %eax # returning to 32bit stack? 423 testl $0x00400000, %eax # returning to 32bit stack?
414 jnz restore_nocheck # allright, normal return 424 jnz restore_nocheck # allright, normal return
425
426#ifdef CONFIG_PARAVIRT
427 /*
428 * The kernel can't run on a non-flat stack if paravirt mode
429 * is active. Rather than try to fixup the high bits of
430 * ESP, bypass this code entirely. This may break DOSemu
431 * and/or Wine support in a paravirt VM, although the option
432 * is still available to implement the setting of the high
433 * 16-bits in the INTERRUPT_RETURN paravirt-op.
434 */
435 cmpl $0, paravirt_ops+PARAVIRT_enabled
436 jne restore_nocheck
437#endif
438
415 /* If returning to userspace with 16bit stack, 439 /* If returning to userspace with 16bit stack,
416 * try to fix the higher word of ESP, as the CPU 440 * try to fix the higher word of ESP, as the CPU
417 * won't restore it. 441 * won't restore it.
418 * This is an "official" bug of all the x86-compatible 442 * This is an "official" bug of all the x86-compatible
419 * CPUs, which we can try to work around to make 443 * CPUs, which we can try to work around to make
420 * dosemu and wine happy. */ 444 * dosemu and wine happy. */
421 subl $8, %esp # reserve space for switch16 pointer 445 movl PT_OLDESP(%esp), %eax
422 CFI_ADJUST_CFA_OFFSET 8 446 movl %esp, %edx
423 DISABLE_INTERRUPTS 447 call patch_espfix_desc
448 pushl $__ESPFIX_SS
449 CFI_ADJUST_CFA_OFFSET 4
450 pushl %eax
451 CFI_ADJUST_CFA_OFFSET 4
452 DISABLE_INTERRUPTS(CLBR_EAX)
424 TRACE_IRQS_OFF 453 TRACE_IRQS_OFF
425 movl %esp, %eax 454 lss (%esp), %esp
426 /* Set up the 16bit stack frame with switch32 pointer on top, 455 CFI_ADJUST_CFA_OFFSET -8
427 * and a switch16 pointer on top of the current frame. */ 456 jmp restore_nocheck
428 call setup_x86_bogus_stack
429 CFI_ADJUST_CFA_OFFSET -8 # frame has moved
430 TRACE_IRQS_IRET
431 RESTORE_REGS
432 lss 20+4(%esp), %esp # switch to 16bit stack
4331: INTERRUPT_RETURN
434.section __ex_table,"a"
435 .align 4
436 .long 1b,iret_exc
437.previous
438 CFI_ENDPROC 457 CFI_ENDPROC
439 458
440 # perform work that needs to be done immediately before resumption 459 # perform work that needs to be done immediately before resumption
@@ -445,7 +464,7 @@ work_pending:
445 jz work_notifysig 464 jz work_notifysig
446work_resched: 465work_resched:
447 call schedule 466 call schedule
448 DISABLE_INTERRUPTS # make sure we don't miss an interrupt 467 DISABLE_INTERRUPTS(CLBR_ANY) # make sure we don't miss an interrupt
449 # setting need_resched or sigpending 468 # setting need_resched or sigpending
450 # between sampling and the iret 469 # between sampling and the iret
451 TRACE_IRQS_OFF 470 TRACE_IRQS_OFF
@@ -458,7 +477,8 @@ work_resched:
458 477
459work_notifysig: # deal with pending signals and 478work_notifysig: # deal with pending signals and
460 # notify-resume requests 479 # notify-resume requests
461 testl $VM_MASK, EFLAGS(%esp) 480#ifdef CONFIG_VM86
481 testl $VM_MASK, PT_EFLAGS(%esp)
462 movl %esp, %eax 482 movl %esp, %eax
463 jne work_notifysig_v86 # returning to kernel-space or 483 jne work_notifysig_v86 # returning to kernel-space or
464 # vm86-space 484 # vm86-space
@@ -468,29 +488,30 @@ work_notifysig: # deal with pending signals and
468 488
469 ALIGN 489 ALIGN
470work_notifysig_v86: 490work_notifysig_v86:
471#ifdef CONFIG_VM86
472 pushl %ecx # save ti_flags for do_notify_resume 491 pushl %ecx # save ti_flags for do_notify_resume
473 CFI_ADJUST_CFA_OFFSET 4 492 CFI_ADJUST_CFA_OFFSET 4
474 call save_v86_state # %eax contains pt_regs pointer 493 call save_v86_state # %eax contains pt_regs pointer
475 popl %ecx 494 popl %ecx
476 CFI_ADJUST_CFA_OFFSET -4 495 CFI_ADJUST_CFA_OFFSET -4
477 movl %eax, %esp 496 movl %eax, %esp
497#else
498 movl %esp, %eax
499#endif
478 xorl %edx, %edx 500 xorl %edx, %edx
479 call do_notify_resume 501 call do_notify_resume
480 jmp resume_userspace_sig 502 jmp resume_userspace_sig
481#endif
482 503
483 # perform syscall exit tracing 504 # perform syscall exit tracing
484 ALIGN 505 ALIGN
485syscall_trace_entry: 506syscall_trace_entry:
486 movl $-ENOSYS,EAX(%esp) 507 movl $-ENOSYS,PT_EAX(%esp)
487 movl %esp, %eax 508 movl %esp, %eax
488 xorl %edx,%edx 509 xorl %edx,%edx
489 call do_syscall_trace 510 call do_syscall_trace
490 cmpl $0, %eax 511 cmpl $0, %eax
491 jne resume_userspace # ret != 0 -> running under PTRACE_SYSEMU, 512 jne resume_userspace # ret != 0 -> running under PTRACE_SYSEMU,
492 # so must skip actual syscall 513 # so must skip actual syscall
493 movl ORIG_EAX(%esp), %eax 514 movl PT_ORIG_EAX(%esp), %eax
494 cmpl $(nr_syscalls), %eax 515 cmpl $(nr_syscalls), %eax
495 jnae syscall_call 516 jnae syscall_call
496 jmp syscall_exit 517 jmp syscall_exit
@@ -501,7 +522,7 @@ syscall_exit_work:
501 testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl 522 testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
502 jz work_pending 523 jz work_pending
503 TRACE_IRQS_ON 524 TRACE_IRQS_ON
504 ENABLE_INTERRUPTS # could let do_syscall_trace() call 525 ENABLE_INTERRUPTS(CLBR_ANY) # could let do_syscall_trace() call
505 # schedule() instead 526 # schedule() instead
506 movl %esp, %eax 527 movl %esp, %eax
507 movl $1, %edx 528 movl $1, %edx
@@ -515,39 +536,38 @@ syscall_fault:
515 CFI_ADJUST_CFA_OFFSET 4 536 CFI_ADJUST_CFA_OFFSET 4
516 SAVE_ALL 537 SAVE_ALL
517 GET_THREAD_INFO(%ebp) 538 GET_THREAD_INFO(%ebp)
518 movl $-EFAULT,EAX(%esp) 539 movl $-EFAULT,PT_EAX(%esp)
519 jmp resume_userspace 540 jmp resume_userspace
520 541
521syscall_badsys: 542syscall_badsys:
522 movl $-ENOSYS,EAX(%esp) 543 movl $-ENOSYS,PT_EAX(%esp)
523 jmp resume_userspace 544 jmp resume_userspace
524 CFI_ENDPROC 545 CFI_ENDPROC
525 546
526#define FIXUP_ESPFIX_STACK \ 547#define FIXUP_ESPFIX_STACK \
527 movl %esp, %eax; \ 548 /* since we are on a wrong stack, we cant make it a C code :( */ \
528 /* switch to 32bit stack using the pointer on top of 16bit stack */ \ 549 movl %gs:PDA_cpu, %ebx; \
529 lss %ss:CPU_16BIT_STACK_SIZE-8, %esp; \ 550 PER_CPU(cpu_gdt_descr, %ebx); \
530 /* copy data from 16bit stack to 32bit stack */ \ 551 movl GDS_address(%ebx), %ebx; \
531 call fixup_x86_bogus_stack; \ 552 GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah); \
532 /* put ESP to the proper location */ \ 553 addl %esp, %eax; \
533 movl %eax, %esp; 554 pushl $__KERNEL_DS; \
534#define UNWIND_ESPFIX_STACK \ 555 CFI_ADJUST_CFA_OFFSET 4; \
535 pushl %eax; \ 556 pushl %eax; \
536 CFI_ADJUST_CFA_OFFSET 4; \ 557 CFI_ADJUST_CFA_OFFSET 4; \
558 lss (%esp), %esp; \
559 CFI_ADJUST_CFA_OFFSET -8;
560#define UNWIND_ESPFIX_STACK \
537 movl %ss, %eax; \ 561 movl %ss, %eax; \
538 /* see if on 16bit stack */ \ 562 /* see if on espfix stack */ \
539 cmpw $__ESPFIX_SS, %ax; \ 563 cmpw $__ESPFIX_SS, %ax; \
540 je 28f; \ 564 jne 27f; \
54127: popl %eax; \ 565 movl $__KERNEL_DS, %eax; \
542 CFI_ADJUST_CFA_OFFSET -4; \
543.section .fixup,"ax"; \
54428: movl $__KERNEL_DS, %eax; \
545 movl %eax, %ds; \ 566 movl %eax, %ds; \
546 movl %eax, %es; \ 567 movl %eax, %es; \
547 /* switch to 32bit stack */ \ 568 /* switch to normal stack */ \
548 FIXUP_ESPFIX_STACK; \ 569 FIXUP_ESPFIX_STACK; \
549 jmp 27b; \ 57027:;
550.previous
551 571
552/* 572/*
553 * Build the entry stubs and pointer table with 573 * Build the entry stubs and pointer table with
@@ -608,13 +628,16 @@ KPROBE_ENTRY(page_fault)
608 CFI_ADJUST_CFA_OFFSET 4 628 CFI_ADJUST_CFA_OFFSET 4
609 ALIGN 629 ALIGN
610error_code: 630error_code:
631 /* the function address is in %gs's slot on the stack */
632 pushl %es
633 CFI_ADJUST_CFA_OFFSET 4
634 /*CFI_REL_OFFSET es, 0*/
611 pushl %ds 635 pushl %ds
612 CFI_ADJUST_CFA_OFFSET 4 636 CFI_ADJUST_CFA_OFFSET 4
613 /*CFI_REL_OFFSET ds, 0*/ 637 /*CFI_REL_OFFSET ds, 0*/
614 pushl %eax 638 pushl %eax
615 CFI_ADJUST_CFA_OFFSET 4 639 CFI_ADJUST_CFA_OFFSET 4
616 CFI_REL_OFFSET eax, 0 640 CFI_REL_OFFSET eax, 0
617 xorl %eax, %eax
618 pushl %ebp 641 pushl %ebp
619 CFI_ADJUST_CFA_OFFSET 4 642 CFI_ADJUST_CFA_OFFSET 4
620 CFI_REL_OFFSET ebp, 0 643 CFI_REL_OFFSET ebp, 0
@@ -627,7 +650,6 @@ error_code:
627 pushl %edx 650 pushl %edx
628 CFI_ADJUST_CFA_OFFSET 4 651 CFI_ADJUST_CFA_OFFSET 4
629 CFI_REL_OFFSET edx, 0 652 CFI_REL_OFFSET edx, 0
630 decl %eax # eax = -1
631 pushl %ecx 653 pushl %ecx
632 CFI_ADJUST_CFA_OFFSET 4 654 CFI_ADJUST_CFA_OFFSET 4
633 CFI_REL_OFFSET ecx, 0 655 CFI_REL_OFFSET ecx, 0
@@ -635,18 +657,20 @@ error_code:
635 CFI_ADJUST_CFA_OFFSET 4 657 CFI_ADJUST_CFA_OFFSET 4
636 CFI_REL_OFFSET ebx, 0 658 CFI_REL_OFFSET ebx, 0
637 cld 659 cld
638 pushl %es 660 pushl %gs
639 CFI_ADJUST_CFA_OFFSET 4 661 CFI_ADJUST_CFA_OFFSET 4
640 /*CFI_REL_OFFSET es, 0*/ 662 /*CFI_REL_OFFSET gs, 0*/
663 movl $(__KERNEL_PDA), %ecx
664 movl %ecx, %gs
641 UNWIND_ESPFIX_STACK 665 UNWIND_ESPFIX_STACK
642 popl %ecx 666 popl %ecx
643 CFI_ADJUST_CFA_OFFSET -4 667 CFI_ADJUST_CFA_OFFSET -4
644 /*CFI_REGISTER es, ecx*/ 668 /*CFI_REGISTER es, ecx*/
645 movl ES(%esp), %edi # get the function address 669 movl PT_GS(%esp), %edi # get the function address
646 movl ORIG_EAX(%esp), %edx # get the error code 670 movl PT_ORIG_EAX(%esp), %edx # get the error code
647 movl %eax, ORIG_EAX(%esp) 671 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
648 movl %ecx, ES(%esp) 672 mov %ecx, PT_GS(%esp)
649 /*CFI_REL_OFFSET es, ES*/ 673 /*CFI_REL_OFFSET gs, ES*/
650 movl $(__USER_DS), %ecx 674 movl $(__USER_DS), %ecx
651 movl %ecx, %ds 675 movl %ecx, %ds
652 movl %ecx, %es 676 movl %ecx, %es
@@ -682,7 +706,7 @@ ENTRY(device_not_available)
682 GET_CR0_INTO_EAX 706 GET_CR0_INTO_EAX
683 testl $0x4, %eax # EM (math emulation bit) 707 testl $0x4, %eax # EM (math emulation bit)
684 jne device_not_available_emulate 708 jne device_not_available_emulate
685 preempt_stop 709 preempt_stop(CLBR_ANY)
686 call math_state_restore 710 call math_state_restore
687 jmp ret_from_exception 711 jmp ret_from_exception
688device_not_available_emulate: 712device_not_available_emulate:
@@ -754,7 +778,7 @@ KPROBE_ENTRY(nmi)
754 cmpw $__ESPFIX_SS, %ax 778 cmpw $__ESPFIX_SS, %ax
755 popl %eax 779 popl %eax
756 CFI_ADJUST_CFA_OFFSET -4 780 CFI_ADJUST_CFA_OFFSET -4
757 je nmi_16bit_stack 781 je nmi_espfix_stack
758 cmpl $sysenter_entry,(%esp) 782 cmpl $sysenter_entry,(%esp)
759 je nmi_stack_fixup 783 je nmi_stack_fixup
760 pushl %eax 784 pushl %eax
@@ -797,7 +821,7 @@ nmi_debug_stack_check:
797 FIX_STACK(24,nmi_stack_correct, 1) 821 FIX_STACK(24,nmi_stack_correct, 1)
798 jmp nmi_stack_correct 822 jmp nmi_stack_correct
799 823
800nmi_16bit_stack: 824nmi_espfix_stack:
801 /* We have a RING0_INT_FRAME here. 825 /* We have a RING0_INT_FRAME here.
802 * 826 *
803 * create the pointer to lss back 827 * create the pointer to lss back
@@ -806,7 +830,6 @@ nmi_16bit_stack:
806 CFI_ADJUST_CFA_OFFSET 4 830 CFI_ADJUST_CFA_OFFSET 4
807 pushl %esp 831 pushl %esp
808 CFI_ADJUST_CFA_OFFSET 4 832 CFI_ADJUST_CFA_OFFSET 4
809 movzwl %sp, %esp
810 addw $4, (%esp) 833 addw $4, (%esp)
811 /* copy the iret frame of 12 bytes */ 834 /* copy the iret frame of 12 bytes */
812 .rept 3 835 .rept 3
@@ -817,11 +840,11 @@ nmi_16bit_stack:
817 CFI_ADJUST_CFA_OFFSET 4 840 CFI_ADJUST_CFA_OFFSET 4
818 SAVE_ALL 841 SAVE_ALL
819 FIXUP_ESPFIX_STACK # %eax == %esp 842 FIXUP_ESPFIX_STACK # %eax == %esp
820 CFI_ADJUST_CFA_OFFSET -20 # the frame has now moved
821 xorl %edx,%edx # zero error code 843 xorl %edx,%edx # zero error code
822 call do_nmi 844 call do_nmi
823 RESTORE_REGS 845 RESTORE_REGS
824 lss 12+4(%esp), %esp # back to 16bit stack 846 lss 12+4(%esp), %esp # back to espfix stack
847 CFI_ADJUST_CFA_OFFSET -24
8251: INTERRUPT_RETURN 8481: INTERRUPT_RETURN
826 CFI_ENDPROC 849 CFI_ENDPROC
827.section __ex_table,"a" 850.section __ex_table,"a"
@@ -830,6 +853,19 @@ nmi_16bit_stack:
830.previous 853.previous
831KPROBE_END(nmi) 854KPROBE_END(nmi)
832 855
856#ifdef CONFIG_PARAVIRT
857ENTRY(native_iret)
8581: iret
859.section __ex_table,"a"
860 .align 4
861 .long 1b,iret_exc
862.previous
863
864ENTRY(native_irq_enable_sysexit)
865 sti
866 sysexit
867#endif
868
833KPROBE_ENTRY(int3) 869KPROBE_ENTRY(int3)
834 RING0_INT_FRAME 870 RING0_INT_FRAME
835 pushl $-1 # mark this as an int 871 pushl $-1 # mark this as an int
@@ -949,26 +985,27 @@ ENTRY(arch_unwind_init_running)
949 movl 4(%esp), %edx 985 movl 4(%esp), %edx
950 movl (%esp), %ecx 986 movl (%esp), %ecx
951 leal 4(%esp), %eax 987 leal 4(%esp), %eax
952 movl %ebx, EBX(%edx) 988 movl %ebx, PT_EBX(%edx)
953 xorl %ebx, %ebx 989 xorl %ebx, %ebx
954 movl %ebx, ECX(%edx) 990 movl %ebx, PT_ECX(%edx)
955 movl %ebx, EDX(%edx) 991 movl %ebx, PT_EDX(%edx)
956 movl %esi, ESI(%edx) 992 movl %esi, PT_ESI(%edx)
957 movl %edi, EDI(%edx) 993 movl %edi, PT_EDI(%edx)
958 movl %ebp, EBP(%edx) 994 movl %ebp, PT_EBP(%edx)
959 movl %ebx, EAX(%edx) 995 movl %ebx, PT_EAX(%edx)
960 movl $__USER_DS, DS(%edx) 996 movl $__USER_DS, PT_DS(%edx)
961 movl $__USER_DS, ES(%edx) 997 movl $__USER_DS, PT_ES(%edx)
962 movl %ebx, ORIG_EAX(%edx) 998 movl $0, PT_GS(%edx)
963 movl %ecx, EIP(%edx) 999 movl %ebx, PT_ORIG_EAX(%edx)
1000 movl %ecx, PT_EIP(%edx)
964 movl 12(%esp), %ecx 1001 movl 12(%esp), %ecx
965 movl $__KERNEL_CS, CS(%edx) 1002 movl $__KERNEL_CS, PT_CS(%edx)
966 movl %ebx, EFLAGS(%edx) 1003 movl %ebx, PT_EFLAGS(%edx)
967 movl %eax, OLDESP(%edx) 1004 movl %eax, PT_OLDESP(%edx)
968 movl 8(%esp), %eax 1005 movl 8(%esp), %eax
969 movl %ecx, 8(%esp) 1006 movl %ecx, 8(%esp)
970 movl EBX(%edx), %ebx 1007 movl PT_EBX(%edx), %ebx
971 movl $__KERNEL_DS, OLDSS(%edx) 1008 movl $__KERNEL_DS, PT_OLDSS(%edx)
972 jmpl *%eax 1009 jmpl *%eax
973 CFI_ENDPROC 1010 CFI_ENDPROC
974ENDPROC(arch_unwind_init_running) 1011ENDPROC(arch_unwind_init_running)
diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S
index ca31f18d277c..edef5084ce17 100644
--- a/arch/i386/kernel/head.S
+++ b/arch/i386/kernel/head.S
@@ -55,6 +55,12 @@
55 */ 55 */
56ENTRY(startup_32) 56ENTRY(startup_32)
57 57
58#ifdef CONFIG_PARAVIRT
59 movl %cs, %eax
60 testl $0x3, %eax
61 jnz startup_paravirt
62#endif
63
58/* 64/*
59 * Set segments to known values. 65 * Set segments to known values.
60 */ 66 */
@@ -302,6 +308,7 @@ is386: movl $2,%ecx # set MP
302 movl %eax,%cr0 308 movl %eax,%cr0
303 309
304 call check_x87 310 call check_x87
311 call setup_pda
305 lgdt cpu_gdt_descr 312 lgdt cpu_gdt_descr
306 lidt idt_descr 313 lidt idt_descr
307 ljmp $(__KERNEL_CS),$1f 314 ljmp $(__KERNEL_CS),$1f
@@ -312,10 +319,13 @@ is386: movl $2,%ecx # set MP
312 movl %eax,%ds 319 movl %eax,%ds
313 movl %eax,%es 320 movl %eax,%es
314 321
315 xorl %eax,%eax # Clear FS/GS and LDT 322 xorl %eax,%eax # Clear FS and LDT
316 movl %eax,%fs 323 movl %eax,%fs
317 movl %eax,%gs
318 lldt %ax 324 lldt %ax
325
326 movl $(__KERNEL_PDA),%eax
327 mov %eax,%gs
328
319 cld # gcc2 wants the direction flag cleared at all times 329 cld # gcc2 wants the direction flag cleared at all times
320 pushl $0 # fake return address for unwinder 330 pushl $0 # fake return address for unwinder
321#ifdef CONFIG_SMP 331#ifdef CONFIG_SMP
@@ -346,6 +356,23 @@ check_x87:
346 ret 356 ret
347 357
348/* 358/*
359 * Point the GDT at this CPU's PDA. On boot this will be
360 * cpu_gdt_table and boot_pda; for secondary CPUs, these will be
361 * that CPU's GDT and PDA.
362 */
363setup_pda:
364 /* get the PDA pointer */
365 movl start_pda, %eax
366
367 /* slot the PDA address into the GDT */
368 mov cpu_gdt_descr+2, %ecx
369 mov %ax, (__KERNEL_PDA+0+2)(%ecx) /* base & 0x0000ffff */
370 shr $16, %eax
371 mov %al, (__KERNEL_PDA+4+0)(%ecx) /* base & 0x00ff0000 */
372 mov %ah, (__KERNEL_PDA+4+3)(%ecx) /* base & 0xff000000 */
373 ret
374
375/*
349 * setup_idt 376 * setup_idt
350 * 377 *
351 * sets up a idt with 256 entries pointing to 378 * sets up a idt with 256 entries pointing to
@@ -465,6 +492,33 @@ ignore_int:
465#endif 492#endif
466 iret 493 iret
467 494
495#ifdef CONFIG_PARAVIRT
496startup_paravirt:
497 cld
498 movl $(init_thread_union+THREAD_SIZE),%esp
499
500 /* We take pains to preserve all the regs. */
501 pushl %edx
502 pushl %ecx
503 pushl %eax
504
505 /* paravirt.o is last in link, and that probe fn never returns */
506 pushl $__start_paravirtprobe
5071:
508 movl 0(%esp), %eax
509 pushl (%eax)
510 movl 8(%esp), %eax
511 call *(%esp)
512 popl %eax
513
514 movl 4(%esp), %eax
515 movl 8(%esp), %ecx
516 movl 12(%esp), %edx
517
518 addl $4, (%esp)
519 jmp 1b
520#endif
521
468/* 522/*
469 * Real beginning of normal "text" segment 523 * Real beginning of normal "text" segment
470 */ 524 */
@@ -484,6 +538,8 @@ ENTRY(empty_zero_page)
484 * This starts the data section. 538 * This starts the data section.
485 */ 539 */
486.data 540.data
541ENTRY(start_pda)
542 .long boot_pda
487 543
488ENTRY(stack_start) 544ENTRY(stack_start)
489 .long init_thread_union+THREAD_SIZE 545 .long init_thread_union+THREAD_SIZE
@@ -525,7 +581,7 @@ idt_descr:
525 581
526# boot GDT descriptor (later on used by CPU#0): 582# boot GDT descriptor (later on used by CPU#0):
527 .word 0 # 32 bit align gdt_desc.address 583 .word 0 # 32 bit align gdt_desc.address
528cpu_gdt_descr: 584ENTRY(cpu_gdt_descr)
529 .word GDT_ENTRIES*8-1 585 .word GDT_ENTRIES*8-1
530 .long cpu_gdt_table 586 .long cpu_gdt_table
531 587
@@ -584,8 +640,8 @@ ENTRY(cpu_gdt_table)
584 .quad 0x00009a000000ffff /* 0xc0 APM CS 16 code (16 bit) */ 640 .quad 0x00009a000000ffff /* 0xc0 APM CS 16 code (16 bit) */
585 .quad 0x004092000000ffff /* 0xc8 APM DS data */ 641 .quad 0x004092000000ffff /* 0xc8 APM DS data */
586 642
587 .quad 0x0000920000000000 /* 0xd0 - ESPFIX 16-bit SS */ 643 .quad 0x00c0920000000000 /* 0xd0 - ESPFIX SS */
588 .quad 0x0000000000000000 /* 0xd8 - unused */ 644 .quad 0x00cf92000000ffff /* 0xd8 - PDA */
589 .quad 0x0000000000000000 /* 0xe0 - unused */ 645 .quad 0x0000000000000000 /* 0xe0 - unused */
590 .quad 0x0000000000000000 /* 0xe8 - unused */ 646 .quad 0x0000000000000000 /* 0xe8 - unused */
591 .quad 0x0000000000000000 /* 0xf0 - unused */ 647 .quad 0x0000000000000000 /* 0xf0 - unused */
diff --git a/arch/i386/kernel/hpet.c b/arch/i386/kernel/hpet.c
index 17647a530b2f..45a8685bb60b 100644
--- a/arch/i386/kernel/hpet.c
+++ b/arch/i386/kernel/hpet.c
@@ -34,6 +34,7 @@ static int __init init_hpet_clocksource(void)
34 unsigned long hpet_period; 34 unsigned long hpet_period;
35 void __iomem* hpet_base; 35 void __iomem* hpet_base;
36 u64 tmp; 36 u64 tmp;
37 int err;
37 38
38 if (!is_hpet_enabled()) 39 if (!is_hpet_enabled())
39 return -ENODEV; 40 return -ENODEV;
@@ -61,7 +62,11 @@ static int __init init_hpet_clocksource(void)
61 do_div(tmp, FSEC_PER_NSEC); 62 do_div(tmp, FSEC_PER_NSEC);
62 clocksource_hpet.mult = (u32)tmp; 63 clocksource_hpet.mult = (u32)tmp;
63 64
64 return clocksource_register(&clocksource_hpet); 65 err = clocksource_register(&clocksource_hpet);
66 if (err)
67 iounmap(hpet_base);
68
69 return err;
65} 70}
66 71
67module_init(init_hpet_clocksource); 72module_init(init_hpet_clocksource);
diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
index 62996cd17084..c8d45821c788 100644
--- a/arch/i386/kernel/i8259.c
+++ b/arch/i386/kernel/i8259.c
@@ -381,7 +381,10 @@ void __init init_ISA_irqs (void)
381 } 381 }
382} 382}
383 383
384void __init init_IRQ(void) 384/* Overridden in paravirt.c */
385void init_IRQ(void) __attribute__((weak, alias("native_init_IRQ")));
386
387void __init native_init_IRQ(void)
385{ 388{
386 int i; 389 int i;
387 390
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 3b7a63e0ed1a..e21dcde0790e 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -34,6 +34,7 @@
34#include <linux/pci.h> 34#include <linux/pci.h>
35#include <linux/msi.h> 35#include <linux/msi.h>
36#include <linux/htirq.h> 36#include <linux/htirq.h>
37#include <linux/freezer.h>
37 38
38#include <asm/io.h> 39#include <asm/io.h>
39#include <asm/smp.h> 40#include <asm/smp.h>
@@ -153,14 +154,20 @@ static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
153 * the interrupt, and we need to make sure the entry is fully populated 154 * the interrupt, and we need to make sure the entry is fully populated
154 * before that happens. 155 * before that happens.
155 */ 156 */
156static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) 157static void
158__ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
157{ 159{
158 unsigned long flags;
159 union entry_union eu; 160 union entry_union eu;
160 eu.entry = e; 161 eu.entry = e;
161 spin_lock_irqsave(&ioapic_lock, flags);
162 io_apic_write(apic, 0x11 + 2*pin, eu.w2); 162 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
163 io_apic_write(apic, 0x10 + 2*pin, eu.w1); 163 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
164}
165
166static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
167{
168 unsigned long flags;
169 spin_lock_irqsave(&ioapic_lock, flags);
170 __ioapic_write_entry(apic, pin, e);
164 spin_unlock_irqrestore(&ioapic_lock, flags); 171 spin_unlock_irqrestore(&ioapic_lock, flags);
165} 172}
166 173
@@ -836,8 +843,7 @@ static int __init find_isa_irq_pin(int irq, int type)
836 843
837 if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA || 844 if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA ||
838 mp_bus_id_to_type[lbus] == MP_BUS_EISA || 845 mp_bus_id_to_type[lbus] == MP_BUS_EISA ||
839 mp_bus_id_to_type[lbus] == MP_BUS_MCA || 846 mp_bus_id_to_type[lbus] == MP_BUS_MCA
840 mp_bus_id_to_type[lbus] == MP_BUS_NEC98
841 ) && 847 ) &&
842 (mp_irqs[i].mpc_irqtype == type) && 848 (mp_irqs[i].mpc_irqtype == type) &&
843 (mp_irqs[i].mpc_srcbusirq == irq)) 849 (mp_irqs[i].mpc_srcbusirq == irq))
@@ -856,8 +862,7 @@ static int __init find_isa_irq_apic(int irq, int type)
856 862
857 if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA || 863 if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA ||
858 mp_bus_id_to_type[lbus] == MP_BUS_EISA || 864 mp_bus_id_to_type[lbus] == MP_BUS_EISA ||
859 mp_bus_id_to_type[lbus] == MP_BUS_MCA || 865 mp_bus_id_to_type[lbus] == MP_BUS_MCA
860 mp_bus_id_to_type[lbus] == MP_BUS_NEC98
861 ) && 866 ) &&
862 (mp_irqs[i].mpc_irqtype == type) && 867 (mp_irqs[i].mpc_irqtype == type) &&
863 (mp_irqs[i].mpc_srcbusirq == irq)) 868 (mp_irqs[i].mpc_srcbusirq == irq))
@@ -987,12 +992,6 @@ static int EISA_ELCR(unsigned int irq)
987#define default_MCA_trigger(idx) (1) 992#define default_MCA_trigger(idx) (1)
988#define default_MCA_polarity(idx) (0) 993#define default_MCA_polarity(idx) (0)
989 994
990/* NEC98 interrupts are always polarity zero edge triggered,
991 * when listed as conforming in the MP table. */
992
993#define default_NEC98_trigger(idx) (0)
994#define default_NEC98_polarity(idx) (0)
995
996static int __init MPBIOS_polarity(int idx) 995static int __init MPBIOS_polarity(int idx)
997{ 996{
998 int bus = mp_irqs[idx].mpc_srcbus; 997 int bus = mp_irqs[idx].mpc_srcbus;
@@ -1027,11 +1026,6 @@ static int __init MPBIOS_polarity(int idx)
1027 polarity = default_MCA_polarity(idx); 1026 polarity = default_MCA_polarity(idx);
1028 break; 1027 break;
1029 } 1028 }
1030 case MP_BUS_NEC98: /* NEC 98 pin */
1031 {
1032 polarity = default_NEC98_polarity(idx);
1033 break;
1034 }
1035 default: 1029 default:
1036 { 1030 {
1037 printk(KERN_WARNING "broken BIOS!!\n"); 1031 printk(KERN_WARNING "broken BIOS!!\n");
@@ -1101,11 +1095,6 @@ static int MPBIOS_trigger(int idx)
1101 trigger = default_MCA_trigger(idx); 1095 trigger = default_MCA_trigger(idx);
1102 break; 1096 break;
1103 } 1097 }
1104 case MP_BUS_NEC98: /* NEC 98 pin */
1105 {
1106 trigger = default_NEC98_trigger(idx);
1107 break;
1108 }
1109 default: 1098 default:
1110 { 1099 {
1111 printk(KERN_WARNING "broken BIOS!!\n"); 1100 printk(KERN_WARNING "broken BIOS!!\n");
@@ -1167,7 +1156,6 @@ static int pin_2_irq(int idx, int apic, int pin)
1167 case MP_BUS_ISA: /* ISA pin */ 1156 case MP_BUS_ISA: /* ISA pin */
1168 case MP_BUS_EISA: 1157 case MP_BUS_EISA:
1169 case MP_BUS_MCA: 1158 case MP_BUS_MCA:
1170 case MP_BUS_NEC98:
1171 { 1159 {
1172 irq = mp_irqs[idx].mpc_srcbusirq; 1160 irq = mp_irqs[idx].mpc_srcbusirq;
1173 break; 1161 break;
@@ -1235,7 +1223,7 @@ static inline int IO_APIC_irq_trigger(int irq)
1235} 1223}
1236 1224
1237/* irq_vectors is indexed by the sum of all RTEs in all I/O APICs. */ 1225/* irq_vectors is indexed by the sum of all RTEs in all I/O APICs. */
1238u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 }; 1226static u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 };
1239 1227
1240static int __assign_irq_vector(int irq) 1228static int __assign_irq_vector(int irq)
1241{ 1229{
@@ -1360,8 +1348,8 @@ static void __init setup_IO_APIC_irqs(void)
1360 if (!apic && (irq < 16)) 1348 if (!apic && (irq < 16))
1361 disable_8259A_irq(irq); 1349 disable_8259A_irq(irq);
1362 } 1350 }
1363 ioapic_write_entry(apic, pin, entry);
1364 spin_lock_irqsave(&ioapic_lock, flags); 1351 spin_lock_irqsave(&ioapic_lock, flags);
1352 __ioapic_write_entry(apic, pin, entry);
1365 set_native_irq_info(irq, TARGET_CPUS); 1353 set_native_irq_info(irq, TARGET_CPUS);
1366 spin_unlock_irqrestore(&ioapic_lock, flags); 1354 spin_unlock_irqrestore(&ioapic_lock, flags);
1367 } 1355 }
@@ -1926,6 +1914,15 @@ static void __init setup_ioapic_ids_from_mpc(void)
1926static void __init setup_ioapic_ids_from_mpc(void) { } 1914static void __init setup_ioapic_ids_from_mpc(void) { }
1927#endif 1915#endif
1928 1916
1917static int no_timer_check __initdata;
1918
1919static int __init notimercheck(char *s)
1920{
1921 no_timer_check = 1;
1922 return 1;
1923}
1924__setup("no_timer_check", notimercheck);
1925
1929/* 1926/*
1930 * There is a nasty bug in some older SMP boards, their mptable lies 1927 * There is a nasty bug in some older SMP boards, their mptable lies
1931 * about the timer IRQ. We do the following to work around the situation: 1928 * about the timer IRQ. We do the following to work around the situation:
@@ -1934,10 +1931,13 @@ static void __init setup_ioapic_ids_from_mpc(void) { }
1934 * - if this function detects that timer IRQs are defunct, then we fall 1931 * - if this function detects that timer IRQs are defunct, then we fall
1935 * back to ISA timer IRQs 1932 * back to ISA timer IRQs
1936 */ 1933 */
1937static int __init timer_irq_works(void) 1934int __init timer_irq_works(void)
1938{ 1935{
1939 unsigned long t1 = jiffies; 1936 unsigned long t1 = jiffies;
1940 1937
1938 if (no_timer_check)
1939 return 1;
1940
1941 local_irq_enable(); 1941 local_irq_enable();
1942 /* Let ten ticks pass... */ 1942 /* Let ten ticks pass... */
1943 mdelay((10 * 1000) / HZ); 1943 mdelay((10 * 1000) / HZ);
@@ -2161,9 +2161,15 @@ static inline void unlock_ExtINT_logic(void)
2161 unsigned char save_control, save_freq_select; 2161 unsigned char save_control, save_freq_select;
2162 2162
2163 pin = find_isa_irq_pin(8, mp_INT); 2163 pin = find_isa_irq_pin(8, mp_INT);
2164 if (pin == -1) {
2165 WARN_ON_ONCE(1);
2166 return;
2167 }
2164 apic = find_isa_irq_apic(8, mp_INT); 2168 apic = find_isa_irq_apic(8, mp_INT);
2165 if (pin == -1) 2169 if (apic == -1) {
2170 WARN_ON_ONCE(1);
2166 return; 2171 return;
2172 }
2167 2173
2168 entry0 = ioapic_read_entry(apic, pin); 2174 entry0 = ioapic_read_entry(apic, pin);
2169 clear_IO_APIC_pin(apic, pin); 2175 clear_IO_APIC_pin(apic, pin);
@@ -2208,7 +2214,7 @@ int timer_uses_ioapic_pin_0;
2208 * is so screwy. Thanks to Brian Perkins for testing/hacking this beast 2214 * is so screwy. Thanks to Brian Perkins for testing/hacking this beast
2209 * fanatically on his truly buggy board. 2215 * fanatically on his truly buggy board.
2210 */ 2216 */
2211static inline void check_timer(void) 2217static inline void __init check_timer(void)
2212{ 2218{
2213 int apic1, pin1, apic2, pin2; 2219 int apic1, pin1, apic2, pin2;
2214 int vector; 2220 int vector;
@@ -2856,8 +2862,8 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
2856 if (!ioapic && (irq < 16)) 2862 if (!ioapic && (irq < 16))
2857 disable_8259A_irq(irq); 2863 disable_8259A_irq(irq);
2858 2864
2859 ioapic_write_entry(ioapic, pin, entry);
2860 spin_lock_irqsave(&ioapic_lock, flags); 2865 spin_lock_irqsave(&ioapic_lock, flags);
2866 __ioapic_write_entry(ioapic, pin, entry);
2861 set_native_irq_info(irq, TARGET_CPUS); 2867 set_native_irq_info(irq, TARGET_CPUS);
2862 spin_unlock_irqrestore(&ioapic_lock, flags); 2868 spin_unlock_irqrestore(&ioapic_lock, flags);
2863 2869
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index fc79e1e859c4..af1d53344993 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -184,7 +184,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
184void __kprobes arch_remove_kprobe(struct kprobe *p) 184void __kprobes arch_remove_kprobe(struct kprobe *p)
185{ 185{
186 mutex_lock(&kprobe_mutex); 186 mutex_lock(&kprobe_mutex);
187 free_insn_slot(p->ainsn.insn); 187 free_insn_slot(p->ainsn.insn, (p->ainsn.boostable == 1));
188 mutex_unlock(&kprobe_mutex); 188 mutex_unlock(&kprobe_mutex);
189} 189}
190 190
@@ -333,7 +333,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
333 return 1; 333 return 1;
334 334
335ss_probe: 335ss_probe:
336#ifndef CONFIG_PREEMPT 336#if !defined(CONFIG_PREEMPT) || defined(CONFIG_PM)
337 if (p->ainsn.boostable == 1 && !p->post_handler){ 337 if (p->ainsn.boostable == 1 && !p->post_handler){
338 /* Boost up -- we can execute copied instructions directly */ 338 /* Boost up -- we can execute copied instructions directly */
339 reset_current_kprobe(); 339 reset_current_kprobe();
diff --git a/arch/i386/kernel/ldt.c b/arch/i386/kernel/ldt.c
index 445211eb2d57..b410e5fb034f 100644
--- a/arch/i386/kernel/ldt.c
+++ b/arch/i386/kernel/ldt.c
@@ -160,16 +160,14 @@ static int read_default_ldt(void __user * ptr, unsigned long bytecount)
160{ 160{
161 int err; 161 int err;
162 unsigned long size; 162 unsigned long size;
163 void *address;
164 163
165 err = 0; 164 err = 0;
166 address = &default_ldt[0];
167 size = 5*sizeof(struct desc_struct); 165 size = 5*sizeof(struct desc_struct);
168 if (size > bytecount) 166 if (size > bytecount)
169 size = bytecount; 167 size = bytecount;
170 168
171 err = size; 169 err = size;
172 if (copy_to_user(ptr, address, size)) 170 if (clear_user(ptr, size))
173 err = -EFAULT; 171 err = -EFAULT;
174 172
175 return err; 173 return err;
diff --git a/arch/i386/kernel/mca.c b/arch/i386/kernel/mca.c
index eb57a851789d..b83672b89527 100644
--- a/arch/i386/kernel/mca.c
+++ b/arch/i386/kernel/mca.c
@@ -283,10 +283,9 @@ static int __init mca_init(void)
283 bus->f.mca_transform_memory = mca_dummy_transform_memory; 283 bus->f.mca_transform_memory = mca_dummy_transform_memory;
284 284
285 /* get the motherboard device */ 285 /* get the motherboard device */
286 mca_dev = kmalloc(sizeof(struct mca_device), GFP_KERNEL); 286 mca_dev = kzalloc(sizeof(struct mca_device), GFP_KERNEL);
287 if(unlikely(!mca_dev)) 287 if(unlikely(!mca_dev))
288 goto out_nomem; 288 goto out_nomem;
289 memset(mca_dev, 0, sizeof(struct mca_device));
290 289
291 /* 290 /*
292 * We do not expect many MCA interrupts during initialization, 291 * We do not expect many MCA interrupts during initialization,
@@ -310,11 +309,9 @@ static int __init mca_init(void)
310 mca_dev->slot = MCA_MOTHERBOARD; 309 mca_dev->slot = MCA_MOTHERBOARD;
311 mca_register_device(MCA_PRIMARY_BUS, mca_dev); 310 mca_register_device(MCA_PRIMARY_BUS, mca_dev);
312 311
313 mca_dev = kmalloc(sizeof(struct mca_device), GFP_ATOMIC); 312 mca_dev = kzalloc(sizeof(struct mca_device), GFP_ATOMIC);
314 if(unlikely(!mca_dev)) 313 if(unlikely(!mca_dev))
315 goto out_unlock_nomem; 314 goto out_unlock_nomem;
316 memset(mca_dev, 0, sizeof(struct mca_device));
317
318 315
319 /* Put motherboard into video setup mode, read integrated video 316 /* Put motherboard into video setup mode, read integrated video
320 * POS registers, and turn motherboard setup off. 317 * POS registers, and turn motherboard setup off.
@@ -349,10 +346,9 @@ static int __init mca_init(void)
349 } 346 }
350 if(which_scsi) { 347 if(which_scsi) {
351 /* found a scsi card */ 348 /* found a scsi card */
352 mca_dev = kmalloc(sizeof(struct mca_device), GFP_ATOMIC); 349 mca_dev = kzalloc(sizeof(struct mca_device), GFP_ATOMIC);
353 if(unlikely(!mca_dev)) 350 if(unlikely(!mca_dev))
354 goto out_unlock_nomem; 351 goto out_unlock_nomem;
355 memset(mca_dev, 0, sizeof(struct mca_device));
356 352
357 for(j = 0; j < 8; j++) 353 for(j = 0; j < 8; j++)
358 mca_dev->pos[j] = pos[j]; 354 mca_dev->pos[j] = pos[j];
@@ -378,10 +374,9 @@ static int __init mca_init(void)
378 if(!mca_read_and_store_pos(pos)) 374 if(!mca_read_and_store_pos(pos))
379 continue; 375 continue;
380 376
381 mca_dev = kmalloc(sizeof(struct mca_device), GFP_ATOMIC); 377 mca_dev = kzalloc(sizeof(struct mca_device), GFP_ATOMIC);
382 if(unlikely(!mca_dev)) 378 if(unlikely(!mca_dev))
383 goto out_unlock_nomem; 379 goto out_unlock_nomem;
384 memset(mca_dev, 0, sizeof(struct mca_device));
385 380
386 for(j=0; j<8; j++) 381 for(j=0; j<8; j++)
387 mca_dev->pos[j]=pos[j]; 382 mca_dev->pos[j]=pos[j];
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 23f5984d0654..972346604f9d 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -703,7 +703,6 @@ static struct sysdev_driver mc_sysdev_driver = {
703 .resume = mc_sysdev_resume, 703 .resume = mc_sysdev_resume,
704}; 704};
705 705
706#ifdef CONFIG_HOTPLUG_CPU
707static __cpuinit int 706static __cpuinit int
708mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) 707mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
709{ 708{
@@ -726,7 +725,6 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
726static struct notifier_block mc_cpu_notifier = { 725static struct notifier_block mc_cpu_notifier = {
727 .notifier_call = mc_cpu_callback, 726 .notifier_call = mc_cpu_callback,
728}; 727};
729#endif
730 728
731static int __init microcode_init (void) 729static int __init microcode_init (void)
732{ 730{
diff --git a/arch/i386/kernel/module.c b/arch/i386/kernel/module.c
index 470cf97e7cd3..d7d9c8b23f72 100644
--- a/arch/i386/kernel/module.c
+++ b/arch/i386/kernel/module.c
@@ -108,7 +108,8 @@ int module_finalize(const Elf_Ehdr *hdr,
108 const Elf_Shdr *sechdrs, 108 const Elf_Shdr *sechdrs,
109 struct module *me) 109 struct module *me)
110{ 110{
111 const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL; 111 const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL,
112 *para = NULL;
112 char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; 113 char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
113 114
114 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) { 115 for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
@@ -118,6 +119,8 @@ int module_finalize(const Elf_Ehdr *hdr,
118 alt = s; 119 alt = s;
119 if (!strcmp(".smp_locks", secstrings + s->sh_name)) 120 if (!strcmp(".smp_locks", secstrings + s->sh_name))
120 locks= s; 121 locks= s;
122 if (!strcmp(".parainstructions", secstrings + s->sh_name))
123 para = s;
121 } 124 }
122 125
123 if (alt) { 126 if (alt) {
@@ -132,6 +135,12 @@ int module_finalize(const Elf_Ehdr *hdr,
132 lseg, lseg + locks->sh_size, 135 lseg, lseg + locks->sh_size,
133 tseg, tseg + text->sh_size); 136 tseg, tseg + text->sh_size);
134 } 137 }
138
139 if (para) {
140 void *pseg = (void *)para->sh_addr;
141 apply_paravirt(pseg, pseg + para->sh_size);
142 }
143
135 return 0; 144 return 0;
136} 145}
137 146
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
index 442aaf8c77eb..2ce67228dff8 100644
--- a/arch/i386/kernel/mpparse.c
+++ b/arch/i386/kernel/mpparse.c
@@ -249,8 +249,6 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
249 mp_current_pci_id++; 249 mp_current_pci_id++;
250 } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA)-1) == 0) { 250 } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA)-1) == 0) {
251 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA; 251 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA;
252 } else if (strncmp(str, BUSTYPE_NEC98, sizeof(BUSTYPE_NEC98)-1) == 0) {
253 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_NEC98;
254 } else { 252 } else {
255 printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str); 253 printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str);
256 } 254 }
diff --git a/arch/i386/kernel/msr.c b/arch/i386/kernel/msr.c
index a773f776c9ea..1d1a56cae340 100644
--- a/arch/i386/kernel/msr.c
+++ b/arch/i386/kernel/msr.c
@@ -195,7 +195,6 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
195{ 195{
196 const u32 __user *tmp = (const u32 __user *)buf; 196 const u32 __user *tmp = (const u32 __user *)buf;
197 u32 data[2]; 197 u32 data[2];
198 size_t rv;
199 u32 reg = *ppos; 198 u32 reg = *ppos;
200 int cpu = iminor(file->f_dentry->d_inode); 199 int cpu = iminor(file->f_dentry->d_inode);
201 int err; 200 int err;
@@ -203,7 +202,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
203 if (count % 8) 202 if (count % 8)
204 return -EINVAL; /* Invalid chunk size */ 203 return -EINVAL; /* Invalid chunk size */
205 204
206 for (rv = 0; count; count -= 8) { 205 for (; count; count -= 8) {
207 if (copy_from_user(&data, tmp, 8)) 206 if (copy_from_user(&data, tmp, 8))
208 return -EFAULT; 207 return -EFAULT;
209 err = do_wrmsr(cpu, reg, data[0], data[1]); 208 err = do_wrmsr(cpu, reg, data[0], data[1]);
@@ -250,7 +249,6 @@ static int msr_device_create(int i)
250 return err; 249 return err;
251} 250}
252 251
253#ifdef CONFIG_HOTPLUG_CPU
254static int msr_class_cpu_callback(struct notifier_block *nfb, 252static int msr_class_cpu_callback(struct notifier_block *nfb,
255 unsigned long action, void *hcpu) 253 unsigned long action, void *hcpu)
256{ 254{
@@ -271,7 +269,6 @@ static struct notifier_block __cpuinitdata msr_class_cpu_notifier =
271{ 269{
272 .notifier_call = msr_class_cpu_callback, 270 .notifier_call = msr_class_cpu_callback,
273}; 271};
274#endif
275 272
276static int __init msr_init(void) 273static int __init msr_init(void)
277{ 274{
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index eaafe233a5da..f5bc7e1be801 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -22,6 +22,7 @@
22#include <linux/percpu.h> 22#include <linux/percpu.h>
23#include <linux/dmi.h> 23#include <linux/dmi.h>
24#include <linux/kprobes.h> 24#include <linux/kprobes.h>
25#include <linux/cpumask.h>
25 26
26#include <asm/smp.h> 27#include <asm/smp.h>
27#include <asm/nmi.h> 28#include <asm/nmi.h>
@@ -42,6 +43,8 @@ int nmi_watchdog_enabled;
42static DEFINE_PER_CPU(unsigned long, perfctr_nmi_owner); 43static DEFINE_PER_CPU(unsigned long, perfctr_nmi_owner);
43static DEFINE_PER_CPU(unsigned long, evntsel_nmi_owner[3]); 44static DEFINE_PER_CPU(unsigned long, evntsel_nmi_owner[3]);
44 45
46static cpumask_t backtrace_mask = CPU_MASK_NONE;
47
45/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's 48/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's
46 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now) 49 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now)
47 */ 50 */
@@ -867,14 +870,16 @@ static unsigned int
867 870
868void touch_nmi_watchdog (void) 871void touch_nmi_watchdog (void)
869{ 872{
870 int i; 873 if (nmi_watchdog > 0) {
874 unsigned cpu;
871 875
872 /* 876 /*
873 * Just reset the alert counters, (other CPUs might be 877 * Just reset the alert counters, (other CPUs might be
874 * spinning on locks we hold): 878 * spinning on locks we hold):
875 */ 879 */
876 for_each_possible_cpu(i) 880 for_each_present_cpu (cpu)
877 alert_counter[i] = 0; 881 alert_counter[cpu] = 0;
882 }
878 883
879 /* 884 /*
880 * Tickle the softlockup detector too: 885 * Tickle the softlockup detector too:
@@ -907,6 +912,16 @@ __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
907 touched = 1; 912 touched = 1;
908 } 913 }
909 914
915 if (cpu_isset(cpu, backtrace_mask)) {
916 static DEFINE_SPINLOCK(lock); /* Serialise the printks */
917
918 spin_lock(&lock);
919 printk("NMI backtrace for cpu %d\n", cpu);
920 dump_stack();
921 spin_unlock(&lock);
922 cpu_clear(cpu, backtrace_mask);
923 }
924
910 sum = per_cpu(irq_stat, cpu).apic_timer_irqs; 925 sum = per_cpu(irq_stat, cpu).apic_timer_irqs;
911 926
912 /* if the apic timer isn't firing, this cpu isn't doing much */ 927 /* if the apic timer isn't firing, this cpu isn't doing much */
@@ -1033,6 +1048,19 @@ int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
1033 1048
1034#endif 1049#endif
1035 1050
1051void __trigger_all_cpu_backtrace(void)
1052{
1053 int i;
1054
1055 backtrace_mask = cpu_online_map;
1056 /* Wait for up to 10 seconds for all CPUs to do the backtrace */
1057 for (i = 0; i < 10 * 1000; i++) {
1058 if (cpus_empty(backtrace_mask))
1059 break;
1060 mdelay(1);
1061 }
1062}
1063
1036EXPORT_SYMBOL(nmi_active); 1064EXPORT_SYMBOL(nmi_active);
1037EXPORT_SYMBOL(nmi_watchdog); 1065EXPORT_SYMBOL(nmi_watchdog);
1038EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi); 1066EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi);
diff --git a/arch/i386/kernel/paravirt.c b/arch/i386/kernel/paravirt.c
new file mode 100644
index 000000000000..3dceab5828f1
--- /dev/null
+++ b/arch/i386/kernel/paravirt.c
@@ -0,0 +1,569 @@
1/* Paravirtualization interfaces
2 Copyright (C) 2006 Rusty Russell IBM Corporation
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17*/
18#include <linux/errno.h>
19#include <linux/module.h>
20#include <linux/efi.h>
21#include <linux/bcd.h>
22#include <linux/start_kernel.h>
23
24#include <asm/bug.h>
25#include <asm/paravirt.h>
26#include <asm/desc.h>
27#include <asm/setup.h>
28#include <asm/arch_hooks.h>
29#include <asm/time.h>
30#include <asm/irq.h>
31#include <asm/delay.h>
32#include <asm/fixmap.h>
33#include <asm/apic.h>
34#include <asm/tlbflush.h>
35
36/* nop stub */
37static void native_nop(void)
38{
39}
40
41static void __init default_banner(void)
42{
43 printk(KERN_INFO "Booting paravirtualized kernel on %s\n",
44 paravirt_ops.name);
45}
46
47char *memory_setup(void)
48{
49 return paravirt_ops.memory_setup();
50}
51
52/* Simple instruction patching code. */
53#define DEF_NATIVE(name, code) \
54 extern const char start_##name[], end_##name[]; \
55 asm("start_" #name ": " code "; end_" #name ":")
56DEF_NATIVE(cli, "cli");
57DEF_NATIVE(sti, "sti");
58DEF_NATIVE(popf, "push %eax; popf");
59DEF_NATIVE(pushf, "pushf; pop %eax");
60DEF_NATIVE(pushf_cli, "pushf; pop %eax; cli");
61DEF_NATIVE(iret, "iret");
62DEF_NATIVE(sti_sysexit, "sti; sysexit");
63
64static const struct native_insns
65{
66 const char *start, *end;
67} native_insns[] = {
68 [PARAVIRT_IRQ_DISABLE] = { start_cli, end_cli },
69 [PARAVIRT_IRQ_ENABLE] = { start_sti, end_sti },
70 [PARAVIRT_RESTORE_FLAGS] = { start_popf, end_popf },
71 [PARAVIRT_SAVE_FLAGS] = { start_pushf, end_pushf },
72 [PARAVIRT_SAVE_FLAGS_IRQ_DISABLE] = { start_pushf_cli, end_pushf_cli },
73 [PARAVIRT_INTERRUPT_RETURN] = { start_iret, end_iret },
74 [PARAVIRT_STI_SYSEXIT] = { start_sti_sysexit, end_sti_sysexit },
75};
76
77static unsigned native_patch(u8 type, u16 clobbers, void *insns, unsigned len)
78{
79 unsigned int insn_len;
80
81 /* Don't touch it if we don't have a replacement */
82 if (type >= ARRAY_SIZE(native_insns) || !native_insns[type].start)
83 return len;
84
85 insn_len = native_insns[type].end - native_insns[type].start;
86
87 /* Similarly if we can't fit replacement. */
88 if (len < insn_len)
89 return len;
90
91 memcpy(insns, native_insns[type].start, insn_len);
92 return insn_len;
93}
94
95static fastcall unsigned long native_get_debugreg(int regno)
96{
97 unsigned long val = 0; /* Damn you, gcc! */
98
99 switch (regno) {
100 case 0:
101 asm("movl %%db0, %0" :"=r" (val)); break;
102 case 1:
103 asm("movl %%db1, %0" :"=r" (val)); break;
104 case 2:
105 asm("movl %%db2, %0" :"=r" (val)); break;
106 case 3:
107 asm("movl %%db3, %0" :"=r" (val)); break;
108 case 6:
109 asm("movl %%db6, %0" :"=r" (val)); break;
110 case 7:
111 asm("movl %%db7, %0" :"=r" (val)); break;
112 default:
113 BUG();
114 }
115 return val;
116}
117
118static fastcall void native_set_debugreg(int regno, unsigned long value)
119{
120 switch (regno) {
121 case 0:
122 asm("movl %0,%%db0" : /* no output */ :"r" (value));
123 break;
124 case 1:
125 asm("movl %0,%%db1" : /* no output */ :"r" (value));
126 break;
127 case 2:
128 asm("movl %0,%%db2" : /* no output */ :"r" (value));
129 break;
130 case 3:
131 asm("movl %0,%%db3" : /* no output */ :"r" (value));
132 break;
133 case 6:
134 asm("movl %0,%%db6" : /* no output */ :"r" (value));
135 break;
136 case 7:
137 asm("movl %0,%%db7" : /* no output */ :"r" (value));
138 break;
139 default:
140 BUG();
141 }
142}
143
144void init_IRQ(void)
145{
146 paravirt_ops.init_IRQ();
147}
148
149static fastcall void native_clts(void)
150{
151 asm volatile ("clts");
152}
153
154static fastcall unsigned long native_read_cr0(void)
155{
156 unsigned long val;
157 asm volatile("movl %%cr0,%0\n\t" :"=r" (val));
158 return val;
159}
160
161static fastcall void native_write_cr0(unsigned long val)
162{
163 asm volatile("movl %0,%%cr0": :"r" (val));
164}
165
166static fastcall unsigned long native_read_cr2(void)
167{
168 unsigned long val;
169 asm volatile("movl %%cr2,%0\n\t" :"=r" (val));
170 return val;
171}
172
173static fastcall void native_write_cr2(unsigned long val)
174{
175 asm volatile("movl %0,%%cr2": :"r" (val));
176}
177
178static fastcall unsigned long native_read_cr3(void)
179{
180 unsigned long val;
181 asm volatile("movl %%cr3,%0\n\t" :"=r" (val));
182 return val;
183}
184
185static fastcall void native_write_cr3(unsigned long val)
186{
187 asm volatile("movl %0,%%cr3": :"r" (val));
188}
189
190static fastcall unsigned long native_read_cr4(void)
191{
192 unsigned long val;
193 asm volatile("movl %%cr4,%0\n\t" :"=r" (val));
194 return val;
195}
196
197static fastcall unsigned long native_read_cr4_safe(void)
198{
199 unsigned long val;
200 /* This could fault if %cr4 does not exist */
201 asm("1: movl %%cr4, %0 \n"
202 "2: \n"
203 ".section __ex_table,\"a\" \n"
204 ".long 1b,2b \n"
205 ".previous \n"
206 : "=r" (val): "0" (0));
207 return val;
208}
209
210static fastcall void native_write_cr4(unsigned long val)
211{
212 asm volatile("movl %0,%%cr4": :"r" (val));
213}
214
215static fastcall unsigned long native_save_fl(void)
216{
217 unsigned long f;
218 asm volatile("pushfl ; popl %0":"=g" (f): /* no input */);
219 return f;
220}
221
222static fastcall void native_restore_fl(unsigned long f)
223{
224 asm volatile("pushl %0 ; popfl": /* no output */
225 :"g" (f)
226 :"memory", "cc");
227}
228
229static fastcall void native_irq_disable(void)
230{
231 asm volatile("cli": : :"memory");
232}
233
234static fastcall void native_irq_enable(void)
235{
236 asm volatile("sti": : :"memory");
237}
238
239static fastcall void native_safe_halt(void)
240{
241 asm volatile("sti; hlt": : :"memory");
242}
243
244static fastcall void native_halt(void)
245{
246 asm volatile("hlt": : :"memory");
247}
248
249static fastcall void native_wbinvd(void)
250{
251 asm volatile("wbinvd": : :"memory");
252}
253
254static fastcall unsigned long long native_read_msr(unsigned int msr, int *err)
255{
256 unsigned long long val;
257
258 asm volatile("2: rdmsr ; xorl %0,%0\n"
259 "1:\n\t"
260 ".section .fixup,\"ax\"\n\t"
261 "3: movl %3,%0 ; jmp 1b\n\t"
262 ".previous\n\t"
263 ".section __ex_table,\"a\"\n"
264 " .align 4\n\t"
265 " .long 2b,3b\n\t"
266 ".previous"
267 : "=r" (*err), "=A" (val)
268 : "c" (msr), "i" (-EFAULT));
269
270 return val;
271}
272
273static fastcall int native_write_msr(unsigned int msr, unsigned long long val)
274{
275 int err;
276 asm volatile("2: wrmsr ; xorl %0,%0\n"
277 "1:\n\t"
278 ".section .fixup,\"ax\"\n\t"
279 "3: movl %4,%0 ; jmp 1b\n\t"
280 ".previous\n\t"
281 ".section __ex_table,\"a\"\n"
282 " .align 4\n\t"
283 " .long 2b,3b\n\t"
284 ".previous"
285 : "=a" (err)
286 : "c" (msr), "0" ((u32)val), "d" ((u32)(val>>32)),
287 "i" (-EFAULT));
288 return err;
289}
290
291static fastcall unsigned long long native_read_tsc(void)
292{
293 unsigned long long val;
294 asm volatile("rdtsc" : "=A" (val));
295 return val;
296}
297
298static fastcall unsigned long long native_read_pmc(void)
299{
300 unsigned long long val;
301 asm volatile("rdpmc" : "=A" (val));
302 return val;
303}
304
305static fastcall void native_load_tr_desc(void)
306{
307 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
308}
309
310static fastcall void native_load_gdt(const struct Xgt_desc_struct *dtr)
311{
312 asm volatile("lgdt %0"::"m" (*dtr));
313}
314
315static fastcall void native_load_idt(const struct Xgt_desc_struct *dtr)
316{
317 asm volatile("lidt %0"::"m" (*dtr));
318}
319
320static fastcall void native_store_gdt(struct Xgt_desc_struct *dtr)
321{
322 asm ("sgdt %0":"=m" (*dtr));
323}
324
325static fastcall void native_store_idt(struct Xgt_desc_struct *dtr)
326{
327 asm ("sidt %0":"=m" (*dtr));
328}
329
330static fastcall unsigned long native_store_tr(void)
331{
332 unsigned long tr;
333 asm ("str %0":"=r" (tr));
334 return tr;
335}
336
337static fastcall void native_load_tls(struct thread_struct *t, unsigned int cpu)
338{
339#define C(i) get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]
340 C(0); C(1); C(2);
341#undef C
342}
343
344static inline void native_write_dt_entry(void *dt, int entry, u32 entry_low, u32 entry_high)
345{
346 u32 *lp = (u32 *)((char *)dt + entry*8);
347 lp[0] = entry_low;
348 lp[1] = entry_high;
349}
350
351static fastcall void native_write_ldt_entry(void *dt, int entrynum, u32 low, u32 high)
352{
353 native_write_dt_entry(dt, entrynum, low, high);
354}
355
356static fastcall void native_write_gdt_entry(void *dt, int entrynum, u32 low, u32 high)
357{
358 native_write_dt_entry(dt, entrynum, low, high);
359}
360
361static fastcall void native_write_idt_entry(void *dt, int entrynum, u32 low, u32 high)
362{
363 native_write_dt_entry(dt, entrynum, low, high);
364}
365
366static fastcall void native_load_esp0(struct tss_struct *tss,
367 struct thread_struct *thread)
368{
369 tss->esp0 = thread->esp0;
370
371 /* This can only happen when SEP is enabled, no need to test "SEP"arately */
372 if (unlikely(tss->ss1 != thread->sysenter_cs)) {
373 tss->ss1 = thread->sysenter_cs;
374 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
375 }
376}
377
378static fastcall void native_io_delay(void)
379{
380 asm volatile("outb %al,$0x80");
381}
382
383static fastcall void native_flush_tlb(void)
384{
385 __native_flush_tlb();
386}
387
388/*
389 * Global pages have to be flushed a bit differently. Not a real
390 * performance problem because this does not happen often.
391 */
392static fastcall void native_flush_tlb_global(void)
393{
394 __native_flush_tlb_global();
395}
396
397static fastcall void native_flush_tlb_single(u32 addr)
398{
399 __native_flush_tlb_single(addr);
400}
401
402#ifndef CONFIG_X86_PAE
403static fastcall void native_set_pte(pte_t *ptep, pte_t pteval)
404{
405 *ptep = pteval;
406}
407
408static fastcall void native_set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pteval)
409{
410 *ptep = pteval;
411}
412
413static fastcall void native_set_pmd(pmd_t *pmdp, pmd_t pmdval)
414{
415 *pmdp = pmdval;
416}
417
418#else /* CONFIG_X86_PAE */
419
420static fastcall void native_set_pte(pte_t *ptep, pte_t pte)
421{
422 ptep->pte_high = pte.pte_high;
423 smp_wmb();
424 ptep->pte_low = pte.pte_low;
425}
426
427static fastcall void native_set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pte)
428{
429 ptep->pte_high = pte.pte_high;
430 smp_wmb();
431 ptep->pte_low = pte.pte_low;
432}
433
434static fastcall void native_set_pte_present(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
435{
436 ptep->pte_low = 0;
437 smp_wmb();
438 ptep->pte_high = pte.pte_high;
439 smp_wmb();
440 ptep->pte_low = pte.pte_low;
441}
442
443static fastcall void native_set_pte_atomic(pte_t *ptep, pte_t pteval)
444{
445 set_64bit((unsigned long long *)ptep,pte_val(pteval));
446}
447
448static fastcall void native_set_pmd(pmd_t *pmdp, pmd_t pmdval)
449{
450 set_64bit((unsigned long long *)pmdp,pmd_val(pmdval));
451}
452
453static fastcall void native_set_pud(pud_t *pudp, pud_t pudval)
454{
455 *pudp = pudval;
456}
457
458static fastcall void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
459{
460 ptep->pte_low = 0;
461 smp_wmb();
462 ptep->pte_high = 0;
463}
464
465static fastcall void native_pmd_clear(pmd_t *pmd)
466{
467 u32 *tmp = (u32 *)pmd;
468 *tmp = 0;
469 smp_wmb();
470 *(tmp + 1) = 0;
471}
472#endif /* CONFIG_X86_PAE */
473
474/* These are in entry.S */
475extern fastcall void native_iret(void);
476extern fastcall void native_irq_enable_sysexit(void);
477
478static int __init print_banner(void)
479{
480 paravirt_ops.banner();
481 return 0;
482}
483core_initcall(print_banner);
484
485/* We simply declare start_kernel to be the paravirt probe of last resort. */
486paravirt_probe(start_kernel);
487
488struct paravirt_ops paravirt_ops = {
489 .name = "bare hardware",
490 .paravirt_enabled = 0,
491 .kernel_rpl = 0,
492
493 .patch = native_patch,
494 .banner = default_banner,
495 .arch_setup = native_nop,
496 .memory_setup = machine_specific_memory_setup,
497 .get_wallclock = native_get_wallclock,
498 .set_wallclock = native_set_wallclock,
499 .time_init = time_init_hook,
500 .init_IRQ = native_init_IRQ,
501
502 .cpuid = native_cpuid,
503 .get_debugreg = native_get_debugreg,
504 .set_debugreg = native_set_debugreg,
505 .clts = native_clts,
506 .read_cr0 = native_read_cr0,
507 .write_cr0 = native_write_cr0,
508 .read_cr2 = native_read_cr2,
509 .write_cr2 = native_write_cr2,
510 .read_cr3 = native_read_cr3,
511 .write_cr3 = native_write_cr3,
512 .read_cr4 = native_read_cr4,
513 .read_cr4_safe = native_read_cr4_safe,
514 .write_cr4 = native_write_cr4,
515 .save_fl = native_save_fl,
516 .restore_fl = native_restore_fl,
517 .irq_disable = native_irq_disable,
518 .irq_enable = native_irq_enable,
519 .safe_halt = native_safe_halt,
520 .halt = native_halt,
521 .wbinvd = native_wbinvd,
522 .read_msr = native_read_msr,
523 .write_msr = native_write_msr,
524 .read_tsc = native_read_tsc,
525 .read_pmc = native_read_pmc,
526 .load_tr_desc = native_load_tr_desc,
527 .set_ldt = native_set_ldt,
528 .load_gdt = native_load_gdt,
529 .load_idt = native_load_idt,
530 .store_gdt = native_store_gdt,
531 .store_idt = native_store_idt,
532 .store_tr = native_store_tr,
533 .load_tls = native_load_tls,
534 .write_ldt_entry = native_write_ldt_entry,
535 .write_gdt_entry = native_write_gdt_entry,
536 .write_idt_entry = native_write_idt_entry,
537 .load_esp0 = native_load_esp0,
538
539 .set_iopl_mask = native_set_iopl_mask,
540 .io_delay = native_io_delay,
541 .const_udelay = __const_udelay,
542
543#ifdef CONFIG_X86_LOCAL_APIC
544 .apic_write = native_apic_write,
545 .apic_write_atomic = native_apic_write_atomic,
546 .apic_read = native_apic_read,
547#endif
548
549 .flush_tlb_user = native_flush_tlb,
550 .flush_tlb_kernel = native_flush_tlb_global,
551 .flush_tlb_single = native_flush_tlb_single,
552
553 .set_pte = native_set_pte,
554 .set_pte_at = native_set_pte_at,
555 .set_pmd = native_set_pmd,
556 .pte_update = (void *)native_nop,
557 .pte_update_defer = (void *)native_nop,
558#ifdef CONFIG_X86_PAE
559 .set_pte_atomic = native_set_pte_atomic,
560 .set_pte_present = native_set_pte_present,
561 .set_pud = native_set_pud,
562 .pte_clear = native_pte_clear,
563 .pmd_clear = native_pmd_clear,
564#endif
565
566 .irq_enable_sysexit = native_irq_enable_sysexit,
567 .iret = native_iret,
568};
569EXPORT_SYMBOL(paravirt_ops);
diff --git a/arch/i386/kernel/pci-dma.c b/arch/i386/kernel/pci-dma.c
index 5c8c6ef1fc5e..41af692c1584 100644
--- a/arch/i386/kernel/pci-dma.c
+++ b/arch/i386/kernel/pci-dma.c
@@ -92,14 +92,12 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
92 if (!mem_base) 92 if (!mem_base)
93 goto out; 93 goto out;
94 94
95 dev->dma_mem = kmalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL); 95 dev->dma_mem = kzalloc(sizeof(struct dma_coherent_mem), GFP_KERNEL);
96 if (!dev->dma_mem) 96 if (!dev->dma_mem)
97 goto out; 97 goto out;
98 memset(dev->dma_mem, 0, sizeof(struct dma_coherent_mem)); 98 dev->dma_mem->bitmap = kzalloc(bitmap_size, GFP_KERNEL);
99 dev->dma_mem->bitmap = kmalloc(bitmap_size, GFP_KERNEL);
100 if (!dev->dma_mem->bitmap) 99 if (!dev->dma_mem->bitmap)
101 goto free1_out; 100 goto free1_out;
102 memset(dev->dma_mem->bitmap, 0, bitmap_size);
103 101
104 dev->dma_mem->virt_base = mem_base; 102 dev->dma_mem->virt_base = mem_base;
105 dev->dma_mem->device_base = device_addr; 103 dev->dma_mem->device_base = device_addr;
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index dd53c58f64f1..99308510a17c 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -56,6 +56,7 @@
56 56
57#include <asm/tlbflush.h> 57#include <asm/tlbflush.h>
58#include <asm/cpu.h> 58#include <asm/cpu.h>
59#include <asm/pda.h>
59 60
60asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); 61asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
61 62
@@ -99,22 +100,18 @@ EXPORT_SYMBOL(enable_hlt);
99 */ 100 */
100void default_idle(void) 101void default_idle(void)
101{ 102{
102 local_irq_enable();
103
104 if (!hlt_counter && boot_cpu_data.hlt_works_ok) { 103 if (!hlt_counter && boot_cpu_data.hlt_works_ok) {
105 current_thread_info()->status &= ~TS_POLLING; 104 current_thread_info()->status &= ~TS_POLLING;
106 smp_mb__after_clear_bit(); 105 smp_mb__after_clear_bit();
107 while (!need_resched()) { 106 local_irq_disable();
108 local_irq_disable(); 107 if (!need_resched())
109 if (!need_resched()) 108 safe_halt(); /* enables interrupts racelessly */
110 safe_halt(); 109 else
111 else 110 local_irq_enable();
112 local_irq_enable();
113 }
114 current_thread_info()->status |= TS_POLLING; 111 current_thread_info()->status |= TS_POLLING;
115 } else { 112 } else {
116 while (!need_resched()) 113 /* loop is done by the caller */
117 cpu_relax(); 114 cpu_relax();
118 } 115 }
119} 116}
120#ifdef CONFIG_APM_MODULE 117#ifdef CONFIG_APM_MODULE
@@ -128,14 +125,7 @@ EXPORT_SYMBOL(default_idle);
128 */ 125 */
129static void poll_idle (void) 126static void poll_idle (void)
130{ 127{
131 local_irq_enable(); 128 cpu_relax();
132
133 asm volatile(
134 "2:"
135 "testl %0, %1;"
136 "rep; nop;"
137 "je 2b;"
138 : : "i"(_TIF_NEED_RESCHED), "m" (current_thread_info()->flags));
139} 129}
140 130
141#ifdef CONFIG_HOTPLUG_CPU 131#ifdef CONFIG_HOTPLUG_CPU
@@ -256,8 +246,7 @@ void mwait_idle_with_hints(unsigned long eax, unsigned long ecx)
256static void mwait_idle(void) 246static void mwait_idle(void)
257{ 247{
258 local_irq_enable(); 248 local_irq_enable();
259 while (!need_resched()) 249 mwait_idle_with_hints(0, 0);
260 mwait_idle_with_hints(0, 0);
261} 250}
262 251
263void __devinit select_idle_routine(const struct cpuinfo_x86 *c) 252void __devinit select_idle_routine(const struct cpuinfo_x86 *c)
@@ -314,8 +303,8 @@ void show_regs(struct pt_regs * regs)
314 regs->eax,regs->ebx,regs->ecx,regs->edx); 303 regs->eax,regs->ebx,regs->ecx,regs->edx);
315 printk("ESI: %08lx EDI: %08lx EBP: %08lx", 304 printk("ESI: %08lx EDI: %08lx EBP: %08lx",
316 regs->esi, regs->edi, regs->ebp); 305 regs->esi, regs->edi, regs->ebp);
317 printk(" DS: %04x ES: %04x\n", 306 printk(" DS: %04x ES: %04x GS: %04x\n",
318 0xffff & regs->xds,0xffff & regs->xes); 307 0xffff & regs->xds,0xffff & regs->xes, 0xffff & regs->xgs);
319 308
320 cr0 = read_cr0(); 309 cr0 = read_cr0();
321 cr2 = read_cr2(); 310 cr2 = read_cr2();
@@ -346,6 +335,7 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
346 335
347 regs.xds = __USER_DS; 336 regs.xds = __USER_DS;
348 regs.xes = __USER_DS; 337 regs.xes = __USER_DS;
338 regs.xgs = __KERNEL_PDA;
349 regs.orig_eax = -1; 339 regs.orig_eax = -1;
350 regs.eip = (unsigned long) kernel_thread_helper; 340 regs.eip = (unsigned long) kernel_thread_helper;
351 regs.xcs = __KERNEL_CS | get_kernel_rpl(); 341 regs.xcs = __KERNEL_CS | get_kernel_rpl();
@@ -431,7 +421,6 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long esp,
431 p->thread.eip = (unsigned long) ret_from_fork; 421 p->thread.eip = (unsigned long) ret_from_fork;
432 422
433 savesegment(fs,p->thread.fs); 423 savesegment(fs,p->thread.fs);
434 savesegment(gs,p->thread.gs);
435 424
436 tsk = current; 425 tsk = current;
437 if (unlikely(test_tsk_thread_flag(tsk, TIF_IO_BITMAP))) { 426 if (unlikely(test_tsk_thread_flag(tsk, TIF_IO_BITMAP))) {
@@ -508,7 +497,7 @@ void dump_thread(struct pt_regs * regs, struct user * dump)
508 dump->regs.ds = regs->xds; 497 dump->regs.ds = regs->xds;
509 dump->regs.es = regs->xes; 498 dump->regs.es = regs->xes;
510 savesegment(fs,dump->regs.fs); 499 savesegment(fs,dump->regs.fs);
511 savesegment(gs,dump->regs.gs); 500 dump->regs.gs = regs->xgs;
512 dump->regs.orig_eax = regs->orig_eax; 501 dump->regs.orig_eax = regs->orig_eax;
513 dump->regs.eip = regs->eip; 502 dump->regs.eip = regs->eip;
514 dump->regs.cs = regs->xcs; 503 dump->regs.cs = regs->xcs;
@@ -648,22 +637,27 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
648 637
649 __unlazy_fpu(prev_p); 638 __unlazy_fpu(prev_p);
650 639
640
641 /* we're going to use this soon, after a few expensive things */
642 if (next_p->fpu_counter > 5)
643 prefetch(&next->i387.fxsave);
644
651 /* 645 /*
652 * Reload esp0. 646 * Reload esp0.
653 */ 647 */
654 load_esp0(tss, next); 648 load_esp0(tss, next);
655 649
656 /* 650 /*
657 * Save away %fs and %gs. No need to save %es and %ds, as 651 * Save away %fs. No need to save %gs, as it was saved on the
658 * those are always kernel segments while inside the kernel. 652 * stack on entry. No need to save %es and %ds, as those are
659 * Doing this before setting the new TLS descriptors avoids 653 * always kernel segments while inside the kernel. Doing this
660 * the situation where we temporarily have non-reloadable 654 * before setting the new TLS descriptors avoids the situation
661 * segments in %fs and %gs. This could be an issue if the 655 * where we temporarily have non-reloadable segments in %fs
662 * NMI handler ever used %fs or %gs (it does not today), or 656 * and %gs. This could be an issue if the NMI handler ever
663 * if the kernel is running inside of a hypervisor layer. 657 * used %fs or %gs (it does not today), or if the kernel is
658 * running inside of a hypervisor layer.
664 */ 659 */
665 savesegment(fs, prev->fs); 660 savesegment(fs, prev->fs);
666 savesegment(gs, prev->gs);
667 661
668 /* 662 /*
669 * Load the per-thread Thread-Local Storage descriptor. 663 * Load the per-thread Thread-Local Storage descriptor.
@@ -671,22 +665,14 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
671 load_TLS(next, cpu); 665 load_TLS(next, cpu);
672 666
673 /* 667 /*
674 * Restore %fs and %gs if needed. 668 * Restore %fs if needed.
675 * 669 *
676 * Glibc normally makes %fs be zero, and %gs is one of 670 * Glibc normally makes %fs be zero.
677 * the TLS segments.
678 */ 671 */
679 if (unlikely(prev->fs | next->fs)) 672 if (unlikely(prev->fs | next->fs))
680 loadsegment(fs, next->fs); 673 loadsegment(fs, next->fs);
681 674
682 if (prev->gs | next->gs) 675 write_pda(pcurrent, next_p);
683 loadsegment(gs, next->gs);
684
685 /*
686 * Restore IOPL if needed.
687 */
688 if (unlikely(prev->iopl != next->iopl))
689 set_iopl_mask(next->iopl);
690 676
691 /* 677 /*
692 * Now maybe handle debug registers and/or IO bitmaps 678 * Now maybe handle debug registers and/or IO bitmaps
@@ -697,6 +683,13 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
697 683
698 disable_tsc(prev_p, next_p); 684 disable_tsc(prev_p, next_p);
699 685
686 /* If the task has used fpu the last 5 timeslices, just do a full
687 * restore of the math state immediately to avoid the trap; the
688 * chances of needing FPU soon are obviously high now
689 */
690 if (next_p->fpu_counter > 5)
691 math_state_restore();
692
700 return prev_p; 693 return prev_p;
701} 694}
702 695
diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index 775f50e9395b..f3f94ac5736a 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -94,13 +94,9 @@ static int putreg(struct task_struct *child,
94 return -EIO; 94 return -EIO;
95 child->thread.fs = value; 95 child->thread.fs = value;
96 return 0; 96 return 0;
97 case GS:
98 if (value && (value & 3) != 3)
99 return -EIO;
100 child->thread.gs = value;
101 return 0;
102 case DS: 97 case DS:
103 case ES: 98 case ES:
99 case GS:
104 if (value && (value & 3) != 3) 100 if (value && (value & 3) != 3)
105 return -EIO; 101 return -EIO;
106 value &= 0xffff; 102 value &= 0xffff;
@@ -116,8 +112,8 @@ static int putreg(struct task_struct *child,
116 value |= get_stack_long(child, EFL_OFFSET) & ~FLAG_MASK; 112 value |= get_stack_long(child, EFL_OFFSET) & ~FLAG_MASK;
117 break; 113 break;
118 } 114 }
119 if (regno > GS*4) 115 if (regno > ES*4)
120 regno -= 2*4; 116 regno -= 1*4;
121 put_stack_long(child, regno - sizeof(struct pt_regs), value); 117 put_stack_long(child, regno - sizeof(struct pt_regs), value);
122 return 0; 118 return 0;
123} 119}
@@ -131,18 +127,16 @@ static unsigned long getreg(struct task_struct *child,
131 case FS: 127 case FS:
132 retval = child->thread.fs; 128 retval = child->thread.fs;
133 break; 129 break;
134 case GS:
135 retval = child->thread.gs;
136 break;
137 case DS: 130 case DS:
138 case ES: 131 case ES:
132 case GS:
139 case SS: 133 case SS:
140 case CS: 134 case CS:
141 retval = 0xffff; 135 retval = 0xffff;
142 /* fall through */ 136 /* fall through */
143 default: 137 default:
144 if (regno > GS*4) 138 if (regno > ES*4)
145 regno -= 2*4; 139 regno -= 1*4;
146 regno = regno - sizeof(struct pt_regs); 140 regno = regno - sizeof(struct pt_regs);
147 retval &= get_stack_long(child, regno); 141 retval &= get_stack_long(child, regno);
148 } 142 }
diff --git a/arch/i386/kernel/quirks.c b/arch/i386/kernel/quirks.c
index 9f6ab1789bb0..a01320a7b636 100644
--- a/arch/i386/kernel/quirks.c
+++ b/arch/i386/kernel/quirks.c
@@ -3,10 +3,23 @@
3 */ 3 */
4#include <linux/pci.h> 4#include <linux/pci.h>
5#include <linux/irq.h> 5#include <linux/irq.h>
6#include <asm/pci-direct.h>
7#include <asm/genapic.h>
8#include <asm/cpu.h>
6 9
7#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI) 10#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
11static void __devinit verify_quirk_intel_irqbalance(struct pci_dev *dev)
12{
13#ifdef CONFIG_X86_64
14 if (genapic != &apic_flat)
15 panic("APIC mode must be flat on this system\n");
16#elif defined(CONFIG_X86_GENERICARCH)
17 if (genapic != &apic_default)
18 panic("APIC mode must be default(flat) on this system. Use apic=default\n");
19#endif
20}
8 21
9static void __devinit quirk_intel_irqbalance(struct pci_dev *dev) 22void __init quirk_intel_irqbalance(void)
10{ 23{
11 u8 config, rev; 24 u8 config, rev;
12 u32 word; 25 u32 word;
@@ -16,18 +29,18 @@ static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
16 * based platforms. 29 * based platforms.
17 * Disable SW irqbalance/affinity on those platforms. 30 * Disable SW irqbalance/affinity on those platforms.
18 */ 31 */
19 pci_read_config_byte(dev, PCI_CLASS_REVISION, &rev); 32 rev = read_pci_config_byte(0, 0, 0, PCI_CLASS_REVISION);
20 if (rev > 0x9) 33 if (rev > 0x9)
21 return; 34 return;
22 35
23 printk(KERN_INFO "Intel E7520/7320/7525 detected."); 36 printk(KERN_INFO "Intel E7520/7320/7525 detected.");
24 37
25 /* enable access to config space*/ 38 /* enable access to config space */
26 pci_read_config_byte(dev, 0xf4, &config); 39 config = read_pci_config_byte(0, 0, 0, 0xf4);
27 pci_write_config_byte(dev, 0xf4, config|0x2); 40 write_pci_config_byte(0, 0, 0, 0xf4, config|0x2);
28 41
29 /* read xTPR register */ 42 /* read xTPR register */
30 raw_pci_ops->read(0, 0, 0x40, 0x4c, 2, &word); 43 word = read_pci_config_16(0, 0, 0x40, 0x4c);
31 44
32 if (!(word & (1 << 13))) { 45 if (!(word & (1 << 13))) {
33 printk(KERN_INFO "Disabling irq balancing and affinity\n"); 46 printk(KERN_INFO "Disabling irq balancing and affinity\n");
@@ -38,13 +51,24 @@ static void __devinit quirk_intel_irqbalance(struct pci_dev *dev)
38#ifdef CONFIG_PROC_FS 51#ifdef CONFIG_PROC_FS
39 no_irq_affinity = 1; 52 no_irq_affinity = 1;
40#endif 53#endif
54#ifdef CONFIG_HOTPLUG_CPU
55 printk(KERN_INFO "Disabling cpu hotplug control\n");
56 enable_cpu_hotplug = 0;
57#endif
58#ifdef CONFIG_X86_64
59 /* force the genapic selection to flat mode so that
60 * interrupts can be redirected to more than one CPU.
61 */
62 genapic_force = &apic_flat;
63#endif
41 } 64 }
42 65
43 /* put back the original value for config space*/ 66 /* put back the original value for config space */
44 if (!(config & 0x2)) 67 if (!(config & 0x2))
45 pci_write_config_byte(dev, 0xf4, config); 68 write_pci_config_byte(0, 0, 0, 0xf4, config);
46} 69}
47DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_intel_irqbalance); 70DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, verify_quirk_intel_irqbalance);
48DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, quirk_intel_irqbalance); 71DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, verify_quirk_intel_irqbalance);
49DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quirk_intel_irqbalance); 72DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, verify_quirk_intel_irqbalance);
73
50#endif 74#endif
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 84278e0093a2..3514b4153f7f 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -12,6 +12,7 @@
12#include <linux/dmi.h> 12#include <linux/dmi.h>
13#include <linux/ctype.h> 13#include <linux/ctype.h>
14#include <linux/pm.h> 14#include <linux/pm.h>
15#include <linux/reboot.h>
15#include <asm/uaccess.h> 16#include <asm/uaccess.h>
16#include <asm/apic.h> 17#include <asm/apic.h>
17#include <asm/desc.h> 18#include <asm/desc.h>
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 141041dde74d..79df6e612dbd 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -63,9 +63,6 @@
63#include <setup_arch.h> 63#include <setup_arch.h>
64#include <bios_ebda.h> 64#include <bios_ebda.h>
65 65
66/* Forward Declaration. */
67void __init find_max_pfn(void);
68
69/* This value is set up by the early boot code to point to the value 66/* This value is set up by the early boot code to point to the value
70 immediately after the boot time page tables. It contains a *physical* 67 immediately after the boot time page tables. It contains a *physical*
71 address, and must not be in the .bss segment! */ 68 address, and must not be in the .bss segment! */
@@ -76,11 +73,8 @@ int disable_pse __devinitdata = 0;
76/* 73/*
77 * Machine setup.. 74 * Machine setup..
78 */ 75 */
79 76extern struct resource code_resource;
80#ifdef CONFIG_EFI 77extern struct resource data_resource;
81int efi_enabled = 0;
82EXPORT_SYMBOL(efi_enabled);
83#endif
84 78
85/* cpu data as detected by the assembly code in head.S */ 79/* cpu data as detected by the assembly code in head.S */
86struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; 80struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
@@ -99,12 +93,6 @@ unsigned int machine_submodel_id;
99unsigned int BIOS_revision; 93unsigned int BIOS_revision;
100unsigned int mca_pentium_flag; 94unsigned int mca_pentium_flag;
101 95
102/* For PCI or other memory-mapped resources */
103unsigned long pci_mem_start = 0x10000000;
104#ifdef CONFIG_PCI
105EXPORT_SYMBOL(pci_mem_start);
106#endif
107
108/* Boot loader ID as an integer, for the benefit of proc_dointvec */ 96/* Boot loader ID as an integer, for the benefit of proc_dointvec */
109int bootloader_type; 97int bootloader_type;
110 98
@@ -134,7 +122,6 @@ struct ist_info ist_info;
134 defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE) 122 defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
135EXPORT_SYMBOL(ist_info); 123EXPORT_SYMBOL(ist_info);
136#endif 124#endif
137struct e820map e820;
138 125
139extern void early_cpu_init(void); 126extern void early_cpu_init(void);
140extern int root_mountflags; 127extern int root_mountflags;
@@ -149,516 +136,6 @@ static char command_line[COMMAND_LINE_SIZE];
149 136
150unsigned char __initdata boot_params[PARAM_SIZE]; 137unsigned char __initdata boot_params[PARAM_SIZE];
151 138
152static struct resource data_resource = {
153 .name = "Kernel data",
154 .start = 0,
155 .end = 0,
156 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
157};
158
159static struct resource code_resource = {
160 .name = "Kernel code",
161 .start = 0,
162 .end = 0,
163 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
164};
165
166static struct resource system_rom_resource = {
167 .name = "System ROM",
168 .start = 0xf0000,
169 .end = 0xfffff,
170 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
171};
172
173static struct resource extension_rom_resource = {
174 .name = "Extension ROM",
175 .start = 0xe0000,
176 .end = 0xeffff,
177 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
178};
179
180static struct resource adapter_rom_resources[] = { {
181 .name = "Adapter ROM",
182 .start = 0xc8000,
183 .end = 0,
184 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
185}, {
186 .name = "Adapter ROM",
187 .start = 0,
188 .end = 0,
189 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
190}, {
191 .name = "Adapter ROM",
192 .start = 0,
193 .end = 0,
194 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
195}, {
196 .name = "Adapter ROM",
197 .start = 0,
198 .end = 0,
199 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
200}, {
201 .name = "Adapter ROM",
202 .start = 0,
203 .end = 0,
204 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
205}, {
206 .name = "Adapter ROM",
207 .start = 0,
208 .end = 0,
209 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
210} };
211
212static struct resource video_rom_resource = {
213 .name = "Video ROM",
214 .start = 0xc0000,
215 .end = 0xc7fff,
216 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
217};
218
219static struct resource video_ram_resource = {
220 .name = "Video RAM area",
221 .start = 0xa0000,
222 .end = 0xbffff,
223 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
224};
225
226static struct resource standard_io_resources[] = { {
227 .name = "dma1",
228 .start = 0x0000,
229 .end = 0x001f,
230 .flags = IORESOURCE_BUSY | IORESOURCE_IO
231}, {
232 .name = "pic1",
233 .start = 0x0020,
234 .end = 0x0021,
235 .flags = IORESOURCE_BUSY | IORESOURCE_IO
236}, {
237 .name = "timer0",
238 .start = 0x0040,
239 .end = 0x0043,
240 .flags = IORESOURCE_BUSY | IORESOURCE_IO
241}, {
242 .name = "timer1",
243 .start = 0x0050,
244 .end = 0x0053,
245 .flags = IORESOURCE_BUSY | IORESOURCE_IO
246}, {
247 .name = "keyboard",
248 .start = 0x0060,
249 .end = 0x006f,
250 .flags = IORESOURCE_BUSY | IORESOURCE_IO
251}, {
252 .name = "dma page reg",
253 .start = 0x0080,
254 .end = 0x008f,
255 .flags = IORESOURCE_BUSY | IORESOURCE_IO
256}, {
257 .name = "pic2",
258 .start = 0x00a0,
259 .end = 0x00a1,
260 .flags = IORESOURCE_BUSY | IORESOURCE_IO
261}, {
262 .name = "dma2",
263 .start = 0x00c0,
264 .end = 0x00df,
265 .flags = IORESOURCE_BUSY | IORESOURCE_IO
266}, {
267 .name = "fpu",
268 .start = 0x00f0,
269 .end = 0x00ff,
270 .flags = IORESOURCE_BUSY | IORESOURCE_IO
271} };
272
273#define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
274
275static int __init romchecksum(unsigned char *rom, unsigned long length)
276{
277 unsigned char *p, sum = 0;
278
279 for (p = rom; p < rom + length; p++)
280 sum += *p;
281 return sum == 0;
282}
283
284static void __init probe_roms(void)
285{
286 unsigned long start, length, upper;
287 unsigned char *rom;
288 int i;
289
290 /* video rom */
291 upper = adapter_rom_resources[0].start;
292 for (start = video_rom_resource.start; start < upper; start += 2048) {
293 rom = isa_bus_to_virt(start);
294 if (!romsignature(rom))
295 continue;
296
297 video_rom_resource.start = start;
298
299 /* 0 < length <= 0x7f * 512, historically */
300 length = rom[2] * 512;
301
302 /* if checksum okay, trust length byte */
303 if (length && romchecksum(rom, length))
304 video_rom_resource.end = start + length - 1;
305
306 request_resource(&iomem_resource, &video_rom_resource);
307 break;
308 }
309
310 start = (video_rom_resource.end + 1 + 2047) & ~2047UL;
311 if (start < upper)
312 start = upper;
313
314 /* system rom */
315 request_resource(&iomem_resource, &system_rom_resource);
316 upper = system_rom_resource.start;
317
318 /* check for extension rom (ignore length byte!) */
319 rom = isa_bus_to_virt(extension_rom_resource.start);
320 if (romsignature(rom)) {
321 length = extension_rom_resource.end - extension_rom_resource.start + 1;
322 if (romchecksum(rom, length)) {
323 request_resource(&iomem_resource, &extension_rom_resource);
324 upper = extension_rom_resource.start;
325 }
326 }
327
328 /* check for adapter roms on 2k boundaries */
329 for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) {
330 rom = isa_bus_to_virt(start);
331 if (!romsignature(rom))
332 continue;
333
334 /* 0 < length <= 0x7f * 512, historically */
335 length = rom[2] * 512;
336
337 /* but accept any length that fits if checksum okay */
338 if (!length || start + length > upper || !romchecksum(rom, length))
339 continue;
340
341 adapter_rom_resources[i].start = start;
342 adapter_rom_resources[i].end = start + length - 1;
343 request_resource(&iomem_resource, &adapter_rom_resources[i]);
344
345 start = adapter_rom_resources[i++].end & ~2047UL;
346 }
347}
348
349static void __init limit_regions(unsigned long long size)
350{
351 unsigned long long current_addr = 0;
352 int i;
353
354 if (efi_enabled) {
355 efi_memory_desc_t *md;
356 void *p;
357
358 for (p = memmap.map, i = 0; p < memmap.map_end;
359 p += memmap.desc_size, i++) {
360 md = p;
361 current_addr = md->phys_addr + (md->num_pages << 12);
362 if (md->type == EFI_CONVENTIONAL_MEMORY) {
363 if (current_addr >= size) {
364 md->num_pages -=
365 (((current_addr-size) + PAGE_SIZE-1) >> PAGE_SHIFT);
366 memmap.nr_map = i + 1;
367 return;
368 }
369 }
370 }
371 }
372 for (i = 0; i < e820.nr_map; i++) {
373 current_addr = e820.map[i].addr + e820.map[i].size;
374 if (current_addr < size)
375 continue;
376
377 if (e820.map[i].type != E820_RAM)
378 continue;
379
380 if (e820.map[i].addr >= size) {
381 /*
382 * This region starts past the end of the
383 * requested size, skip it completely.
384 */
385 e820.nr_map = i;
386 } else {
387 e820.nr_map = i + 1;
388 e820.map[i].size -= current_addr - size;
389 }
390 return;
391 }
392}
393
394void __init add_memory_region(unsigned long long start,
395 unsigned long long size, int type)
396{
397 int x;
398
399 if (!efi_enabled) {
400 x = e820.nr_map;
401
402 if (x == E820MAX) {
403 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
404 return;
405 }
406
407 e820.map[x].addr = start;
408 e820.map[x].size = size;
409 e820.map[x].type = type;
410 e820.nr_map++;
411 }
412} /* add_memory_region */
413
414#define E820_DEBUG 1
415
416static void __init print_memory_map(char *who)
417{
418 int i;
419
420 for (i = 0; i < e820.nr_map; i++) {
421 printk(" %s: %016Lx - %016Lx ", who,
422 e820.map[i].addr,
423 e820.map[i].addr + e820.map[i].size);
424 switch (e820.map[i].type) {
425 case E820_RAM: printk("(usable)\n");
426 break;
427 case E820_RESERVED:
428 printk("(reserved)\n");
429 break;
430 case E820_ACPI:
431 printk("(ACPI data)\n");
432 break;
433 case E820_NVS:
434 printk("(ACPI NVS)\n");
435 break;
436 default: printk("type %lu\n", e820.map[i].type);
437 break;
438 }
439 }
440}
441
442/*
443 * Sanitize the BIOS e820 map.
444 *
445 * Some e820 responses include overlapping entries. The following
446 * replaces the original e820 map with a new one, removing overlaps.
447 *
448 */
449struct change_member {
450 struct e820entry *pbios; /* pointer to original bios entry */
451 unsigned long long addr; /* address for this change point */
452};
453static struct change_member change_point_list[2*E820MAX] __initdata;
454static struct change_member *change_point[2*E820MAX] __initdata;
455static struct e820entry *overlap_list[E820MAX] __initdata;
456static struct e820entry new_bios[E820MAX] __initdata;
457
458int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
459{
460 struct change_member *change_tmp;
461 unsigned long current_type, last_type;
462 unsigned long long last_addr;
463 int chgidx, still_changing;
464 int overlap_entries;
465 int new_bios_entry;
466 int old_nr, new_nr, chg_nr;
467 int i;
468
469 /*
470 Visually we're performing the following (1,2,3,4 = memory types)...
471
472 Sample memory map (w/overlaps):
473 ____22__________________
474 ______________________4_
475 ____1111________________
476 _44_____________________
477 11111111________________
478 ____________________33__
479 ___________44___________
480 __________33333_________
481 ______________22________
482 ___________________2222_
483 _________111111111______
484 _____________________11_
485 _________________4______
486
487 Sanitized equivalent (no overlap):
488 1_______________________
489 _44_____________________
490 ___1____________________
491 ____22__________________
492 ______11________________
493 _________1______________
494 __________3_____________
495 ___________44___________
496 _____________33_________
497 _______________2________
498 ________________1_______
499 _________________4______
500 ___________________2____
501 ____________________33__
502 ______________________4_
503 */
504
505 /* if there's only one memory region, don't bother */
506 if (*pnr_map < 2)
507 return -1;
508
509 old_nr = *pnr_map;
510
511 /* bail out if we find any unreasonable addresses in bios map */
512 for (i=0; i<old_nr; i++)
513 if (biosmap[i].addr + biosmap[i].size < biosmap[i].addr)
514 return -1;
515
516 /* create pointers for initial change-point information (for sorting) */
517 for (i=0; i < 2*old_nr; i++)
518 change_point[i] = &change_point_list[i];
519
520 /* record all known change-points (starting and ending addresses),
521 omitting those that are for empty memory regions */
522 chgidx = 0;
523 for (i=0; i < old_nr; i++) {
524 if (biosmap[i].size != 0) {
525 change_point[chgidx]->addr = biosmap[i].addr;
526 change_point[chgidx++]->pbios = &biosmap[i];
527 change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
528 change_point[chgidx++]->pbios = &biosmap[i];
529 }
530 }
531 chg_nr = chgidx; /* true number of change-points */
532
533 /* sort change-point list by memory addresses (low -> high) */
534 still_changing = 1;
535 while (still_changing) {
536 still_changing = 0;
537 for (i=1; i < chg_nr; i++) {
538 /* if <current_addr> > <last_addr>, swap */
539 /* or, if current=<start_addr> & last=<end_addr>, swap */
540 if ((change_point[i]->addr < change_point[i-1]->addr) ||
541 ((change_point[i]->addr == change_point[i-1]->addr) &&
542 (change_point[i]->addr == change_point[i]->pbios->addr) &&
543 (change_point[i-1]->addr != change_point[i-1]->pbios->addr))
544 )
545 {
546 change_tmp = change_point[i];
547 change_point[i] = change_point[i-1];
548 change_point[i-1] = change_tmp;
549 still_changing=1;
550 }
551 }
552 }
553
554 /* create a new bios memory map, removing overlaps */
555 overlap_entries=0; /* number of entries in the overlap table */
556 new_bios_entry=0; /* index for creating new bios map entries */
557 last_type = 0; /* start with undefined memory type */
558 last_addr = 0; /* start with 0 as last starting address */
559 /* loop through change-points, determining affect on the new bios map */
560 for (chgidx=0; chgidx < chg_nr; chgidx++)
561 {
562 /* keep track of all overlapping bios entries */
563 if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
564 {
565 /* add map entry to overlap list (> 1 entry implies an overlap) */
566 overlap_list[overlap_entries++]=change_point[chgidx]->pbios;
567 }
568 else
569 {
570 /* remove entry from list (order independent, so swap with last) */
571 for (i=0; i<overlap_entries; i++)
572 {
573 if (overlap_list[i] == change_point[chgidx]->pbios)
574 overlap_list[i] = overlap_list[overlap_entries-1];
575 }
576 overlap_entries--;
577 }
578 /* if there are overlapping entries, decide which "type" to use */
579 /* (larger value takes precedence -- 1=usable, 2,3,4,4+=unusable) */
580 current_type = 0;
581 for (i=0; i<overlap_entries; i++)
582 if (overlap_list[i]->type > current_type)
583 current_type = overlap_list[i]->type;
584 /* continue building up new bios map based on this information */
585 if (current_type != last_type) {
586 if (last_type != 0) {
587 new_bios[new_bios_entry].size =
588 change_point[chgidx]->addr - last_addr;
589 /* move forward only if the new size was non-zero */
590 if (new_bios[new_bios_entry].size != 0)
591 if (++new_bios_entry >= E820MAX)
592 break; /* no more space left for new bios entries */
593 }
594 if (current_type != 0) {
595 new_bios[new_bios_entry].addr = change_point[chgidx]->addr;
596 new_bios[new_bios_entry].type = current_type;
597 last_addr=change_point[chgidx]->addr;
598 }
599 last_type = current_type;
600 }
601 }
602 new_nr = new_bios_entry; /* retain count for new bios entries */
603
604 /* copy new bios mapping into original location */
605 memcpy(biosmap, new_bios, new_nr*sizeof(struct e820entry));
606 *pnr_map = new_nr;
607
608 return 0;
609}
610
611/*
612 * Copy the BIOS e820 map into a safe place.
613 *
614 * Sanity-check it while we're at it..
615 *
616 * If we're lucky and live on a modern system, the setup code
617 * will have given us a memory map that we can use to properly
618 * set up memory. If we aren't, we'll fake a memory map.
619 *
620 * We check to see that the memory map contains at least 2 elements
621 * before we'll use it, because the detection code in setup.S may
622 * not be perfect and most every PC known to man has two memory
623 * regions: one from 0 to 640k, and one from 1mb up. (The IBM
624 * thinkpad 560x, for example, does not cooperate with the memory
625 * detection code.)
626 */
627int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
628{
629 /* Only one memory region (or negative)? Ignore it */
630 if (nr_map < 2)
631 return -1;
632
633 do {
634 unsigned long long start = biosmap->addr;
635 unsigned long long size = biosmap->size;
636 unsigned long long end = start + size;
637 unsigned long type = biosmap->type;
638
639 /* Overflow in 64 bits? Ignore the memory map. */
640 if (start > end)
641 return -1;
642
643 /*
644 * Some BIOSes claim RAM in the 640k - 1M region.
645 * Not right. Fix it up.
646 */
647 if (type == E820_RAM) {
648 if (start < 0x100000ULL && end > 0xA0000ULL) {
649 if (start < 0xA0000ULL)
650 add_memory_region(start, 0xA0000ULL-start, type);
651 if (end <= 0x100000ULL)
652 continue;
653 start = 0x100000ULL;
654 size = end - start;
655 }
656 }
657 add_memory_region(start, size, type);
658 } while (biosmap++,--nr_map);
659 return 0;
660}
661
662#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) 139#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
663struct edd edd; 140struct edd edd;
664#ifdef CONFIG_EDD_MODULE 141#ifdef CONFIG_EDD_MODULE
@@ -682,7 +159,7 @@ static inline void copy_edd(void)
682} 159}
683#endif 160#endif
684 161
685static int __initdata user_defined_memmap = 0; 162int __initdata user_defined_memmap = 0;
686 163
687/* 164/*
688 * "mem=nopentium" disables the 4MB page tables. 165 * "mem=nopentium" disables the 4MB page tables.
@@ -719,51 +196,6 @@ static int __init parse_mem(char *arg)
719} 196}
720early_param("mem", parse_mem); 197early_param("mem", parse_mem);
721 198
722static int __init parse_memmap(char *arg)
723{
724 if (!arg)
725 return -EINVAL;
726
727 if (strcmp(arg, "exactmap") == 0) {
728#ifdef CONFIG_CRASH_DUMP
729 /* If we are doing a crash dump, we
730 * still need to know the real mem
731 * size before original memory map is
732 * reset.
733 */
734 find_max_pfn();
735 saved_max_pfn = max_pfn;
736#endif
737 e820.nr_map = 0;
738 user_defined_memmap = 1;
739 } else {
740 /* If the user specifies memory size, we
741 * limit the BIOS-provided memory map to
742 * that size. exactmap can be used to specify
743 * the exact map. mem=number can be used to
744 * trim the existing memory map.
745 */
746 unsigned long long start_at, mem_size;
747
748 mem_size = memparse(arg, &arg);
749 if (*arg == '@') {
750 start_at = memparse(arg+1, &arg);
751 add_memory_region(start_at, mem_size, E820_RAM);
752 } else if (*arg == '#') {
753 start_at = memparse(arg+1, &arg);
754 add_memory_region(start_at, mem_size, E820_ACPI);
755 } else if (*arg == '$') {
756 start_at = memparse(arg+1, &arg);
757 add_memory_region(start_at, mem_size, E820_RESERVED);
758 } else {
759 limit_regions(mem_size);
760 user_defined_memmap = 1;
761 }
762 }
763 return 0;
764}
765early_param("memmap", parse_memmap);
766
767#ifdef CONFIG_PROC_VMCORE 199#ifdef CONFIG_PROC_VMCORE
768/* elfcorehdr= specifies the location of elf core header 200/* elfcorehdr= specifies the location of elf core header
769 * stored by the crashed kernel. 201 * stored by the crashed kernel.
@@ -828,90 +260,6 @@ static int __init parse_reservetop(char *arg)
828early_param("reservetop", parse_reservetop); 260early_param("reservetop", parse_reservetop);
829 261
830/* 262/*
831 * Callback for efi_memory_walk.
832 */
833static int __init
834efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
835{
836 unsigned long *max_pfn = arg, pfn;
837
838 if (start < end) {
839 pfn = PFN_UP(end -1);
840 if (pfn > *max_pfn)
841 *max_pfn = pfn;
842 }
843 return 0;
844}
845
846static int __init
847efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
848{
849 memory_present(0, PFN_UP(start), PFN_DOWN(end));
850 return 0;
851}
852
853 /*
854 * This function checks if the entire range <start,end> is mapped with type.
855 *
856 * Note: this function only works correct if the e820 table is sorted and
857 * not-overlapping, which is the case
858 */
859int __init
860e820_all_mapped(unsigned long s, unsigned long e, unsigned type)
861{
862 u64 start = s;
863 u64 end = e;
864 int i;
865 for (i = 0; i < e820.nr_map; i++) {
866 struct e820entry *ei = &e820.map[i];
867 if (type && ei->type != type)
868 continue;
869 /* is the region (part) in overlap with the current region ?*/
870 if (ei->addr >= end || ei->addr + ei->size <= start)
871 continue;
872 /* if the region is at the beginning of <start,end> we move
873 * start to the end of the region since it's ok until there
874 */
875 if (ei->addr <= start)
876 start = ei->addr + ei->size;
877 /* if start is now at or beyond end, we're done, full
878 * coverage */
879 if (start >= end)
880 return 1; /* we're done */
881 }
882 return 0;
883}
884
885/*
886 * Find the highest page frame number we have available
887 */
888void __init find_max_pfn(void)
889{
890 int i;
891
892 max_pfn = 0;
893 if (efi_enabled) {
894 efi_memmap_walk(efi_find_max_pfn, &max_pfn);
895 efi_memmap_walk(efi_memory_present_wrapper, NULL);
896 return;
897 }
898
899 for (i = 0; i < e820.nr_map; i++) {
900 unsigned long start, end;
901 /* RAM? */
902 if (e820.map[i].type != E820_RAM)
903 continue;
904 start = PFN_UP(e820.map[i].addr);
905 end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
906 if (start >= end)
907 continue;
908 if (end > max_pfn)
909 max_pfn = end;
910 memory_present(0, start, end);
911 }
912}
913
914/*
915 * Determine low and high memory ranges: 263 * Determine low and high memory ranges:
916 */ 264 */
917unsigned long __init find_max_low_pfn(void) 265unsigned long __init find_max_low_pfn(void)
@@ -971,68 +319,6 @@ unsigned long __init find_max_low_pfn(void)
971} 319}
972 320
973/* 321/*
974 * Free all available memory for boot time allocation. Used
975 * as a callback function by efi_memory_walk()
976 */
977
978static int __init
979free_available_memory(unsigned long start, unsigned long end, void *arg)
980{
981 /* check max_low_pfn */
982 if (start >= (max_low_pfn << PAGE_SHIFT))
983 return 0;
984 if (end >= (max_low_pfn << PAGE_SHIFT))
985 end = max_low_pfn << PAGE_SHIFT;
986 if (start < end)
987 free_bootmem(start, end - start);
988
989 return 0;
990}
991/*
992 * Register fully available low RAM pages with the bootmem allocator.
993 */
994static void __init register_bootmem_low_pages(unsigned long max_low_pfn)
995{
996 int i;
997
998 if (efi_enabled) {
999 efi_memmap_walk(free_available_memory, NULL);
1000 return;
1001 }
1002 for (i = 0; i < e820.nr_map; i++) {
1003 unsigned long curr_pfn, last_pfn, size;
1004 /*
1005 * Reserve usable low memory
1006 */
1007 if (e820.map[i].type != E820_RAM)
1008 continue;
1009 /*
1010 * We are rounding up the start address of usable memory:
1011 */
1012 curr_pfn = PFN_UP(e820.map[i].addr);
1013 if (curr_pfn >= max_low_pfn)
1014 continue;
1015 /*
1016 * ... and at the end of the usable range downwards:
1017 */
1018 last_pfn = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
1019
1020 if (last_pfn > max_low_pfn)
1021 last_pfn = max_low_pfn;
1022
1023 /*
1024 * .. finally, did all the rounding and playing
1025 * around just make the area go away?
1026 */
1027 if (last_pfn <= curr_pfn)
1028 continue;
1029
1030 size = last_pfn - curr_pfn;
1031 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size));
1032 }
1033}
1034
1035/*
1036 * workaround for Dell systems that neglect to reserve EBDA 322 * workaround for Dell systems that neglect to reserve EBDA
1037 */ 323 */
1038static void __init reserve_ebda_region(void) 324static void __init reserve_ebda_region(void)
@@ -1118,8 +404,8 @@ void __init setup_bootmem_allocator(void)
1118 * the (very unlikely) case of us accidentally initializing the 404 * the (very unlikely) case of us accidentally initializing the
1119 * bootmem allocator with an invalid RAM area. 405 * bootmem allocator with an invalid RAM area.
1120 */ 406 */
1121 reserve_bootmem(__PHYSICAL_START, (PFN_PHYS(min_low_pfn) + 407 reserve_bootmem(__pa_symbol(_text), (PFN_PHYS(min_low_pfn) +
1122 bootmap_size + PAGE_SIZE-1) - (__PHYSICAL_START)); 408 bootmap_size + PAGE_SIZE-1) - __pa_symbol(_text));
1123 409
1124 /* 410 /*
1125 * reserve physical page 0 - it's a special BIOS page on many boxes, 411 * reserve physical page 0 - it's a special BIOS page on many boxes,
@@ -1162,8 +448,7 @@ void __init setup_bootmem_allocator(void)
1162 if (LOADER_TYPE && INITRD_START) { 448 if (LOADER_TYPE && INITRD_START) {
1163 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { 449 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
1164 reserve_bootmem(INITRD_START, INITRD_SIZE); 450 reserve_bootmem(INITRD_START, INITRD_SIZE);
1165 initrd_start = 451 initrd_start = INITRD_START + PAGE_OFFSET;
1166 INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
1167 initrd_end = initrd_start+INITRD_SIZE; 452 initrd_end = initrd_start+INITRD_SIZE;
1168 } 453 }
1169 else { 454 else {
@@ -1200,126 +485,6 @@ void __init remapped_pgdat_init(void)
1200 } 485 }
1201} 486}
1202 487
1203/*
1204 * Request address space for all standard RAM and ROM resources
1205 * and also for regions reported as reserved by the e820.
1206 */
1207static void __init
1208legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource)
1209{
1210 int i;
1211
1212 probe_roms();
1213 for (i = 0; i < e820.nr_map; i++) {
1214 struct resource *res;
1215#ifndef CONFIG_RESOURCES_64BIT
1216 if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
1217 continue;
1218#endif
1219 res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
1220 switch (e820.map[i].type) {
1221 case E820_RAM: res->name = "System RAM"; break;
1222 case E820_ACPI: res->name = "ACPI Tables"; break;
1223 case E820_NVS: res->name = "ACPI Non-volatile Storage"; break;
1224 default: res->name = "reserved";
1225 }
1226 res->start = e820.map[i].addr;
1227 res->end = res->start + e820.map[i].size - 1;
1228 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
1229 if (request_resource(&iomem_resource, res)) {
1230 kfree(res);
1231 continue;
1232 }
1233 if (e820.map[i].type == E820_RAM) {
1234 /*
1235 * We don't know which RAM region contains kernel data,
1236 * so we try it repeatedly and let the resource manager
1237 * test it.
1238 */
1239 request_resource(res, code_resource);
1240 request_resource(res, data_resource);
1241#ifdef CONFIG_KEXEC
1242 request_resource(res, &crashk_res);
1243#endif
1244 }
1245 }
1246}
1247
1248/*
1249 * Request address space for all standard resources
1250 *
1251 * This is called just before pcibios_init(), which is also a
1252 * subsys_initcall, but is linked in later (in arch/i386/pci/common.c).
1253 */
1254static int __init request_standard_resources(void)
1255{
1256 int i;
1257
1258 printk("Setting up standard PCI resources\n");
1259 if (efi_enabled)
1260 efi_initialize_iomem_resources(&code_resource, &data_resource);
1261 else
1262 legacy_init_iomem_resources(&code_resource, &data_resource);
1263
1264 /* EFI systems may still have VGA */
1265 request_resource(&iomem_resource, &video_ram_resource);
1266
1267 /* request I/O space for devices used on all i[345]86 PCs */
1268 for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
1269 request_resource(&ioport_resource, &standard_io_resources[i]);
1270 return 0;
1271}
1272
1273subsys_initcall(request_standard_resources);
1274
1275static void __init register_memory(void)
1276{
1277 unsigned long gapstart, gapsize, round;
1278 unsigned long long last;
1279 int i;
1280
1281 /*
1282 * Search for the bigest gap in the low 32 bits of the e820
1283 * memory space.
1284 */
1285 last = 0x100000000ull;
1286 gapstart = 0x10000000;
1287 gapsize = 0x400000;
1288 i = e820.nr_map;
1289 while (--i >= 0) {
1290 unsigned long long start = e820.map[i].addr;
1291 unsigned long long end = start + e820.map[i].size;
1292
1293 /*
1294 * Since "last" is at most 4GB, we know we'll
1295 * fit in 32 bits if this condition is true
1296 */
1297 if (last > end) {
1298 unsigned long gap = last - end;
1299
1300 if (gap > gapsize) {
1301 gapsize = gap;
1302 gapstart = end;
1303 }
1304 }
1305 if (start < last)
1306 last = start;
1307 }
1308
1309 /*
1310 * See how much we want to round up: start off with
1311 * rounding to the next 1MB area.
1312 */
1313 round = 0x100000;
1314 while ((gapsize >> 4) > round)
1315 round += round;
1316 /* Fun with two's complement */
1317 pci_mem_start = (gapstart + round) & -round;
1318
1319 printk("Allocating PCI resources starting at %08lx (gap: %08lx:%08lx)\n",
1320 pci_mem_start, gapstart, gapsize);
1321}
1322
1323#ifdef CONFIG_MCA 488#ifdef CONFIG_MCA
1324static void set_mca_bus(int x) 489static void set_mca_bus(int x)
1325{ 490{
@@ -1329,6 +494,12 @@ static void set_mca_bus(int x)
1329static void set_mca_bus(int x) { } 494static void set_mca_bus(int x) { }
1330#endif 495#endif
1331 496
497/* Overridden in paravirt.c if CONFIG_PARAVIRT */
498char * __attribute__((weak)) memory_setup(void)
499{
500 return machine_specific_memory_setup();
501}
502
1332/* 503/*
1333 * Determine if we were loaded by an EFI loader. If so, then we have also been 504 * Determine if we were loaded by an EFI loader. If so, then we have also been
1334 * passed the efi memmap, systab, etc., so we should use these data structures 505 * passed the efi memmap, systab, etc., so we should use these data structures
@@ -1381,7 +552,7 @@ void __init setup_arch(char **cmdline_p)
1381 efi_init(); 552 efi_init();
1382 else { 553 else {
1383 printk(KERN_INFO "BIOS-provided physical RAM map:\n"); 554 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
1384 print_memory_map(machine_specific_memory_setup()); 555 print_memory_map(memory_setup());
1385 } 556 }
1386 557
1387 copy_edd(); 558 copy_edd();
diff --git a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
index 43002cfb40c4..65d7620eaa09 100644
--- a/arch/i386/kernel/signal.c
+++ b/arch/i386/kernel/signal.c
@@ -128,7 +128,7 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax
128 X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \ 128 X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \
129 X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF) 129 X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF)
130 130
131 GET_SEG(gs); 131 COPY_SEG(gs);
132 GET_SEG(fs); 132 GET_SEG(fs);
133 COPY_SEG(es); 133 COPY_SEG(es);
134 COPY_SEG(ds); 134 COPY_SEG(ds);
@@ -244,9 +244,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct _fpstate __user *fpstate,
244{ 244{
245 int tmp, err = 0; 245 int tmp, err = 0;
246 246
247 tmp = 0; 247 err |= __put_user(regs->xgs, (unsigned int __user *)&sc->gs);
248 savesegment(gs, tmp);
249 err |= __put_user(tmp, (unsigned int __user *)&sc->gs);
250 savesegment(fs, tmp); 248 savesegment(fs, tmp);
251 err |= __put_user(tmp, (unsigned int __user *)&sc->fs); 249 err |= __put_user(tmp, (unsigned int __user *)&sc->fs);
252 250
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
index 31e5c6573aae..5285aff8367f 100644
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -321,7 +321,6 @@ static inline void leave_mm (unsigned long cpu)
321 321
322fastcall void smp_invalidate_interrupt(struct pt_regs *regs) 322fastcall void smp_invalidate_interrupt(struct pt_regs *regs)
323{ 323{
324 struct pt_regs *old_regs = set_irq_regs(regs);
325 unsigned long cpu; 324 unsigned long cpu;
326 325
327 cpu = get_cpu(); 326 cpu = get_cpu();
@@ -352,7 +351,6 @@ fastcall void smp_invalidate_interrupt(struct pt_regs *regs)
352 smp_mb__after_clear_bit(); 351 smp_mb__after_clear_bit();
353out: 352out:
354 put_cpu_no_resched(); 353 put_cpu_no_resched();
355 set_irq_regs(old_regs);
356} 354}
357 355
358static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm, 356static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
@@ -607,14 +605,11 @@ void smp_send_stop(void)
607 */ 605 */
608fastcall void smp_reschedule_interrupt(struct pt_regs *regs) 606fastcall void smp_reschedule_interrupt(struct pt_regs *regs)
609{ 607{
610 struct pt_regs *old_regs = set_irq_regs(regs);
611 ack_APIC_irq(); 608 ack_APIC_irq();
612 set_irq_regs(old_regs);
613} 609}
614 610
615fastcall void smp_call_function_interrupt(struct pt_regs *regs) 611fastcall void smp_call_function_interrupt(struct pt_regs *regs)
616{ 612{
617 struct pt_regs *old_regs = set_irq_regs(regs);
618 void (*func) (void *info) = call_data->func; 613 void (*func) (void *info) = call_data->func;
619 void *info = call_data->info; 614 void *info = call_data->info;
620 int wait = call_data->wait; 615 int wait = call_data->wait;
@@ -637,7 +632,6 @@ fastcall void smp_call_function_interrupt(struct pt_regs *regs)
637 mb(); 632 mb();
638 atomic_inc(&call_data->finished); 633 atomic_inc(&call_data->finished);
639 } 634 }
640 set_irq_regs(old_regs);
641} 635}
642 636
643/* 637/*
@@ -699,6 +693,10 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
699 put_cpu(); 693 put_cpu();
700 return -EBUSY; 694 return -EBUSY;
701 } 695 }
696
697 /* Can deadlock when called with interrupts disabled */
698 WARN_ON(irqs_disabled());
699
702 spin_lock_bh(&call_lock); 700 spin_lock_bh(&call_lock);
703 __smp_call_function_single(cpu, func, info, nonatomic, wait); 701 __smp_call_function_single(cpu, func, info, nonatomic, wait);
704 spin_unlock_bh(&call_lock); 702 spin_unlock_bh(&call_lock);
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 02a9b66b6ac3..4bf0e3c83b8b 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -33,6 +33,11 @@
33 * Dave Jones : Report invalid combinations of Athlon CPUs. 33 * Dave Jones : Report invalid combinations of Athlon CPUs.
34* Rusty Russell : Hacked into shape for new "hotplug" boot process. */ 34* Rusty Russell : Hacked into shape for new "hotplug" boot process. */
35 35
36
37/* SMP boot always wants to use real time delay to allow sufficient time for
38 * the APs to come online */
39#define USE_REAL_TIME_DELAY
40
36#include <linux/module.h> 41#include <linux/module.h>
37#include <linux/init.h> 42#include <linux/init.h>
38#include <linux/kernel.h> 43#include <linux/kernel.h>
@@ -52,6 +57,8 @@
52#include <asm/desc.h> 57#include <asm/desc.h>
53#include <asm/arch_hooks.h> 58#include <asm/arch_hooks.h>
54#include <asm/nmi.h> 59#include <asm/nmi.h>
60#include <asm/pda.h>
61#include <asm/genapic.h>
55 62
56#include <mach_apic.h> 63#include <mach_apic.h>
57#include <mach_wakecpu.h> 64#include <mach_wakecpu.h>
@@ -536,11 +543,11 @@ set_cpu_sibling_map(int cpu)
536static void __devinit start_secondary(void *unused) 543static void __devinit start_secondary(void *unused)
537{ 544{
538 /* 545 /*
539 * Dont put anything before smp_callin(), SMP 546 * Don't put *anything* before secondary_cpu_init(), SMP
540 * booting is too fragile that we want to limit the 547 * booting is too fragile that we want to limit the
541 * things done here to the most necessary things. 548 * things done here to the most necessary things.
542 */ 549 */
543 cpu_init(); 550 secondary_cpu_init();
544 preempt_disable(); 551 preempt_disable();
545 smp_callin(); 552 smp_callin();
546 while (!cpu_isset(smp_processor_id(), smp_commenced_mask)) 553 while (!cpu_isset(smp_processor_id(), smp_commenced_mask))
@@ -599,13 +606,16 @@ void __devinit initialize_secondary(void)
599 "movl %0,%%esp\n\t" 606 "movl %0,%%esp\n\t"
600 "jmp *%1" 607 "jmp *%1"
601 : 608 :
602 :"r" (current->thread.esp),"r" (current->thread.eip)); 609 :"m" (current->thread.esp),"m" (current->thread.eip));
603} 610}
604 611
612/* Static state in head.S used to set up a CPU */
605extern struct { 613extern struct {
606 void * esp; 614 void * esp;
607 unsigned short ss; 615 unsigned short ss;
608} stack_start; 616} stack_start;
617extern struct i386_pda *start_pda;
618extern struct Xgt_desc_struct cpu_gdt_descr;
609 619
610#ifdef CONFIG_NUMA 620#ifdef CONFIG_NUMA
611 621
@@ -936,9 +946,6 @@ static int __devinit do_boot_cpu(int apicid, int cpu)
936 unsigned long start_eip; 946 unsigned long start_eip;
937 unsigned short nmi_high = 0, nmi_low = 0; 947 unsigned short nmi_high = 0, nmi_low = 0;
938 948
939 ++cpucount;
940 alternatives_smp_switch(1);
941
942 /* 949 /*
943 * We can't use kernel_thread since we must avoid to 950 * We can't use kernel_thread since we must avoid to
944 * reschedule the child. 951 * reschedule the child.
@@ -946,15 +953,30 @@ static int __devinit do_boot_cpu(int apicid, int cpu)
946 idle = alloc_idle_task(cpu); 953 idle = alloc_idle_task(cpu);
947 if (IS_ERR(idle)) 954 if (IS_ERR(idle))
948 panic("failed fork for CPU %d", cpu); 955 panic("failed fork for CPU %d", cpu);
956
957 /* Pre-allocate and initialize the CPU's GDT and PDA so it
958 doesn't have to do any memory allocation during the
959 delicate CPU-bringup phase. */
960 if (!init_gdt(cpu, idle)) {
961 printk(KERN_INFO "Couldn't allocate GDT/PDA for CPU %d\n", cpu);
962 return -1; /* ? */
963 }
964
949 idle->thread.eip = (unsigned long) start_secondary; 965 idle->thread.eip = (unsigned long) start_secondary;
950 /* start_eip had better be page-aligned! */ 966 /* start_eip had better be page-aligned! */
951 start_eip = setup_trampoline(); 967 start_eip = setup_trampoline();
952 968
969 ++cpucount;
970 alternatives_smp_switch(1);
971
953 /* So we see what's up */ 972 /* So we see what's up */
954 printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip); 973 printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);
955 /* Stack for startup_32 can be just as for start_secondary onwards */ 974 /* Stack for startup_32 can be just as for start_secondary onwards */
956 stack_start.esp = (void *) idle->thread.esp; 975 stack_start.esp = (void *) idle->thread.esp;
957 976
977 start_pda = cpu_pda(cpu);
978 cpu_gdt_descr = per_cpu(cpu_gdt_descr, cpu);
979
958 irq_ctx_init(cpu); 980 irq_ctx_init(cpu);
959 981
960 x86_cpu_to_apicid[cpu] = apicid; 982 x86_cpu_to_apicid[cpu] = apicid;
@@ -1109,34 +1131,15 @@ exit:
1109} 1131}
1110#endif 1132#endif
1111 1133
1112static void smp_tune_scheduling (void) 1134static void smp_tune_scheduling(void)
1113{ 1135{
1114 unsigned long cachesize; /* kB */ 1136 unsigned long cachesize; /* kB */
1115 unsigned long bandwidth = 350; /* MB/s */
1116 /*
1117 * Rough estimation for SMP scheduling, this is the number of
1118 * cycles it takes for a fully memory-limited process to flush
1119 * the SMP-local cache.
1120 *
1121 * (For a P5 this pretty much means we will choose another idle
1122 * CPU almost always at wakeup time (this is due to the small
1123 * L1 cache), on PIIs it's around 50-100 usecs, depending on
1124 * the cache size)
1125 */
1126 1137
1127 if (!cpu_khz) { 1138 if (cpu_khz) {
1128 /*
1129 * this basically disables processor-affinity
1130 * scheduling on SMP without a TSC.
1131 */
1132 return;
1133 } else {
1134 cachesize = boot_cpu_data.x86_cache_size; 1139 cachesize = boot_cpu_data.x86_cache_size;
1135 if (cachesize == -1) { 1140
1136 cachesize = 16; /* Pentiums, 2x8kB cache */ 1141 if (cachesize > 0)
1137 bandwidth = 100; 1142 max_cache_size = cachesize * 1024;
1138 }
1139 max_cache_size = cachesize * 1024;
1140 } 1143 }
1141} 1144}
1142 1145
@@ -1462,6 +1465,12 @@ int __devinit __cpu_up(unsigned int cpu)
1462 cpu_set(cpu, smp_commenced_mask); 1465 cpu_set(cpu, smp_commenced_mask);
1463 while (!cpu_isset(cpu, cpu_online_map)) 1466 while (!cpu_isset(cpu, cpu_online_map))
1464 cpu_relax(); 1467 cpu_relax();
1468
1469#ifdef CONFIG_X86_GENERICARCH
1470 if (num_online_cpus() > 8 && genapic == &apic_default)
1471 panic("Default flat APIC routing can't be used with > 8 cpus\n");
1472#endif
1473
1465 return 0; 1474 return 0;
1466} 1475}
1467 1476
diff --git a/arch/i386/kernel/sysenter.c b/arch/i386/kernel/sysenter.c
index 713ba39d32c6..7de9117b5a3a 100644
--- a/arch/i386/kernel/sysenter.c
+++ b/arch/i386/kernel/sysenter.c
@@ -27,7 +27,11 @@
27 * Should the kernel map a VDSO page into processes and pass its 27 * Should the kernel map a VDSO page into processes and pass its
28 * address down to glibc upon exec()? 28 * address down to glibc upon exec()?
29 */ 29 */
30#ifdef CONFIG_PARAVIRT
31unsigned int __read_mostly vdso_enabled = 0;
32#else
30unsigned int __read_mostly vdso_enabled = 1; 33unsigned int __read_mostly vdso_enabled = 1;
34#endif
31 35
32EXPORT_SYMBOL_GPL(vdso_enabled); 36EXPORT_SYMBOL_GPL(vdso_enabled);
33 37
@@ -132,7 +136,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
132 goto up_fail; 136 goto up_fail;
133 } 137 }
134 138
135 vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL); 139 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
136 if (!vma) { 140 if (!vma) {
137 ret = -ENOMEM; 141 ret = -ENOMEM;
138 goto up_fail; 142 goto up_fail;
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index 78af572fd17c..c505b16c0990 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -56,6 +56,7 @@
56#include <asm/uaccess.h> 56#include <asm/uaccess.h>
57#include <asm/processor.h> 57#include <asm/processor.h>
58#include <asm/timer.h> 58#include <asm/timer.h>
59#include <asm/time.h>
59 60
60#include "mach_time.h" 61#include "mach_time.h"
61 62
@@ -116,10 +117,7 @@ static int set_rtc_mmss(unsigned long nowtime)
116 /* gets recalled with irq locally disabled */ 117 /* gets recalled with irq locally disabled */
117 /* XXX - does irqsave resolve this? -johnstul */ 118 /* XXX - does irqsave resolve this? -johnstul */
118 spin_lock_irqsave(&rtc_lock, flags); 119 spin_lock_irqsave(&rtc_lock, flags);
119 if (efi_enabled) 120 retval = set_wallclock(nowtime);
120 retval = efi_set_rtc_mmss(nowtime);
121 else
122 retval = mach_set_rtc_mmss(nowtime);
123 spin_unlock_irqrestore(&rtc_lock, flags); 121 spin_unlock_irqrestore(&rtc_lock, flags);
124 122
125 return retval; 123 return retval;
@@ -223,10 +221,7 @@ unsigned long get_cmos_time(void)
223 221
224 spin_lock_irqsave(&rtc_lock, flags); 222 spin_lock_irqsave(&rtc_lock, flags);
225 223
226 if (efi_enabled) 224 retval = get_wallclock();
227 retval = efi_get_time();
228 else
229 retval = mach_get_cmos_time();
230 225
231 spin_unlock_irqrestore(&rtc_lock, flags); 226 spin_unlock_irqrestore(&rtc_lock, flags);
232 227
@@ -370,7 +365,7 @@ static void __init hpet_time_init(void)
370 printk("Using HPET for base-timer\n"); 365 printk("Using HPET for base-timer\n");
371 } 366 }
372 367
373 time_init_hook(); 368 do_time_init();
374} 369}
375#endif 370#endif
376 371
@@ -392,5 +387,5 @@ void __init time_init(void)
392 387
393 do_settimeofday(&ts); 388 do_settimeofday(&ts);
394 389
395 time_init_hook(); 390 do_time_init();
396} 391}
diff --git a/arch/i386/kernel/time_hpet.c b/arch/i386/kernel/time_hpet.c
index 1a2a979cf6a3..1e4702dfcd01 100644
--- a/arch/i386/kernel/time_hpet.c
+++ b/arch/i386/kernel/time_hpet.c
@@ -132,14 +132,20 @@ int __init hpet_enable(void)
132 * the single HPET timer for system time. 132 * the single HPET timer for system time.
133 */ 133 */
134#ifdef CONFIG_HPET_EMULATE_RTC 134#ifdef CONFIG_HPET_EMULATE_RTC
135 if (!(id & HPET_ID_NUMBER)) 135 if (!(id & HPET_ID_NUMBER)) {
136 iounmap(hpet_virt_address);
137 hpet_virt_address = NULL;
136 return -1; 138 return -1;
139 }
137#endif 140#endif
138 141
139 142
140 hpet_period = hpet_readl(HPET_PERIOD); 143 hpet_period = hpet_readl(HPET_PERIOD);
141 if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD)) 144 if ((hpet_period < HPET_MIN_PERIOD) || (hpet_period > HPET_MAX_PERIOD)) {
145 iounmap(hpet_virt_address);
146 hpet_virt_address = NULL;
142 return -1; 147 return -1;
148 }
143 149
144 /* 150 /*
145 * 64 bit math 151 * 64 bit math
@@ -156,8 +162,11 @@ int __init hpet_enable(void)
156 162
157 hpet_use_timer = id & HPET_ID_LEGSUP; 163 hpet_use_timer = id & HPET_ID_LEGSUP;
158 164
159 if (hpet_timer_stop_set_go(hpet_tick)) 165 if (hpet_timer_stop_set_go(hpet_tick)) {
166 iounmap(hpet_virt_address);
167 hpet_virt_address = NULL;
160 return -1; 168 return -1;
169 }
161 170
162 use_hpet = 1; 171 use_hpet = 1;
163 172
diff --git a/arch/i386/kernel/topology.c b/arch/i386/kernel/topology.c
index 07d6da36a825..79cf608e14ca 100644
--- a/arch/i386/kernel/topology.c
+++ b/arch/i386/kernel/topology.c
@@ -40,14 +40,18 @@ int arch_register_cpu(int num)
40 * restrictions and assumptions in kernel. This basically 40 * restrictions and assumptions in kernel. This basically
41 * doesnt add a control file, one cannot attempt to offline 41 * doesnt add a control file, one cannot attempt to offline
42 * BSP. 42 * BSP.
43 *
44 * Also certain PCI quirks require not to enable hotplug control
45 * for all CPU's.
43 */ 46 */
44 if (!num) 47 if (num && enable_cpu_hotplug)
45 cpu_devices[num].cpu.no_control = 1; 48 cpu_devices[num].cpu.hotpluggable = 1;
46 49
47 return register_cpu(&cpu_devices[num].cpu, num); 50 return register_cpu(&cpu_devices[num].cpu, num);
48} 51}
49 52
50#ifdef CONFIG_HOTPLUG_CPU 53#ifdef CONFIG_HOTPLUG_CPU
54int enable_cpu_hotplug = 1;
51 55
52void arch_unregister_cpu(int num) { 56void arch_unregister_cpu(int num) {
53 return unregister_cpu(&cpu_devices[num].cpu); 57 return unregister_cpu(&cpu_devices[num].cpu);
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index fe9c5e8e7e6f..68de48e498ca 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -29,6 +29,7 @@
29#include <linux/kexec.h> 29#include <linux/kexec.h>
30#include <linux/unwind.h> 30#include <linux/unwind.h>
31#include <linux/uaccess.h> 31#include <linux/uaccess.h>
32#include <linux/nmi.h>
32 33
33#ifdef CONFIG_EISA 34#ifdef CONFIG_EISA
34#include <linux/ioport.h> 35#include <linux/ioport.h>
@@ -61,9 +62,6 @@ int panic_on_unrecovered_nmi;
61 62
62asmlinkage int system_call(void); 63asmlinkage int system_call(void);
63 64
64struct desc_struct default_ldt[] = { { 0, 0 }, { 0, 0 }, { 0, 0 },
65 { 0, 0 }, { 0, 0 } };
66
67/* Do we ignore FPU interrupts ? */ 65/* Do we ignore FPU interrupts ? */
68char ignore_fpu_irq = 0; 66char ignore_fpu_irq = 0;
69 67
@@ -94,7 +92,7 @@ asmlinkage void alignment_check(void);
94asmlinkage void spurious_interrupt_bug(void); 92asmlinkage void spurious_interrupt_bug(void);
95asmlinkage void machine_check(void); 93asmlinkage void machine_check(void);
96 94
97static int kstack_depth_to_print = 24; 95int kstack_depth_to_print = 24;
98#ifdef CONFIG_STACK_UNWIND 96#ifdef CONFIG_STACK_UNWIND
99static int call_trace = 1; 97static int call_trace = 1;
100#else 98#else
@@ -163,16 +161,25 @@ dump_trace_unwind(struct unwind_frame_info *info, void *data)
163{ 161{
164 struct ops_and_data *oad = (struct ops_and_data *)data; 162 struct ops_and_data *oad = (struct ops_and_data *)data;
165 int n = 0; 163 int n = 0;
164 unsigned long sp = UNW_SP(info);
166 165
166 if (arch_unw_user_mode(info))
167 return -1;
167 while (unwind(info) == 0 && UNW_PC(info)) { 168 while (unwind(info) == 0 && UNW_PC(info)) {
168 n++; 169 n++;
169 oad->ops->address(oad->data, UNW_PC(info)); 170 oad->ops->address(oad->data, UNW_PC(info));
170 if (arch_unw_user_mode(info)) 171 if (arch_unw_user_mode(info))
171 break; 172 break;
173 if ((sp & ~(PAGE_SIZE - 1)) == (UNW_SP(info) & ~(PAGE_SIZE - 1))
174 && sp > UNW_SP(info))
175 break;
176 sp = UNW_SP(info);
172 } 177 }
173 return n; 178 return n;
174} 179}
175 180
181#define MSG(msg) ops->warning(data, msg)
182
176void dump_trace(struct task_struct *task, struct pt_regs *regs, 183void dump_trace(struct task_struct *task, struct pt_regs *regs,
177 unsigned long *stack, 184 unsigned long *stack,
178 struct stacktrace_ops *ops, void *data) 185 struct stacktrace_ops *ops, void *data)
@@ -191,29 +198,31 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
191 if (unwind_init_frame_info(&info, task, regs) == 0) 198 if (unwind_init_frame_info(&info, task, regs) == 0)
192 unw_ret = dump_trace_unwind(&info, &oad); 199 unw_ret = dump_trace_unwind(&info, &oad);
193 } else if (task == current) 200 } else if (task == current)
194 unw_ret = unwind_init_running(&info, dump_trace_unwind, &oad); 201 unw_ret = unwind_init_running(&info, dump_trace_unwind,
202 &oad);
195 else { 203 else {
196 if (unwind_init_blocked(&info, task) == 0) 204 if (unwind_init_blocked(&info, task) == 0)
197 unw_ret = dump_trace_unwind(&info, &oad); 205 unw_ret = dump_trace_unwind(&info, &oad);
198 } 206 }
199 if (unw_ret > 0) { 207 if (unw_ret > 0) {
200 if (call_trace == 1 && !arch_unw_user_mode(&info)) { 208 if (call_trace == 1 && !arch_unw_user_mode(&info)) {
201 ops->warning_symbol(data, "DWARF2 unwinder stuck at %s\n", 209 ops->warning_symbol(data,
210 "DWARF2 unwinder stuck at %s",
202 UNW_PC(&info)); 211 UNW_PC(&info));
203 if (UNW_SP(&info) >= PAGE_OFFSET) { 212 if (UNW_SP(&info) >= PAGE_OFFSET) {
204 ops->warning(data, "Leftover inexact backtrace:\n"); 213 MSG("Leftover inexact backtrace:");
205 stack = (void *)UNW_SP(&info); 214 stack = (void *)UNW_SP(&info);
206 if (!stack) 215 if (!stack)
207 return; 216 return;
208 ebp = UNW_FP(&info); 217 ebp = UNW_FP(&info);
209 } else 218 } else
210 ops->warning(data, "Full inexact backtrace again:\n"); 219 MSG("Full inexact backtrace again:");
211 } else if (call_trace >= 1) 220 } else if (call_trace >= 1)
212 return; 221 return;
213 else 222 else
214 ops->warning(data, "Full inexact backtrace again:\n"); 223 MSG("Full inexact backtrace again:");
215 } else 224 } else
216 ops->warning(data, "Inexact backtrace:\n"); 225 MSG("Inexact backtrace:");
217 } 226 }
218 if (!stack) { 227 if (!stack) {
219 unsigned long dummy; 228 unsigned long dummy;
@@ -247,6 +256,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
247 stack = (unsigned long*)context->previous_esp; 256 stack = (unsigned long*)context->previous_esp;
248 if (!stack) 257 if (!stack)
249 break; 258 break;
259 touch_nmi_watchdog();
250 } 260 }
251} 261}
252EXPORT_SYMBOL(dump_trace); 262EXPORT_SYMBOL(dump_trace);
@@ -379,7 +389,7 @@ void show_registers(struct pt_regs *regs)
379 * time of the fault.. 389 * time of the fault..
380 */ 390 */
381 if (in_kernel) { 391 if (in_kernel) {
382 u8 __user *eip; 392 u8 *eip;
383 int code_bytes = 64; 393 int code_bytes = 64;
384 unsigned char c; 394 unsigned char c;
385 395
@@ -388,18 +398,20 @@ void show_registers(struct pt_regs *regs)
388 398
389 printk(KERN_EMERG "Code: "); 399 printk(KERN_EMERG "Code: ");
390 400
391 eip = (u8 __user *)regs->eip - 43; 401 eip = (u8 *)regs->eip - 43;
392 if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) { 402 if (eip < (u8 *)PAGE_OFFSET ||
403 probe_kernel_address(eip, c)) {
393 /* try starting at EIP */ 404 /* try starting at EIP */
394 eip = (u8 __user *)regs->eip; 405 eip = (u8 *)regs->eip;
395 code_bytes = 32; 406 code_bytes = 32;
396 } 407 }
397 for (i = 0; i < code_bytes; i++, eip++) { 408 for (i = 0; i < code_bytes; i++, eip++) {
398 if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) { 409 if (eip < (u8 *)PAGE_OFFSET ||
410 probe_kernel_address(eip, c)) {
399 printk(" Bad EIP value."); 411 printk(" Bad EIP value.");
400 break; 412 break;
401 } 413 }
402 if (eip == (u8 __user *)regs->eip) 414 if (eip == (u8 *)regs->eip)
403 printk("<%02x> ", c); 415 printk("<%02x> ", c);
404 else 416 else
405 printk("%02x ", c); 417 printk("%02x ", c);
@@ -415,7 +427,7 @@ static void handle_BUG(struct pt_regs *regs)
415 427
416 if (eip < PAGE_OFFSET) 428 if (eip < PAGE_OFFSET)
417 return; 429 return;
418 if (probe_kernel_address((unsigned short __user *)eip, ud2)) 430 if (probe_kernel_address((unsigned short *)eip, ud2))
419 return; 431 return;
420 if (ud2 != 0x0b0f) 432 if (ud2 != 0x0b0f)
421 return; 433 return;
@@ -428,11 +440,11 @@ static void handle_BUG(struct pt_regs *regs)
428 char *file; 440 char *file;
429 char c; 441 char c;
430 442
431 if (probe_kernel_address((unsigned short __user *)(eip + 2), 443 if (probe_kernel_address((unsigned short *)(eip + 2), line))
432 line))
433 break; 444 break;
434 if (__get_user(file, (char * __user *)(eip + 4)) || 445 if (probe_kernel_address((char **)(eip + 4), file) ||
435 (unsigned long)file < PAGE_OFFSET || __get_user(c, file)) 446 (unsigned long)file < PAGE_OFFSET ||
447 probe_kernel_address(file, c))
436 file = "<bad filename>"; 448 file = "<bad filename>";
437 449
438 printk(KERN_EMERG "kernel BUG at %s:%d!\n", file, line); 450 printk(KERN_EMERG "kernel BUG at %s:%d!\n", file, line);
@@ -452,7 +464,7 @@ void die(const char * str, struct pt_regs * regs, long err)
452 u32 lock_owner; 464 u32 lock_owner;
453 int lock_owner_depth; 465 int lock_owner_depth;
454 } die = { 466 } die = {
455 .lock = SPIN_LOCK_UNLOCKED, 467 .lock = __SPIN_LOCK_UNLOCKED(die.lock),
456 .lock_owner = -1, 468 .lock_owner = -1,
457 .lock_owner_depth = 0 469 .lock_owner_depth = 0
458 }; 470 };
@@ -707,8 +719,7 @@ mem_parity_error(unsigned char reason, struct pt_regs * regs)
707{ 719{
708 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x on " 720 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x on "
709 "CPU %d.\n", reason, smp_processor_id()); 721 "CPU %d.\n", reason, smp_processor_id());
710 printk(KERN_EMERG "You probably have a hardware problem with your RAM " 722 printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
711 "chips\n");
712 if (panic_on_unrecovered_nmi) 723 if (panic_on_unrecovered_nmi)
713 panic("NMI: Not continuing"); 724 panic("NMI: Not continuing");
714 725
@@ -773,7 +784,6 @@ void __kprobes die_nmi(struct pt_regs *regs, const char *msg)
773 printk(" on CPU%d, eip %08lx, registers:\n", 784 printk(" on CPU%d, eip %08lx, registers:\n",
774 smp_processor_id(), regs->eip); 785 smp_processor_id(), regs->eip);
775 show_registers(regs); 786 show_registers(regs);
776 printk(KERN_EMERG "console shuts up ...\n");
777 console_silent(); 787 console_silent();
778 spin_unlock(&nmi_print_lock); 788 spin_unlock(&nmi_print_lock);
779 bust_spinlocks(0); 789 bust_spinlocks(0);
@@ -1088,49 +1098,24 @@ fastcall void do_spurious_interrupt_bug(struct pt_regs * regs,
1088#endif 1098#endif
1089} 1099}
1090 1100
1091fastcall void setup_x86_bogus_stack(unsigned char * stk) 1101fastcall unsigned long patch_espfix_desc(unsigned long uesp,
1092{ 1102 unsigned long kesp)
1093 unsigned long *switch16_ptr, *switch32_ptr;
1094 struct pt_regs *regs;
1095 unsigned long stack_top, stack_bot;
1096 unsigned short iret_frame16_off;
1097 int cpu = smp_processor_id();
1098 /* reserve the space on 32bit stack for the magic switch16 pointer */
1099 memmove(stk, stk + 8, sizeof(struct pt_regs));
1100 switch16_ptr = (unsigned long *)(stk + sizeof(struct pt_regs));
1101 regs = (struct pt_regs *)stk;
1102 /* now the switch32 on 16bit stack */
1103 stack_bot = (unsigned long)&per_cpu(cpu_16bit_stack, cpu);
1104 stack_top = stack_bot + CPU_16BIT_STACK_SIZE;
1105 switch32_ptr = (unsigned long *)(stack_top - 8);
1106 iret_frame16_off = CPU_16BIT_STACK_SIZE - 8 - 20;
1107 /* copy iret frame on 16bit stack */
1108 memcpy((void *)(stack_bot + iret_frame16_off), &regs->eip, 20);
1109 /* fill in the switch pointers */
1110 switch16_ptr[0] = (regs->esp & 0xffff0000) | iret_frame16_off;
1111 switch16_ptr[1] = __ESPFIX_SS;
1112 switch32_ptr[0] = (unsigned long)stk + sizeof(struct pt_regs) +
1113 8 - CPU_16BIT_STACK_SIZE;
1114 switch32_ptr[1] = __KERNEL_DS;
1115}
1116
1117fastcall unsigned char * fixup_x86_bogus_stack(unsigned short sp)
1118{ 1103{
1119 unsigned long *switch32_ptr;
1120 unsigned char *stack16, *stack32;
1121 unsigned long stack_top, stack_bot;
1122 int len;
1123 int cpu = smp_processor_id(); 1104 int cpu = smp_processor_id();
1124 stack_bot = (unsigned long)&per_cpu(cpu_16bit_stack, cpu); 1105 struct Xgt_desc_struct *cpu_gdt_descr = &per_cpu(cpu_gdt_descr, cpu);
1125 stack_top = stack_bot + CPU_16BIT_STACK_SIZE; 1106 struct desc_struct *gdt = (struct desc_struct *)cpu_gdt_descr->address;
1126 switch32_ptr = (unsigned long *)(stack_top - 8); 1107 unsigned long base = (kesp - uesp) & -THREAD_SIZE;
1127 /* copy the data from 16bit stack to 32bit stack */ 1108 unsigned long new_kesp = kesp - base;
1128 len = CPU_16BIT_STACK_SIZE - 8 - sp; 1109 unsigned long lim_pages = (new_kesp | (THREAD_SIZE - 1)) >> PAGE_SHIFT;
1129 stack16 = (unsigned char *)(stack_bot + sp); 1110 __u64 desc = *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS];
1130 stack32 = (unsigned char *) 1111 /* Set up base for espfix segment */
1131 (switch32_ptr[0] + CPU_16BIT_STACK_SIZE - 8 - len); 1112 desc &= 0x00f0ff0000000000ULL;
1132 memcpy(stack32, stack16, len); 1113 desc |= ((((__u64)base) << 16) & 0x000000ffffff0000ULL) |
1133 return stack32; 1114 ((((__u64)base) << 32) & 0xff00000000000000ULL) |
1115 ((((__u64)lim_pages) << 32) & 0x000f000000000000ULL) |
1116 (lim_pages & 0xffff);
1117 *(__u64 *)&gdt[GDT_ENTRY_ESPFIX_SS] = desc;
1118 return new_kesp;
1134} 1119}
1135 1120
1136/* 1121/*
@@ -1143,7 +1128,7 @@ fastcall unsigned char * fixup_x86_bogus_stack(unsigned short sp)
1143 * Must be called with kernel preemption disabled (in this case, 1128 * Must be called with kernel preemption disabled (in this case,
1144 * local interrupts are disabled at the call-site in entry.S). 1129 * local interrupts are disabled at the call-site in entry.S).
1145 */ 1130 */
1146asmlinkage void math_state_restore(struct pt_regs regs) 1131asmlinkage void math_state_restore(void)
1147{ 1132{
1148 struct thread_info *thread = current_thread_info(); 1133 struct thread_info *thread = current_thread_info();
1149 struct task_struct *tsk = thread->task; 1134 struct task_struct *tsk = thread->task;
@@ -1153,6 +1138,7 @@ asmlinkage void math_state_restore(struct pt_regs regs)
1153 init_fpu(tsk); 1138 init_fpu(tsk);
1154 restore_fpu(tsk); 1139 restore_fpu(tsk);
1155 thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */ 1140 thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */
1141 tsk->fpu_counter++;
1156} 1142}
1157 1143
1158#ifndef CONFIG_MATH_EMULATION 1144#ifndef CONFIG_MATH_EMULATION
diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index 9810c8c90750..1bbe45dca7a0 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -13,7 +13,6 @@
13 13
14#include <asm/delay.h> 14#include <asm/delay.h>
15#include <asm/tsc.h> 15#include <asm/tsc.h>
16#include <asm/delay.h>
17#include <asm/io.h> 16#include <asm/io.h>
18 17
19#include "mach_timer.h" 18#include "mach_timer.h"
diff --git a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c
index cbcd61d6120b..be2f96e67f78 100644
--- a/arch/i386/kernel/vm86.c
+++ b/arch/i386/kernel/vm86.c
@@ -43,6 +43,7 @@
43#include <linux/highmem.h> 43#include <linux/highmem.h>
44#include <linux/ptrace.h> 44#include <linux/ptrace.h>
45#include <linux/audit.h> 45#include <linux/audit.h>
46#include <linux/stddef.h>
46 47
47#include <asm/uaccess.h> 48#include <asm/uaccess.h>
48#include <asm/io.h> 49#include <asm/io.h>
@@ -72,10 +73,10 @@
72/* 73/*
73 * 8- and 16-bit register defines.. 74 * 8- and 16-bit register defines..
74 */ 75 */
75#define AL(regs) (((unsigned char *)&((regs)->eax))[0]) 76#define AL(regs) (((unsigned char *)&((regs)->pt.eax))[0])
76#define AH(regs) (((unsigned char *)&((regs)->eax))[1]) 77#define AH(regs) (((unsigned char *)&((regs)->pt.eax))[1])
77#define IP(regs) (*(unsigned short *)&((regs)->eip)) 78#define IP(regs) (*(unsigned short *)&((regs)->pt.eip))
78#define SP(regs) (*(unsigned short *)&((regs)->esp)) 79#define SP(regs) (*(unsigned short *)&((regs)->pt.esp))
79 80
80/* 81/*
81 * virtual flags (16 and 32-bit versions) 82 * virtual flags (16 and 32-bit versions)
@@ -89,10 +90,37 @@
89#define SAFE_MASK (0xDD5) 90#define SAFE_MASK (0xDD5)
90#define RETURN_MASK (0xDFF) 91#define RETURN_MASK (0xDFF)
91 92
92#define VM86_REGS_PART2 orig_eax 93/* convert kernel_vm86_regs to vm86_regs */
93#define VM86_REGS_SIZE1 \ 94static int copy_vm86_regs_to_user(struct vm86_regs __user *user,
94 ( (unsigned)( & (((struct kernel_vm86_regs *)0)->VM86_REGS_PART2) ) ) 95 const struct kernel_vm86_regs *regs)
95#define VM86_REGS_SIZE2 (sizeof(struct kernel_vm86_regs) - VM86_REGS_SIZE1) 96{
97 int ret = 0;
98
99 /* kernel_vm86_regs is missing xfs, so copy everything up to
100 (but not including) xgs, and then rest after xgs. */
101 ret += copy_to_user(user, regs, offsetof(struct kernel_vm86_regs, pt.xgs));
102 ret += copy_to_user(&user->__null_gs, &regs->pt.xgs,
103 sizeof(struct kernel_vm86_regs) -
104 offsetof(struct kernel_vm86_regs, pt.xgs));
105
106 return ret;
107}
108
109/* convert vm86_regs to kernel_vm86_regs */
110static int copy_vm86_regs_from_user(struct kernel_vm86_regs *regs,
111 const struct vm86_regs __user *user,
112 unsigned extra)
113{
114 int ret = 0;
115
116 ret += copy_from_user(regs, user, offsetof(struct kernel_vm86_regs, pt.xgs));
117 ret += copy_from_user(&regs->pt.xgs, &user->__null_gs,
118 sizeof(struct kernel_vm86_regs) -
119 offsetof(struct kernel_vm86_regs, pt.xgs) +
120 extra);
121
122 return ret;
123}
96 124
97struct pt_regs * FASTCALL(save_v86_state(struct kernel_vm86_regs * regs)); 125struct pt_regs * FASTCALL(save_v86_state(struct kernel_vm86_regs * regs));
98struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs) 126struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs)
@@ -112,10 +140,8 @@ struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs)
112 printk("no vm86_info: BAD\n"); 140 printk("no vm86_info: BAD\n");
113 do_exit(SIGSEGV); 141 do_exit(SIGSEGV);
114 } 142 }
115 set_flags(regs->eflags, VEFLAGS, VIF_MASK | current->thread.v86mask); 143 set_flags(regs->pt.eflags, VEFLAGS, VIF_MASK | current->thread.v86mask);
116 tmp = copy_to_user(&current->thread.vm86_info->regs,regs, VM86_REGS_SIZE1); 144 tmp = copy_vm86_regs_to_user(&current->thread.vm86_info->regs,regs);
117 tmp += copy_to_user(&current->thread.vm86_info->regs.VM86_REGS_PART2,
118 &regs->VM86_REGS_PART2, VM86_REGS_SIZE2);
119 tmp += put_user(current->thread.screen_bitmap,&current->thread.vm86_info->screen_bitmap); 145 tmp += put_user(current->thread.screen_bitmap,&current->thread.vm86_info->screen_bitmap);
120 if (tmp) { 146 if (tmp) {
121 printk("vm86: could not access userspace vm86_info\n"); 147 printk("vm86: could not access userspace vm86_info\n");
@@ -129,9 +155,11 @@ struct pt_regs * fastcall save_v86_state(struct kernel_vm86_regs * regs)
129 current->thread.saved_esp0 = 0; 155 current->thread.saved_esp0 = 0;
130 put_cpu(); 156 put_cpu();
131 157
132 loadsegment(fs, current->thread.saved_fs);
133 loadsegment(gs, current->thread.saved_gs);
134 ret = KVM86->regs32; 158 ret = KVM86->regs32;
159
160 loadsegment(fs, current->thread.saved_fs);
161 ret->xgs = current->thread.saved_gs;
162
135 return ret; 163 return ret;
136} 164}
137 165
@@ -183,9 +211,9 @@ asmlinkage int sys_vm86old(struct pt_regs regs)
183 tsk = current; 211 tsk = current;
184 if (tsk->thread.saved_esp0) 212 if (tsk->thread.saved_esp0)
185 goto out; 213 goto out;
186 tmp = copy_from_user(&info, v86, VM86_REGS_SIZE1); 214 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
187 tmp += copy_from_user(&info.regs.VM86_REGS_PART2, &v86->regs.VM86_REGS_PART2, 215 offsetof(struct kernel_vm86_struct, vm86plus) -
188 (long)&info.vm86plus - (long)&info.regs.VM86_REGS_PART2); 216 sizeof(info.regs));
189 ret = -EFAULT; 217 ret = -EFAULT;
190 if (tmp) 218 if (tmp)
191 goto out; 219 goto out;
@@ -233,9 +261,9 @@ asmlinkage int sys_vm86(struct pt_regs regs)
233 if (tsk->thread.saved_esp0) 261 if (tsk->thread.saved_esp0)
234 goto out; 262 goto out;
235 v86 = (struct vm86plus_struct __user *)regs.ecx; 263 v86 = (struct vm86plus_struct __user *)regs.ecx;
236 tmp = copy_from_user(&info, v86, VM86_REGS_SIZE1); 264 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
237 tmp += copy_from_user(&info.regs.VM86_REGS_PART2, &v86->regs.VM86_REGS_PART2, 265 offsetof(struct kernel_vm86_struct, regs32) -
238 (long)&info.regs32 - (long)&info.regs.VM86_REGS_PART2); 266 sizeof(info.regs));
239 ret = -EFAULT; 267 ret = -EFAULT;
240 if (tmp) 268 if (tmp)
241 goto out; 269 goto out;
@@ -252,15 +280,15 @@ out:
252static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk) 280static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk)
253{ 281{
254 struct tss_struct *tss; 282 struct tss_struct *tss;
255 long eax;
256/* 283/*
257 * make sure the vm86() system call doesn't try to do anything silly 284 * make sure the vm86() system call doesn't try to do anything silly
258 */ 285 */
259 info->regs.__null_ds = 0; 286 info->regs.pt.xds = 0;
260 info->regs.__null_es = 0; 287 info->regs.pt.xes = 0;
288 info->regs.pt.xgs = 0;
261 289
262/* we are clearing fs,gs later just before "jmp resume_userspace", 290/* we are clearing fs later just before "jmp resume_userspace",
263 * because starting with Linux 2.1.x they aren't no longer saved/restored 291 * because it is not saved/restored.
264 */ 292 */
265 293
266/* 294/*
@@ -268,10 +296,10 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
268 * has set it up safely, so this makes sure interrupt etc flags are 296 * has set it up safely, so this makes sure interrupt etc flags are
269 * inherited from protected mode. 297 * inherited from protected mode.
270 */ 298 */
271 VEFLAGS = info->regs.eflags; 299 VEFLAGS = info->regs.pt.eflags;
272 info->regs.eflags &= SAFE_MASK; 300 info->regs.pt.eflags &= SAFE_MASK;
273 info->regs.eflags |= info->regs32->eflags & ~SAFE_MASK; 301 info->regs.pt.eflags |= info->regs32->eflags & ~SAFE_MASK;
274 info->regs.eflags |= VM_MASK; 302 info->regs.pt.eflags |= VM_MASK;
275 303
276 switch (info->cpu_type) { 304 switch (info->cpu_type) {
277 case CPU_286: 305 case CPU_286:
@@ -294,7 +322,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
294 info->regs32->eax = 0; 322 info->regs32->eax = 0;
295 tsk->thread.saved_esp0 = tsk->thread.esp0; 323 tsk->thread.saved_esp0 = tsk->thread.esp0;
296 savesegment(fs, tsk->thread.saved_fs); 324 savesegment(fs, tsk->thread.saved_fs);
297 savesegment(gs, tsk->thread.saved_gs); 325 tsk->thread.saved_gs = info->regs32->xgs;
298 326
299 tss = &per_cpu(init_tss, get_cpu()); 327 tss = &per_cpu(init_tss, get_cpu());
300 tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0; 328 tsk->thread.esp0 = (unsigned long) &info->VM86_TSS_ESP0;
@@ -306,19 +334,18 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
306 tsk->thread.screen_bitmap = info->screen_bitmap; 334 tsk->thread.screen_bitmap = info->screen_bitmap;
307 if (info->flags & VM86_SCREEN_BITMAP) 335 if (info->flags & VM86_SCREEN_BITMAP)
308 mark_screen_rdonly(tsk->mm); 336 mark_screen_rdonly(tsk->mm);
309 __asm__ __volatile__("xorl %eax,%eax; movl %eax,%fs; movl %eax,%gs\n\t");
310 __asm__ __volatile__("movl %%eax, %0\n" :"=r"(eax));
311 337
312 /*call audit_syscall_exit since we do not exit via the normal paths */ 338 /*call audit_syscall_exit since we do not exit via the normal paths */
313 if (unlikely(current->audit_context)) 339 if (unlikely(current->audit_context))
314 audit_syscall_exit(AUDITSC_RESULT(eax), eax); 340 audit_syscall_exit(AUDITSC_RESULT(0), 0);
315 341
316 __asm__ __volatile__( 342 __asm__ __volatile__(
317 "movl %0,%%esp\n\t" 343 "movl %0,%%esp\n\t"
318 "movl %1,%%ebp\n\t" 344 "movl %1,%%ebp\n\t"
345 "mov %2, %%fs\n\t"
319 "jmp resume_userspace" 346 "jmp resume_userspace"
320 : /* no outputs */ 347 : /* no outputs */
321 :"r" (&info->regs), "r" (task_thread_info(tsk))); 348 :"r" (&info->regs), "r" (task_thread_info(tsk)), "r" (0));
322 /* we never return here */ 349 /* we never return here */
323} 350}
324 351
@@ -348,12 +375,12 @@ static inline void clear_IF(struct kernel_vm86_regs * regs)
348 375
349static inline void clear_TF(struct kernel_vm86_regs * regs) 376static inline void clear_TF(struct kernel_vm86_regs * regs)
350{ 377{
351 regs->eflags &= ~TF_MASK; 378 regs->pt.eflags &= ~TF_MASK;
352} 379}
353 380
354static inline void clear_AC(struct kernel_vm86_regs * regs) 381static inline void clear_AC(struct kernel_vm86_regs * regs)
355{ 382{
356 regs->eflags &= ~AC_MASK; 383 regs->pt.eflags &= ~AC_MASK;
357} 384}
358 385
359/* It is correct to call set_IF(regs) from the set_vflags_* 386/* It is correct to call set_IF(regs) from the set_vflags_*
@@ -370,7 +397,7 @@ static inline void clear_AC(struct kernel_vm86_regs * regs)
370static inline void set_vflags_long(unsigned long eflags, struct kernel_vm86_regs * regs) 397static inline void set_vflags_long(unsigned long eflags, struct kernel_vm86_regs * regs)
371{ 398{
372 set_flags(VEFLAGS, eflags, current->thread.v86mask); 399 set_flags(VEFLAGS, eflags, current->thread.v86mask);
373 set_flags(regs->eflags, eflags, SAFE_MASK); 400 set_flags(regs->pt.eflags, eflags, SAFE_MASK);
374 if (eflags & IF_MASK) 401 if (eflags & IF_MASK)
375 set_IF(regs); 402 set_IF(regs);
376 else 403 else
@@ -380,7 +407,7 @@ static inline void set_vflags_long(unsigned long eflags, struct kernel_vm86_regs
380static inline void set_vflags_short(unsigned short flags, struct kernel_vm86_regs * regs) 407static inline void set_vflags_short(unsigned short flags, struct kernel_vm86_regs * regs)
381{ 408{
382 set_flags(VFLAGS, flags, current->thread.v86mask); 409 set_flags(VFLAGS, flags, current->thread.v86mask);
383 set_flags(regs->eflags, flags, SAFE_MASK); 410 set_flags(regs->pt.eflags, flags, SAFE_MASK);
384 if (flags & IF_MASK) 411 if (flags & IF_MASK)
385 set_IF(regs); 412 set_IF(regs);
386 else 413 else
@@ -389,7 +416,7 @@ static inline void set_vflags_short(unsigned short flags, struct kernel_vm86_reg
389 416
390static inline unsigned long get_vflags(struct kernel_vm86_regs * regs) 417static inline unsigned long get_vflags(struct kernel_vm86_regs * regs)
391{ 418{
392 unsigned long flags = regs->eflags & RETURN_MASK; 419 unsigned long flags = regs->pt.eflags & RETURN_MASK;
393 420
394 if (VEFLAGS & VIF_MASK) 421 if (VEFLAGS & VIF_MASK)
395 flags |= IF_MASK; 422 flags |= IF_MASK;
@@ -493,7 +520,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
493 unsigned long __user *intr_ptr; 520 unsigned long __user *intr_ptr;
494 unsigned long segoffs; 521 unsigned long segoffs;
495 522
496 if (regs->cs == BIOSSEG) 523 if (regs->pt.xcs == BIOSSEG)
497 goto cannot_handle; 524 goto cannot_handle;
498 if (is_revectored(i, &KVM86->int_revectored)) 525 if (is_revectored(i, &KVM86->int_revectored))
499 goto cannot_handle; 526 goto cannot_handle;
@@ -505,9 +532,9 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
505 if ((segoffs >> 16) == BIOSSEG) 532 if ((segoffs >> 16) == BIOSSEG)
506 goto cannot_handle; 533 goto cannot_handle;
507 pushw(ssp, sp, get_vflags(regs), cannot_handle); 534 pushw(ssp, sp, get_vflags(regs), cannot_handle);
508 pushw(ssp, sp, regs->cs, cannot_handle); 535 pushw(ssp, sp, regs->pt.xcs, cannot_handle);
509 pushw(ssp, sp, IP(regs), cannot_handle); 536 pushw(ssp, sp, IP(regs), cannot_handle);
510 regs->cs = segoffs >> 16; 537 regs->pt.xcs = segoffs >> 16;
511 SP(regs) -= 6; 538 SP(regs) -= 6;
512 IP(regs) = segoffs & 0xffff; 539 IP(regs) = segoffs & 0xffff;
513 clear_TF(regs); 540 clear_TF(regs);
@@ -524,7 +551,7 @@ int handle_vm86_trap(struct kernel_vm86_regs * regs, long error_code, int trapno
524 if (VMPI.is_vm86pus) { 551 if (VMPI.is_vm86pus) {
525 if ( (trapno==3) || (trapno==1) ) 552 if ( (trapno==3) || (trapno==1) )
526 return_to_32bit(regs, VM86_TRAP + (trapno << 8)); 553 return_to_32bit(regs, VM86_TRAP + (trapno << 8));
527 do_int(regs, trapno, (unsigned char __user *) (regs->ss << 4), SP(regs)); 554 do_int(regs, trapno, (unsigned char __user *) (regs->pt.xss << 4), SP(regs));
528 return 0; 555 return 0;
529 } 556 }
530 if (trapno !=1) 557 if (trapno !=1)
@@ -560,10 +587,10 @@ void handle_vm86_fault(struct kernel_vm86_regs * regs, long error_code)
560 handle_vm86_trap(regs, 0, 1); \ 587 handle_vm86_trap(regs, 0, 1); \
561 return; } while (0) 588 return; } while (0)
562 589
563 orig_flags = *(unsigned short *)&regs->eflags; 590 orig_flags = *(unsigned short *)&regs->pt.eflags;
564 591
565 csp = (unsigned char __user *) (regs->cs << 4); 592 csp = (unsigned char __user *) (regs->pt.xcs << 4);
566 ssp = (unsigned char __user *) (regs->ss << 4); 593 ssp = (unsigned char __user *) (regs->pt.xss << 4);
567 sp = SP(regs); 594 sp = SP(regs);
568 ip = IP(regs); 595 ip = IP(regs);
569 596
@@ -650,7 +677,7 @@ void handle_vm86_fault(struct kernel_vm86_regs * regs, long error_code)
650 SP(regs) += 6; 677 SP(regs) += 6;
651 } 678 }
652 IP(regs) = newip; 679 IP(regs) = newip;
653 regs->cs = newcs; 680 regs->pt.xcs = newcs;
654 CHECK_IF_IN_TRAP; 681 CHECK_IF_IN_TRAP;
655 if (data32) { 682 if (data32) {
656 set_vflags_long(newflags, regs); 683 set_vflags_long(newflags, regs);
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
index c6f84a0322ba..56e6ad5cb045 100644
--- a/arch/i386/kernel/vmlinux.lds.S
+++ b/arch/i386/kernel/vmlinux.lds.S
@@ -1,13 +1,26 @@
1/* ld script to make i386 Linux kernel 1/* ld script to make i386 Linux kernel
2 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>; 2 * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
3 *
4 * Don't define absolute symbols until and unless you know that symbol
5 * value is should remain constant even if kernel image is relocated
6 * at run time. Absolute symbols are not relocated. If symbol value should
7 * change if kernel is relocated, make the symbol section relative and
8 * put it inside the section definition.
3 */ 9 */
4 10
11/* Don't define absolute symbols until and unless you know that symbol
12 * value is should remain constant even if kernel image is relocated
13 * at run time. Absolute symbols are not relocated. If symbol value should
14 * change if kernel is relocated, make the symbol section relative and
15 * put it inside the section definition.
16 */
5#define LOAD_OFFSET __PAGE_OFFSET 17#define LOAD_OFFSET __PAGE_OFFSET
6 18
7#include <asm-generic/vmlinux.lds.h> 19#include <asm-generic/vmlinux.lds.h>
8#include <asm/thread_info.h> 20#include <asm/thread_info.h>
9#include <asm/page.h> 21#include <asm/page.h>
10#include <asm/cache.h> 22#include <asm/cache.h>
23#include <asm/boot.h>
11 24
12OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") 25OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
13OUTPUT_ARCH(i386) 26OUTPUT_ARCH(i386)
@@ -21,34 +34,35 @@ PHDRS {
21} 34}
22SECTIONS 35SECTIONS
23{ 36{
24 . = __KERNEL_START; 37 . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
25 phys_startup_32 = startup_32 - LOAD_OFFSET; 38 phys_startup_32 = startup_32 - LOAD_OFFSET;
26 /* read-only */ 39 /* read-only */
27 _text = .; /* Text and read-only data */
28 .text : AT(ADDR(.text) - LOAD_OFFSET) { 40 .text : AT(ADDR(.text) - LOAD_OFFSET) {
41 _text = .; /* Text and read-only data */
29 *(.text) 42 *(.text)
30 SCHED_TEXT 43 SCHED_TEXT
31 LOCK_TEXT 44 LOCK_TEXT
32 KPROBES_TEXT 45 KPROBES_TEXT
33 *(.fixup) 46 *(.fixup)
34 *(.gnu.warning) 47 *(.gnu.warning)
35 } :text = 0x9090 48 _etext = .; /* End of text section */
36 49 } :text = 0x9090
37 _etext = .; /* End of text section */
38 50
39 . = ALIGN(16); /* Exception table */ 51 . = ALIGN(16); /* Exception table */
40 __start___ex_table = .; 52 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
41 __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { *(__ex_table) } 53 __start___ex_table = .;
42 __stop___ex_table = .; 54 *(__ex_table)
55 __stop___ex_table = .;
56 }
43 57
44 RODATA 58 RODATA
45 59
46 . = ALIGN(4); 60 . = ALIGN(4);
47 __tracedata_start = .;
48 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) { 61 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
62 __tracedata_start = .;
49 *(.tracedata) 63 *(.tracedata)
64 __tracedata_end = .;
50 } 65 }
51 __tracedata_end = .;
52 66
53 /* writeable */ 67 /* writeable */
54 . = ALIGN(4096); 68 . = ALIGN(4096);
@@ -57,11 +71,19 @@ SECTIONS
57 CONSTRUCTORS 71 CONSTRUCTORS
58 } :data 72 } :data
59 73
74 .paravirtprobe : AT(ADDR(.paravirtprobe) - LOAD_OFFSET) {
75 __start_paravirtprobe = .;
76 *(.paravirtprobe)
77 __stop_paravirtprobe = .;
78 }
79
60 . = ALIGN(4096); 80 . = ALIGN(4096);
61 __nosave_begin = .; 81 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
62 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { *(.data.nosave) } 82 __nosave_begin = .;
63 . = ALIGN(4096); 83 *(.data.nosave)
64 __nosave_end = .; 84 . = ALIGN(4096);
85 __nosave_end = .;
86 }
65 87
66 . = ALIGN(4096); 88 . = ALIGN(4096);
67 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { 89 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
@@ -75,17 +97,10 @@ SECTIONS
75 97
76 /* rarely changed data like cpu maps */ 98 /* rarely changed data like cpu maps */
77 . = ALIGN(32); 99 . = ALIGN(32);
78 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { *(.data.read_mostly) } 100 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
79 _edata = .; /* End of data section */ 101 *(.data.read_mostly)
80 102 _edata = .; /* End of data section */
81#ifdef CONFIG_STACK_UNWIND
82 . = ALIGN(4);
83 .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {
84 __start_unwind = .;
85 *(.eh_frame)
86 __end_unwind = .;
87 } 103 }
88#endif
89 104
90 . = ALIGN(THREAD_SIZE); /* init_task */ 105 . = ALIGN(THREAD_SIZE); /* init_task */
91 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { 106 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
@@ -94,88 +109,102 @@ SECTIONS
94 109
95 /* might get freed after init */ 110 /* might get freed after init */
96 . = ALIGN(4096); 111 . = ALIGN(4096);
97 __smp_alt_begin = .;
98 __smp_alt_instructions = .;
99 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) { 112 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
113 __smp_alt_begin = .;
114 __smp_alt_instructions = .;
100 *(.smp_altinstructions) 115 *(.smp_altinstructions)
116 __smp_alt_instructions_end = .;
101 } 117 }
102 __smp_alt_instructions_end = .;
103 . = ALIGN(4); 118 . = ALIGN(4);
104 __smp_locks = .;
105 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) { 119 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
120 __smp_locks = .;
106 *(.smp_locks) 121 *(.smp_locks)
122 __smp_locks_end = .;
107 } 123 }
108 __smp_locks_end = .;
109 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) { 124 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
110 *(.smp_altinstr_replacement) 125 *(.smp_altinstr_replacement)
126 __smp_alt_end = .;
111 } 127 }
128 /* will be freed after init
129 * Following ALIGN() is required to make sure no other data falls on the
130 * same page where __smp_alt_end is pointing as that page might be freed
131 * after boot. Always make sure that ALIGN() directive is present after
132 * the section which contains __smp_alt_end.
133 */
112 . = ALIGN(4096); 134 . = ALIGN(4096);
113 __smp_alt_end = .;
114 135
115 /* will be freed after init */ 136 /* will be freed after init */
116 . = ALIGN(4096); /* Init code and data */ 137 . = ALIGN(4096); /* Init code and data */
117 __init_begin = .;
118 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { 138 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
139 __init_begin = .;
119 _sinittext = .; 140 _sinittext = .;
120 *(.init.text) 141 *(.init.text)
121 _einittext = .; 142 _einittext = .;
122 } 143 }
123 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) } 144 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) }
124 . = ALIGN(16); 145 . = ALIGN(16);
125 __setup_start = .; 146 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
126 .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) } 147 __setup_start = .;
127 __setup_end = .; 148 *(.init.setup)
128 __initcall_start = .; 149 __setup_end = .;
150 }
129 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { 151 .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
152 __initcall_start = .;
130 INITCALLS 153 INITCALLS
154 __initcall_end = .;
131 } 155 }
132 __initcall_end = .;
133 __con_initcall_start = .;
134 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) { 156 .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
157 __con_initcall_start = .;
135 *(.con_initcall.init) 158 *(.con_initcall.init)
159 __con_initcall_end = .;
136 } 160 }
137 __con_initcall_end = .;
138 SECURITY_INIT 161 SECURITY_INIT
139 . = ALIGN(4); 162 . = ALIGN(4);
140 __alt_instructions = .;
141 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { 163 .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) {
164 __alt_instructions = .;
142 *(.altinstructions) 165 *(.altinstructions)
166 __alt_instructions_end = .;
143 } 167 }
144 __alt_instructions_end = .;
145 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) { 168 .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) {
146 *(.altinstr_replacement) 169 *(.altinstr_replacement)
147 } 170 }
171 . = ALIGN(4);
172 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
173 __start_parainstructions = .;
174 *(.parainstructions)
175 __stop_parainstructions = .;
176 }
148 /* .exit.text is discard at runtime, not link time, to deal with references 177 /* .exit.text is discard at runtime, not link time, to deal with references
149 from .altinstructions and .eh_frame */ 178 from .altinstructions and .eh_frame */
150 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) } 179 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
151 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) } 180 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
152 . = ALIGN(4096); 181 . = ALIGN(4096);
153 __initramfs_start = .; 182 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
154 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) } 183 __initramfs_start = .;
155 __initramfs_end = .; 184 *(.init.ramfs)
185 __initramfs_end = .;
186 }
156 . = ALIGN(L1_CACHE_BYTES); 187 . = ALIGN(L1_CACHE_BYTES);
157 __per_cpu_start = .; 188 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) {
158 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) } 189 __per_cpu_start = .;
159 __per_cpu_end = .; 190 *(.data.percpu)
191 __per_cpu_end = .;
192 }
160 . = ALIGN(4096); 193 . = ALIGN(4096);
161 __init_end = .;
162 /* freed after init ends here */ 194 /* freed after init ends here */
163 195
164 __bss_start = .; /* BSS */
165 .bss.page_aligned : AT(ADDR(.bss.page_aligned) - LOAD_OFFSET) {
166 *(.bss.page_aligned)
167 }
168 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { 196 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
197 __init_end = .;
198 __bss_start = .; /* BSS */
199 *(.bss.page_aligned)
169 *(.bss) 200 *(.bss)
201 . = ALIGN(4);
202 __bss_stop = .;
203 _end = . ;
204 /* This is where the kernel creates the early boot page tables */
205 . = ALIGN(4096);
206 pg0 = . ;
170 } 207 }
171 . = ALIGN(4);
172 __bss_stop = .;
173
174 _end = . ;
175
176 /* This is where the kernel creates the early boot page tables */
177 . = ALIGN(4096);
178 pg0 = .;
179 208
180 /* Sections to be discarded */ 209 /* Sections to be discarded */
181 /DISCARD/ : { 210 /DISCARD/ : {
diff --git a/arch/i386/mach-generic/probe.c b/arch/i386/mach-generic/probe.c
index 94b1fd9cbe3c..a7b3999bb37a 100644
--- a/arch/i386/mach-generic/probe.c
+++ b/arch/i386/mach-generic/probe.c
@@ -45,7 +45,9 @@ static int __init parse_apic(char *arg)
45 return 0; 45 return 0;
46 } 46 }
47 } 47 }
48 return -ENOENT; 48
49 /* Parsed again by __setup for debug/verbose */
50 return 0;
49} 51}
50early_param("apic", parse_apic); 52early_param("apic", parse_apic);
51 53
diff --git a/arch/i386/mach-voyager/voyager_cat.c b/arch/i386/mach-voyager/voyager_cat.c
index f50c6c6ad680..943a9473b138 100644
--- a/arch/i386/mach-voyager/voyager_cat.c
+++ b/arch/i386/mach-voyager/voyager_cat.c
@@ -776,7 +776,7 @@ voyager_cat_init(void)
776 for(asic=0; asic < (*modpp)->num_asics; asic++) { 776 for(asic=0; asic < (*modpp)->num_asics; asic++) {
777 int j; 777 int j;
778 voyager_asic_t *asicp = *asicpp 778 voyager_asic_t *asicp = *asicpp
779 = kmalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count++];*/ 779 = kzalloc(sizeof(voyager_asic_t), GFP_KERNEL); /*&voyager_asic_storage[asic_count++];*/
780 voyager_sp_table_t *sp_table; 780 voyager_sp_table_t *sp_table;
781 voyager_at_t *asic_table; 781 voyager_at_t *asic_table;
782 voyager_jtt_t *jtag_table; 782 voyager_jtt_t *jtag_table;
@@ -785,7 +785,6 @@ voyager_cat_init(void)
785 printk("**WARNING** kmalloc failure in cat_init\n"); 785 printk("**WARNING** kmalloc failure in cat_init\n");
786 continue; 786 continue;
787 } 787 }
788 memset(asicp, 0, sizeof(voyager_asic_t));
789 asicpp = &(asicp->next); 788 asicpp = &(asicp->next);
790 asicp->asic_location = asic; 789 asicp->asic_location = asic;
791 sp_table = (voyager_sp_table_t *)(eprom_buf + sp_offset); 790 sp_table = (voyager_sp_table_t *)(eprom_buf + sp_offset);
@@ -851,8 +850,7 @@ voyager_cat_init(void)
851#endif 850#endif
852 851
853 { 852 {
854 struct resource *res = kmalloc(sizeof(struct resource),GFP_KERNEL); 853 struct resource *res = kzalloc(sizeof(struct resource),GFP_KERNEL);
855 memset(res, 0, sizeof(struct resource));
856 res->name = kmalloc(128, GFP_KERNEL); 854 res->name = kmalloc(128, GFP_KERNEL);
857 sprintf((char *)res->name, "Voyager %s Quad CPI", cat_module_name(i)); 855 sprintf((char *)res->name, "Voyager %s Quad CPI", cat_module_name(i));
858 res->start = qic_addr; 856 res->start = qic_addr;
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index f3fea2ad50fe..55428e656a3f 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -28,6 +28,7 @@
28#include <asm/pgalloc.h> 28#include <asm/pgalloc.h>
29#include <asm/tlbflush.h> 29#include <asm/tlbflush.h>
30#include <asm/arch_hooks.h> 30#include <asm/arch_hooks.h>
31#include <asm/pda.h>
31 32
32/* TLB state -- visible externally, indexed physically */ 33/* TLB state -- visible externally, indexed physically */
33DEFINE_PER_CPU(struct tlb_state, cpu_tlbstate) ____cacheline_aligned = { &init_mm, 0 }; 34DEFINE_PER_CPU(struct tlb_state, cpu_tlbstate) ____cacheline_aligned = { &init_mm, 0 };
@@ -422,6 +423,7 @@ find_smp_config(void)
422 VOYAGER_SUS_IN_CONTROL_PORT); 423 VOYAGER_SUS_IN_CONTROL_PORT);
423 424
424 current_thread_info()->cpu = boot_cpu_id; 425 current_thread_info()->cpu = boot_cpu_id;
426 write_pda(cpu_number, boot_cpu_id);
425} 427}
426 428
427/* 429/*
@@ -458,7 +460,7 @@ start_secondary(void *unused)
458 /* external functions not defined in the headers */ 460 /* external functions not defined in the headers */
459 extern void calibrate_delay(void); 461 extern void calibrate_delay(void);
460 462
461 cpu_init(); 463 secondary_cpu_init();
462 464
463 /* OK, we're in the routine */ 465 /* OK, we're in the routine */
464 ack_CPI(VIC_CPU_BOOT_CPI); 466 ack_CPI(VIC_CPU_BOOT_CPI);
@@ -578,6 +580,15 @@ do_boot_cpu(__u8 cpu)
578 /* init_tasks (in sched.c) is indexed logically */ 580 /* init_tasks (in sched.c) is indexed logically */
579 stack_start.esp = (void *) idle->thread.esp; 581 stack_start.esp = (void *) idle->thread.esp;
580 582
583 /* Pre-allocate and initialize the CPU's GDT and PDA so it
584 doesn't have to do any memory allocation during the
585 delicate CPU-bringup phase. */
586 if (!init_gdt(cpu, idle)) {
587 printk(KERN_INFO "Couldn't allocate GDT/PDA for CPU %d\n", cpu);
588 cpucount--;
589 return;
590 }
591
581 irq_ctx_init(cpu); 592 irq_ctx_init(cpu);
582 593
583 /* Note: Don't modify initial ss override */ 594 /* Note: Don't modify initial ss override */
@@ -1963,4 +1974,5 @@ void __init
1963smp_setup_processor_id(void) 1974smp_setup_processor_id(void)
1964{ 1975{
1965 current_thread_info()->cpu = hard_smp_processor_id(); 1976 current_thread_info()->cpu = hard_smp_processor_id();
1977 write_pda(cpu_number, hard_smp_processor_id());
1966} 1978}
diff --git a/arch/i386/math-emu/fpu_emu.h b/arch/i386/math-emu/fpu_emu.h
index d62b20a3e660..65120f523853 100644
--- a/arch/i386/math-emu/fpu_emu.h
+++ b/arch/i386/math-emu/fpu_emu.h
@@ -57,6 +57,7 @@
57#define TAG_Special Const(2) /* De-normal, + or - infinity, 57#define TAG_Special Const(2) /* De-normal, + or - infinity,
58 or Not a Number */ 58 or Not a Number */
59#define TAG_Empty Const(3) /* empty */ 59#define TAG_Empty Const(3) /* empty */
60#define TAG_Error Const(0x80) /* probably need to abort */
60 61
61#define LOADED_DATA Const(10101) /* Special st() number to identify 62#define LOADED_DATA Const(10101) /* Special st() number to identify
62 loaded data (not on stack). */ 63 loaded data (not on stack). */
diff --git a/arch/i386/math-emu/fpu_entry.c b/arch/i386/math-emu/fpu_entry.c
index d93f16ef828f..ddf8fa3bbd01 100644
--- a/arch/i386/math-emu/fpu_entry.c
+++ b/arch/i386/math-emu/fpu_entry.c
@@ -742,7 +742,8 @@ int save_i387_soft(void *s387, struct _fpstate __user * buf)
742 S387->fcs &= ~0xf8000000; 742 S387->fcs &= ~0xf8000000;
743 S387->fos |= 0xffff0000; 743 S387->fos |= 0xffff0000;
744#endif /* PECULIAR_486 */ 744#endif /* PECULIAR_486 */
745 __copy_to_user(d, &S387->cwd, 7*4); 745 if (__copy_to_user(d, &S387->cwd, 7*4))
746 return -1;
746 RE_ENTRANT_CHECK_ON; 747 RE_ENTRANT_CHECK_ON;
747 748
748 d += 7*4; 749 d += 7*4;
diff --git a/arch/i386/math-emu/fpu_system.h b/arch/i386/math-emu/fpu_system.h
index bf26341c8bde..a3ae28c49ddd 100644
--- a/arch/i386/math-emu/fpu_system.h
+++ b/arch/i386/math-emu/fpu_system.h
@@ -68,6 +68,7 @@
68 68
69#define FPU_access_ok(x,y,z) if ( !access_ok(x,y,z) ) \ 69#define FPU_access_ok(x,y,z) if ( !access_ok(x,y,z) ) \
70 math_abort(FPU_info,SIGSEGV) 70 math_abort(FPU_info,SIGSEGV)
71#define FPU_abort math_abort(FPU_info, SIGSEGV)
71 72
72#undef FPU_IGNORE_CODE_SEGV 73#undef FPU_IGNORE_CODE_SEGV
73#ifdef FPU_IGNORE_CODE_SEGV 74#ifdef FPU_IGNORE_CODE_SEGV
diff --git a/arch/i386/math-emu/load_store.c b/arch/i386/math-emu/load_store.c
index 85314be2fef8..eebd6fb1c8a8 100644
--- a/arch/i386/math-emu/load_store.c
+++ b/arch/i386/math-emu/load_store.c
@@ -227,6 +227,8 @@ int FPU_load_store(u_char type, fpu_addr_modes addr_modes,
227 case 027: /* fild m64int */ 227 case 027: /* fild m64int */
228 clear_C1(); 228 clear_C1();
229 loaded_tag = FPU_load_int64((long long __user *)data_address); 229 loaded_tag = FPU_load_int64((long long __user *)data_address);
230 if (loaded_tag == TAG_Error)
231 return 0;
230 FPU_settag0(loaded_tag); 232 FPU_settag0(loaded_tag);
231 break; 233 break;
232 case 030: /* fstenv m14/28byte */ 234 case 030: /* fstenv m14/28byte */
diff --git a/arch/i386/math-emu/reg_ld_str.c b/arch/i386/math-emu/reg_ld_str.c
index f06ed41d191d..e976caef6498 100644
--- a/arch/i386/math-emu/reg_ld_str.c
+++ b/arch/i386/math-emu/reg_ld_str.c
@@ -244,7 +244,8 @@ int FPU_load_int64(long long __user *_s)
244 244
245 RE_ENTRANT_CHECK_OFF; 245 RE_ENTRANT_CHECK_OFF;
246 FPU_access_ok(VERIFY_READ, _s, 8); 246 FPU_access_ok(VERIFY_READ, _s, 8);
247 copy_from_user(&s,_s,8); 247 if (copy_from_user(&s,_s,8))
248 FPU_abort;
248 RE_ENTRANT_CHECK_ON; 249 RE_ENTRANT_CHECK_ON;
249 250
250 if (s == 0) 251 if (s == 0)
@@ -907,7 +908,8 @@ int FPU_store_int64(FPU_REG *st0_ptr, u_char st0_tag, long long __user *d)
907 908
908 RE_ENTRANT_CHECK_OFF; 909 RE_ENTRANT_CHECK_OFF;
909 FPU_access_ok(VERIFY_WRITE,d,8); 910 FPU_access_ok(VERIFY_WRITE,d,8);
910 copy_to_user(d, &tll, 8); 911 if (copy_to_user(d, &tll, 8))
912 FPU_abort;
911 RE_ENTRANT_CHECK_ON; 913 RE_ENTRANT_CHECK_ON;
912 914
913 return 1; 915 return 1;
@@ -1336,7 +1338,8 @@ u_char __user *fstenv(fpu_addr_modes addr_modes, u_char __user *d)
1336 I387.soft.fcs &= ~0xf8000000; 1338 I387.soft.fcs &= ~0xf8000000;
1337 I387.soft.fos |= 0xffff0000; 1339 I387.soft.fos |= 0xffff0000;
1338#endif /* PECULIAR_486 */ 1340#endif /* PECULIAR_486 */
1339 __copy_to_user(d, &control_word, 7*4); 1341 if (__copy_to_user(d, &control_word, 7*4))
1342 FPU_abort;
1340 RE_ENTRANT_CHECK_ON; 1343 RE_ENTRANT_CHECK_ON;
1341 d += 0x1c; 1344 d += 0x1c;
1342 } 1345 }
@@ -1359,9 +1362,11 @@ void fsave(fpu_addr_modes addr_modes, u_char __user *data_address)
1359 FPU_access_ok(VERIFY_WRITE,d,80); 1362 FPU_access_ok(VERIFY_WRITE,d,80);
1360 1363
1361 /* Copy all registers in stack order. */ 1364 /* Copy all registers in stack order. */
1362 __copy_to_user(d, register_base+offset, other); 1365 if (__copy_to_user(d, register_base+offset, other))
1366 FPU_abort;
1363 if ( offset ) 1367 if ( offset )
1364 __copy_to_user(d+other, register_base, offset); 1368 if (__copy_to_user(d+other, register_base, offset))
1369 FPU_abort;
1365 RE_ENTRANT_CHECK_ON; 1370 RE_ENTRANT_CHECK_ON;
1366 1371
1367 finit(); 1372 finit();
diff --git a/arch/i386/mm/boot_ioremap.c b/arch/i386/mm/boot_ioremap.c
index 4de11f508c3a..4de95a17a7d4 100644
--- a/arch/i386/mm/boot_ioremap.c
+++ b/arch/i386/mm/boot_ioremap.c
@@ -16,6 +16,7 @@
16 */ 16 */
17 17
18#undef CONFIG_X86_PAE 18#undef CONFIG_X86_PAE
19#undef CONFIG_PARAVIRT
19#include <asm/page.h> 20#include <asm/page.h>
20#include <asm/pgtable.h> 21#include <asm/pgtable.h>
21#include <asm/tlbflush.h> 22#include <asm/tlbflush.h>
diff --git a/arch/i386/mm/discontig.c b/arch/i386/mm/discontig.c
index ddbdb0336f28..103b76e56a94 100644
--- a/arch/i386/mm/discontig.c
+++ b/arch/i386/mm/discontig.c
@@ -168,7 +168,7 @@ static void __init allocate_pgdat(int nid)
168 if (nid && node_has_online_mem(nid)) 168 if (nid && node_has_online_mem(nid))
169 NODE_DATA(nid) = (pg_data_t *)node_remap_start_vaddr[nid]; 169 NODE_DATA(nid) = (pg_data_t *)node_remap_start_vaddr[nid];
170 else { 170 else {
171 NODE_DATA(nid) = (pg_data_t *)(__va(min_low_pfn << PAGE_SHIFT)); 171 NODE_DATA(nid) = (pg_data_t *)(pfn_to_kaddr(min_low_pfn));
172 min_low_pfn += PFN_UP(sizeof(pg_data_t)); 172 min_low_pfn += PFN_UP(sizeof(pg_data_t));
173 } 173 }
174} 174}
diff --git a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c
index 2581575786c1..aaaa4d225f7e 100644
--- a/arch/i386/mm/fault.c
+++ b/arch/i386/mm/fault.c
@@ -22,9 +22,9 @@
22#include <linux/highmem.h> 22#include <linux/highmem.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kprobes.h> 24#include <linux/kprobes.h>
25#include <linux/uaccess.h>
25 26
26#include <asm/system.h> 27#include <asm/system.h>
27#include <asm/uaccess.h>
28#include <asm/desc.h> 28#include <asm/desc.h>
29#include <asm/kdebug.h> 29#include <asm/kdebug.h>
30#include <asm/segment.h> 30#include <asm/segment.h>
@@ -167,7 +167,7 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
167static int __is_prefetch(struct pt_regs *regs, unsigned long addr) 167static int __is_prefetch(struct pt_regs *regs, unsigned long addr)
168{ 168{
169 unsigned long limit; 169 unsigned long limit;
170 unsigned long instr = get_segment_eip (regs, &limit); 170 unsigned char *instr = (unsigned char *)get_segment_eip (regs, &limit);
171 int scan_more = 1; 171 int scan_more = 1;
172 int prefetch = 0; 172 int prefetch = 0;
173 int i; 173 int i;
@@ -177,9 +177,9 @@ static int __is_prefetch(struct pt_regs *regs, unsigned long addr)
177 unsigned char instr_hi; 177 unsigned char instr_hi;
178 unsigned char instr_lo; 178 unsigned char instr_lo;
179 179
180 if (instr > limit) 180 if (instr > (unsigned char *)limit)
181 break; 181 break;
182 if (__get_user(opcode, (unsigned char __user *) instr)) 182 if (probe_kernel_address(instr, opcode))
183 break; 183 break;
184 184
185 instr_hi = opcode & 0xf0; 185 instr_hi = opcode & 0xf0;
@@ -204,9 +204,9 @@ static int __is_prefetch(struct pt_regs *regs, unsigned long addr)
204 case 0x00: 204 case 0x00:
205 /* Prefetch instruction is 0x0F0D or 0x0F18 */ 205 /* Prefetch instruction is 0x0F0D or 0x0F18 */
206 scan_more = 0; 206 scan_more = 0;
207 if (instr > limit) 207 if (instr > (unsigned char *)limit)
208 break; 208 break;
209 if (__get_user(opcode, (unsigned char __user *) instr)) 209 if (probe_kernel_address(instr, opcode))
210 break; 210 break;
211 prefetch = (instr_lo == 0xF) && 211 prefetch = (instr_lo == 0xF) &&
212 (opcode == 0x0D || opcode == 0x18); 212 (opcode == 0x0D || opcode == 0x18);
diff --git a/arch/i386/mm/highmem.c b/arch/i386/mm/highmem.c
index f9f647cdbc7b..e0fa6cb655a8 100644
--- a/arch/i386/mm/highmem.c
+++ b/arch/i386/mm/highmem.c
@@ -32,7 +32,7 @@ void *kmap_atomic(struct page *page, enum km_type type)
32 unsigned long vaddr; 32 unsigned long vaddr;
33 33
34 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 34 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
35 inc_preempt_count(); 35 pagefault_disable();
36 if (!PageHighMem(page)) 36 if (!PageHighMem(page))
37 return page_address(page); 37 return page_address(page);
38 38
@@ -50,26 +50,22 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
50 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 50 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
51 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); 51 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
52 52
53#ifdef CONFIG_DEBUG_HIGHMEM
54 if (vaddr >= PAGE_OFFSET && vaddr < (unsigned long)high_memory) {
55 dec_preempt_count();
56 preempt_check_resched();
57 return;
58 }
59
60 if (vaddr != __fix_to_virt(FIX_KMAP_BEGIN+idx))
61 BUG();
62#endif
63 /* 53 /*
64 * Force other mappings to Oops if they'll try to access this pte 54 * Force other mappings to Oops if they'll try to access this pte
65 * without first remap it. Keeping stale mappings around is a bad idea 55 * without first remap it. Keeping stale mappings around is a bad idea
66 * also, in case the page changes cacheability attributes or becomes 56 * also, in case the page changes cacheability attributes or becomes
67 * a protected page in a hypervisor. 57 * a protected page in a hypervisor.
68 */ 58 */
69 kpte_clear_flush(kmap_pte-idx, vaddr); 59 if (vaddr == __fix_to_virt(FIX_KMAP_BEGIN+idx))
60 kpte_clear_flush(kmap_pte-idx, vaddr);
61 else {
62#ifdef CONFIG_DEBUG_HIGHMEM
63 BUG_ON(vaddr < PAGE_OFFSET);
64 BUG_ON(vaddr >= (unsigned long)high_memory);
65#endif
66 }
70 67
71 dec_preempt_count(); 68 pagefault_enable();
72 preempt_check_resched();
73} 69}
74 70
75/* This is the same as kmap_atomic() but can map memory that doesn't 71/* This is the same as kmap_atomic() but can map memory that doesn't
@@ -80,7 +76,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
80 enum fixed_addresses idx; 76 enum fixed_addresses idx;
81 unsigned long vaddr; 77 unsigned long vaddr;
82 78
83 inc_preempt_count(); 79 pagefault_disable();
84 80
85 idx = type + KM_TYPE_NR*smp_processor_id(); 81 idx = type + KM_TYPE_NR*smp_processor_id();
86 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 82 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
diff --git a/arch/i386/mm/hugetlbpage.c b/arch/i386/mm/hugetlbpage.c
index 1719a8141f81..34728e4afe48 100644
--- a/arch/i386/mm/hugetlbpage.c
+++ b/arch/i386/mm/hugetlbpage.c
@@ -17,6 +17,113 @@
17#include <asm/tlb.h> 17#include <asm/tlb.h>
18#include <asm/tlbflush.h> 18#include <asm/tlbflush.h>
19 19
20static unsigned long page_table_shareable(struct vm_area_struct *svma,
21 struct vm_area_struct *vma,
22 unsigned long addr, pgoff_t idx)
23{
24 unsigned long saddr = ((idx - svma->vm_pgoff) << PAGE_SHIFT) +
25 svma->vm_start;
26 unsigned long sbase = saddr & PUD_MASK;
27 unsigned long s_end = sbase + PUD_SIZE;
28
29 /*
30 * match the virtual addresses, permission and the alignment of the
31 * page table page.
32 */
33 if (pmd_index(addr) != pmd_index(saddr) ||
34 vma->vm_flags != svma->vm_flags ||
35 sbase < svma->vm_start || svma->vm_end < s_end)
36 return 0;
37
38 return saddr;
39}
40
41static int vma_shareable(struct vm_area_struct *vma, unsigned long addr)
42{
43 unsigned long base = addr & PUD_MASK;
44 unsigned long end = base + PUD_SIZE;
45
46 /*
47 * check on proper vm_flags and page table alignment
48 */
49 if (vma->vm_flags & VM_MAYSHARE &&
50 vma->vm_start <= base && end <= vma->vm_end)
51 return 1;
52 return 0;
53}
54
55/*
56 * search for a shareable pmd page for hugetlb.
57 */
58static void huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud)
59{
60 struct vm_area_struct *vma = find_vma(mm, addr);
61 struct address_space *mapping = vma->vm_file->f_mapping;
62 pgoff_t idx = ((addr - vma->vm_start) >> PAGE_SHIFT) +
63 vma->vm_pgoff;
64 struct prio_tree_iter iter;
65 struct vm_area_struct *svma;
66 unsigned long saddr;
67 pte_t *spte = NULL;
68
69 if (!vma_shareable(vma, addr))
70 return;
71
72 spin_lock(&mapping->i_mmap_lock);
73 vma_prio_tree_foreach(svma, &iter, &mapping->i_mmap, idx, idx) {
74 if (svma == vma)
75 continue;
76
77 saddr = page_table_shareable(svma, vma, addr, idx);
78 if (saddr) {
79 spte = huge_pte_offset(svma->vm_mm, saddr);
80 if (spte) {
81 get_page(virt_to_page(spte));
82 break;
83 }
84 }
85 }
86
87 if (!spte)
88 goto out;
89
90 spin_lock(&mm->page_table_lock);
91 if (pud_none(*pud))
92 pud_populate(mm, pud, (unsigned long) spte & PAGE_MASK);
93 else
94 put_page(virt_to_page(spte));
95 spin_unlock(&mm->page_table_lock);
96out:
97 spin_unlock(&mapping->i_mmap_lock);
98}
99
100/*
101 * unmap huge page backed by shared pte.
102 *
103 * Hugetlb pte page is ref counted at the time of mapping. If pte is shared
104 * indicated by page_count > 1, unmap is achieved by clearing pud and
105 * decrementing the ref count. If count == 1, the pte page is not shared.
106 *
107 * called with vma->vm_mm->page_table_lock held.
108 *
109 * returns: 1 successfully unmapped a shared pte page
110 * 0 the underlying pte page is not shared, or it is the last user
111 */
112int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
113{
114 pgd_t *pgd = pgd_offset(mm, *addr);
115 pud_t *pud = pud_offset(pgd, *addr);
116
117 BUG_ON(page_count(virt_to_page(ptep)) == 0);
118 if (page_count(virt_to_page(ptep)) == 1)
119 return 0;
120
121 pud_clear(pud);
122 put_page(virt_to_page(ptep));
123 *addr = ALIGN(*addr, HPAGE_SIZE * PTRS_PER_PTE) - HPAGE_SIZE;
124 return 1;
125}
126
20pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 127pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
21{ 128{
22 pgd_t *pgd; 129 pgd_t *pgd;
@@ -25,8 +132,11 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
25 132
26 pgd = pgd_offset(mm, addr); 133 pgd = pgd_offset(mm, addr);
27 pud = pud_alloc(mm, pgd, addr); 134 pud = pud_alloc(mm, pgd, addr);
28 if (pud) 135 if (pud) {
136 if (pud_none(*pud))
137 huge_pmd_share(mm, addr, pud);
29 pte = (pte_t *) pmd_alloc(mm, pud, addr); 138 pte = (pte_t *) pmd_alloc(mm, pud, addr);
139 }
30 BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte)); 140 BUG_ON(pte && !pte_none(*pte) && !pte_huge(*pte));
31 141
32 return pte; 142 return pte;
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index 167416155ee4..84697dfc7348 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -192,8 +192,6 @@ static inline int page_kills_ppro(unsigned long pagenr)
192 return 0; 192 return 0;
193} 193}
194 194
195extern int is_available_memory(efi_memory_desc_t *);
196
197int page_is_ram(unsigned long pagenr) 195int page_is_ram(unsigned long pagenr)
198{ 196{
199 int i; 197 int i;
@@ -699,8 +697,8 @@ int remove_memory(u64 start, u64 size)
699#endif 697#endif
700#endif 698#endif
701 699
702kmem_cache_t *pgd_cache; 700struct kmem_cache *pgd_cache;
703kmem_cache_t *pmd_cache; 701struct kmem_cache *pmd_cache;
704 702
705void __init pgtable_cache_init(void) 703void __init pgtable_cache_init(void)
706{ 704{
diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c
index 8564b6ae17e3..ad91528bdc14 100644
--- a/arch/i386/mm/pageattr.c
+++ b/arch/i386/mm/pageattr.c
@@ -67,11 +67,17 @@ static struct page *split_large_page(unsigned long address, pgprot_t prot,
67 return base; 67 return base;
68} 68}
69 69
70static void flush_kernel_map(void *dummy) 70static void flush_kernel_map(void *arg)
71{ 71{
72 /* Could use CLFLUSH here if the CPU supports it (Hammer,P4) */ 72 unsigned long adr = (unsigned long)arg;
73 if (boot_cpu_data.x86_model >= 4) 73
74 if (adr && cpu_has_clflush) {
75 int i;
76 for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
77 asm volatile("clflush (%0)" :: "r" (adr + i));
78 } else if (boot_cpu_data.x86_model >= 4)
74 wbinvd(); 79 wbinvd();
80
75 /* Flush all to work around Errata in early athlons regarding 81 /* Flush all to work around Errata in early athlons regarding
76 * large page flushing. 82 * large page flushing.
77 */ 83 */
@@ -173,9 +179,9 @@ __change_page_attr(struct page *page, pgprot_t prot)
173 return 0; 179 return 0;
174} 180}
175 181
176static inline void flush_map(void) 182static inline void flush_map(void *adr)
177{ 183{
178 on_each_cpu(flush_kernel_map, NULL, 1, 1); 184 on_each_cpu(flush_kernel_map, adr, 1, 1);
179} 185}
180 186
181/* 187/*
@@ -217,9 +223,13 @@ void global_flush_tlb(void)
217 spin_lock_irq(&cpa_lock); 223 spin_lock_irq(&cpa_lock);
218 list_replace_init(&df_list, &l); 224 list_replace_init(&df_list, &l);
219 spin_unlock_irq(&cpa_lock); 225 spin_unlock_irq(&cpa_lock);
220 flush_map(); 226 if (!cpu_has_clflush)
221 list_for_each_entry_safe(pg, next, &l, lru) 227 flush_map(0);
228 list_for_each_entry_safe(pg, next, &l, lru) {
229 if (cpu_has_clflush)
230 flush_map(page_address(pg));
222 __free_page(pg); 231 __free_page(pg);
232 }
223} 233}
224 234
225#ifdef CONFIG_DEBUG_PAGEALLOC 235#ifdef CONFIG_DEBUG_PAGEALLOC
diff --git a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c
index 10126e3f8174..f349eaf450b0 100644
--- a/arch/i386/mm/pgtable.c
+++ b/arch/i386/mm/pgtable.c
@@ -95,8 +95,11 @@ static void set_pte_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
95 return; 95 return;
96 } 96 }
97 pte = pte_offset_kernel(pmd, vaddr); 97 pte = pte_offset_kernel(pmd, vaddr);
98 /* <pfn,flags> stored as-is, to permit clearing entries */ 98 if (pgprot_val(flags))
99 set_pte(pte, pfn_pte(pfn, flags)); 99 /* <pfn,flags> stored as-is, to permit clearing entries */
100 set_pte(pte, pfn_pte(pfn, flags));
101 else
102 pte_clear(&init_mm, vaddr, pte);
100 103
101 /* 104 /*
102 * It's enough to flush this one mapping. 105 * It's enough to flush this one mapping.
@@ -193,7 +196,7 @@ struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
193 return pte; 196 return pte;
194} 197}
195 198
196void pmd_ctor(void *pmd, kmem_cache_t *cache, unsigned long flags) 199void pmd_ctor(void *pmd, struct kmem_cache *cache, unsigned long flags)
197{ 200{
198 memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t)); 201 memset(pmd, 0, PTRS_PER_PMD*sizeof(pmd_t));
199} 202}
@@ -233,7 +236,7 @@ static inline void pgd_list_del(pgd_t *pgd)
233 set_page_private(next, (unsigned long)pprev); 236 set_page_private(next, (unsigned long)pprev);
234} 237}
235 238
236void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused) 239void pgd_ctor(void *pgd, struct kmem_cache *cache, unsigned long unused)
237{ 240{
238 unsigned long flags; 241 unsigned long flags;
239 242
@@ -253,7 +256,7 @@ void pgd_ctor(void *pgd, kmem_cache_t *cache, unsigned long unused)
253} 256}
254 257
255/* never called when PTRS_PER_PMD > 1 */ 258/* never called when PTRS_PER_PMD > 1 */
256void pgd_dtor(void *pgd, kmem_cache_t *cache, unsigned long unused) 259void pgd_dtor(void *pgd, struct kmem_cache *cache, unsigned long unused)
257{ 260{
258 unsigned long flags; /* can be called from interrupt context */ 261 unsigned long flags; /* can be called from interrupt context */
259 262
diff --git a/arch/i386/pci/early.c b/arch/i386/pci/early.c
index 713d6c866cae..42df4b6606df 100644
--- a/arch/i386/pci/early.c
+++ b/arch/i386/pci/early.c
@@ -45,6 +45,13 @@ void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset,
45 outl(val, 0xcfc); 45 outl(val, 0xcfc);
46} 46}
47 47
48void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val)
49{
50 PDprintk("%x writing to %x: %x\n", slot, offset, val);
51 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
52 outb(val, 0xcfc);
53}
54
48int early_pci_allowed(void) 55int early_pci_allowed(void)
49{ 56{
50 return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) == 57 return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) ==
diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c
index e65551cd8216..f2cb942f8281 100644
--- a/arch/i386/pci/irq.c
+++ b/arch/i386/pci/irq.c
@@ -764,7 +764,7 @@ static void __init pirq_find_router(struct irq_router *r)
764 DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for %04x:%04x\n", 764 DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for %04x:%04x\n",
765 rt->rtr_vendor, rt->rtr_device); 765 rt->rtr_vendor, rt->rtr_device);
766 766
767 pirq_router_dev = pci_find_slot(rt->rtr_bus, rt->rtr_devfn); 767 pirq_router_dev = pci_get_bus_and_slot(rt->rtr_bus, rt->rtr_devfn);
768 if (!pirq_router_dev) { 768 if (!pirq_router_dev) {
769 DBG(KERN_DEBUG "PCI: Interrupt router not found at " 769 DBG(KERN_DEBUG "PCI: Interrupt router not found at "
770 "%02x:%02x\n", rt->rtr_bus, rt->rtr_devfn); 770 "%02x:%02x\n", rt->rtr_bus, rt->rtr_devfn);
@@ -784,6 +784,8 @@ static void __init pirq_find_router(struct irq_router *r)
784 pirq_router_dev->vendor, 784 pirq_router_dev->vendor,
785 pirq_router_dev->device, 785 pirq_router_dev->device,
786 pci_name(pirq_router_dev)); 786 pci_name(pirq_router_dev));
787
788 /* The device remains referenced for the kernel lifetime */
787} 789}
788 790
789static struct irq_info *pirq_get_info(struct pci_dev *dev) 791static struct irq_info *pirq_get_info(struct pci_dev *dev)
diff --git a/arch/i386/pci/pcbios.c b/arch/i386/pci/pcbios.c
index ed1512a175ab..5f5193401bea 100644
--- a/arch/i386/pci/pcbios.c
+++ b/arch/i386/pci/pcbios.c
@@ -5,6 +5,7 @@
5#include <linux/pci.h> 5#include <linux/pci.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/uaccess.h>
8#include "pci.h" 9#include "pci.h"
9#include "pci-functions.h" 10#include "pci-functions.h"
10 11
@@ -314,6 +315,10 @@ static struct pci_raw_ops * __devinit pci_find_bios(void)
314 for (check = (union bios32 *) __va(0xe0000); 315 for (check = (union bios32 *) __va(0xe0000);
315 check <= (union bios32 *) __va(0xffff0); 316 check <= (union bios32 *) __va(0xffff0);
316 ++check) { 317 ++check) {
318 long sig;
319 if (probe_kernel_address(&check->fields.signature, sig))
320 continue;
321
317 if (check->fields.signature != BIOS32_SIGNATURE) 322 if (check->fields.signature != BIOS32_SIGNATURE)
318 continue; 323 continue;
319 length = check->fields.length * 16; 324 length = check->fields.length * 16;
@@ -331,11 +336,13 @@ static struct pci_raw_ops * __devinit pci_find_bios(void)
331 } 336 }
332 DBG("PCI: BIOS32 Service Directory structure at 0x%p\n", check); 337 DBG("PCI: BIOS32 Service Directory structure at 0x%p\n", check);
333 if (check->fields.entry >= 0x100000) { 338 if (check->fields.entry >= 0x100000) {
334 printk("PCI: BIOS32 entry (0x%p) in high memory, cannot use.\n", check); 339 printk("PCI: BIOS32 entry (0x%p) in high memory, "
340 "cannot use.\n", check);
335 return NULL; 341 return NULL;
336 } else { 342 } else {
337 unsigned long bios32_entry = check->fields.entry; 343 unsigned long bios32_entry = check->fields.entry;
338 DBG("PCI: BIOS32 Service Directory entry at 0x%lx\n", bios32_entry); 344 DBG("PCI: BIOS32 Service Directory entry at 0x%lx\n",
345 bios32_entry);
339 bios32_indirect.address = bios32_entry + PAGE_OFFSET; 346 bios32_indirect.address = bios32_entry + PAGE_OFFSET;
340 if (check_pcibios()) 347 if (check_pcibios())
341 return &pci_bios_access; 348 return &pci_bios_access;
diff --git a/arch/i386/power/Makefile b/arch/i386/power/Makefile
index 8cfa4e8a719d..2de7bbf03cd7 100644
--- a/arch/i386/power/Makefile
+++ b/arch/i386/power/Makefile
@@ -1,2 +1,2 @@
1obj-$(CONFIG_PM) += cpu.o 1obj-$(CONFIG_PM) += cpu.o
2obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o 2obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o suspend.o
diff --git a/arch/i386/power/cpu.c b/arch/i386/power/cpu.c
index 5a1abeff033b..2c15500f8713 100644
--- a/arch/i386/power/cpu.c
+++ b/arch/i386/power/cpu.c
@@ -26,8 +26,8 @@ void __save_processor_state(struct saved_context *ctxt)
26 /* 26 /*
27 * descriptor tables 27 * descriptor tables
28 */ 28 */
29 store_gdt(&ctxt->gdt_limit); 29 store_gdt(&ctxt->gdt);
30 store_idt(&ctxt->idt_limit); 30 store_idt(&ctxt->idt);
31 store_tr(ctxt->tr); 31 store_tr(ctxt->tr);
32 32
33 /* 33 /*
@@ -99,8 +99,8 @@ void __restore_processor_state(struct saved_context *ctxt)
99 * now restore the descriptor tables to their proper values 99 * now restore the descriptor tables to their proper values
100 * ltr is done i fix_processor_context(). 100 * ltr is done i fix_processor_context().
101 */ 101 */
102 load_gdt(&ctxt->gdt_limit); 102 load_gdt(&ctxt->gdt);
103 load_idt(&ctxt->idt_limit); 103 load_idt(&ctxt->idt);
104 104
105 /* 105 /*
106 * segment registers 106 * segment registers
diff --git a/arch/i386/power/suspend.c b/arch/i386/power/suspend.c
new file mode 100644
index 000000000000..db5e98d2eb73
--- /dev/null
+++ b/arch/i386/power/suspend.c
@@ -0,0 +1,158 @@
1/*
2 * Suspend support specific for i386 - temporary page tables
3 *
4 * Distribute under GPLv2
5 *
6 * Copyright (c) 2006 Rafael J. Wysocki <rjw@sisk.pl>
7 */
8
9#include <linux/suspend.h>
10#include <linux/bootmem.h>
11
12#include <asm/system.h>
13#include <asm/page.h>
14#include <asm/pgtable.h>
15
16/* Defined in arch/i386/power/swsusp.S */
17extern int restore_image(void);
18
19/* Pointer to the temporary resume page tables */
20pgd_t *resume_pg_dir;
21
22/* The following three functions are based on the analogous code in
23 * arch/i386/mm/init.c
24 */
25
26/*
27 * Create a middle page table on a resume-safe page and put a pointer to it in
28 * the given global directory entry. This only returns the gd entry
29 * in non-PAE compilation mode, since the middle layer is folded.
30 */
31static pmd_t *resume_one_md_table_init(pgd_t *pgd)
32{
33 pud_t *pud;
34 pmd_t *pmd_table;
35
36#ifdef CONFIG_X86_PAE
37 pmd_table = (pmd_t *)get_safe_page(GFP_ATOMIC);
38 if (!pmd_table)
39 return NULL;
40
41 set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
42 pud = pud_offset(pgd, 0);
43
44 BUG_ON(pmd_table != pmd_offset(pud, 0));
45#else
46 pud = pud_offset(pgd, 0);
47 pmd_table = pmd_offset(pud, 0);
48#endif
49
50 return pmd_table;
51}
52
53/*
54 * Create a page table on a resume-safe page and place a pointer to it in
55 * a middle page directory entry.
56 */
57static pte_t *resume_one_page_table_init(pmd_t *pmd)
58{
59 if (pmd_none(*pmd)) {
60 pte_t *page_table = (pte_t *)get_safe_page(GFP_ATOMIC);
61 if (!page_table)
62 return NULL;
63
64 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
65
66 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
67
68 return page_table;
69 }
70
71 return pte_offset_kernel(pmd, 0);
72}
73
74/*
75 * This maps the physical memory to kernel virtual address space, a total
76 * of max_low_pfn pages, by creating page tables starting from address
77 * PAGE_OFFSET. The page tables are allocated out of resume-safe pages.
78 */
79static int resume_physical_mapping_init(pgd_t *pgd_base)
80{
81 unsigned long pfn;
82 pgd_t *pgd;
83 pmd_t *pmd;
84 pte_t *pte;
85 int pgd_idx, pmd_idx;
86
87 pgd_idx = pgd_index(PAGE_OFFSET);
88 pgd = pgd_base + pgd_idx;
89 pfn = 0;
90
91 for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
92 pmd = resume_one_md_table_init(pgd);
93 if (!pmd)
94 return -ENOMEM;
95
96 if (pfn >= max_low_pfn)
97 continue;
98
99 for (pmd_idx = 0; pmd_idx < PTRS_PER_PMD; pmd++, pmd_idx++) {
100 if (pfn >= max_low_pfn)
101 break;
102
103 /* Map with big pages if possible, otherwise create
104 * normal page tables.
105 * NOTE: We can mark everything as executable here
106 */
107 if (cpu_has_pse) {
108 set_pmd(pmd, pfn_pmd(pfn, PAGE_KERNEL_LARGE_EXEC));
109 pfn += PTRS_PER_PTE;
110 } else {
111 pte_t *max_pte;
112
113 pte = resume_one_page_table_init(pmd);
114 if (!pte)
115 return -ENOMEM;
116
117 max_pte = pte + PTRS_PER_PTE;
118 for (; pte < max_pte; pte++, pfn++) {
119 if (pfn >= max_low_pfn)
120 break;
121
122 set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC));
123 }
124 }
125 }
126 }
127 return 0;
128}
129
130static inline void resume_init_first_level_page_table(pgd_t *pg_dir)
131{
132#ifdef CONFIG_X86_PAE
133 int i;
134
135 /* Init entries of the first-level page table to the zero page */
136 for (i = 0; i < PTRS_PER_PGD; i++)
137 set_pgd(pg_dir + i,
138 __pgd(__pa(empty_zero_page) | _PAGE_PRESENT));
139#endif
140}
141
142int swsusp_arch_resume(void)
143{
144 int error;
145
146 resume_pg_dir = (pgd_t *)get_safe_page(GFP_ATOMIC);
147 if (!resume_pg_dir)
148 return -ENOMEM;
149
150 resume_init_first_level_page_table(resume_pg_dir);
151 error = resume_physical_mapping_init(resume_pg_dir);
152 if (error)
153 return error;
154
155 /* We have got enough memory and from now on we cannot recover */
156 restore_image();
157 return 0;
158}
diff --git a/arch/i386/power/swsusp.S b/arch/i386/power/swsusp.S
index 8a2b50a0aaad..53662e05b393 100644
--- a/arch/i386/power/swsusp.S
+++ b/arch/i386/power/swsusp.S
@@ -28,8 +28,9 @@ ENTRY(swsusp_arch_suspend)
28 call swsusp_save 28 call swsusp_save
29 ret 29 ret
30 30
31ENTRY(swsusp_arch_resume) 31ENTRY(restore_image)
32 movl $swsusp_pg_dir-__PAGE_OFFSET, %ecx 32 movl resume_pg_dir, %ecx
33 subl $__PAGE_OFFSET, %ecx
33 movl %ecx, %cr3 34 movl %ecx, %cr3
34 35
35 movl restore_pblist, %edx 36 movl restore_pblist, %edx
@@ -51,6 +52,10 @@ copy_loop:
51 .p2align 4,,7 52 .p2align 4,,7
52 53
53done: 54done:
55 /* go back to the original page tables */
56 movl $swapper_pg_dir, %ecx
57 subl $__PAGE_OFFSET, %ecx
58 movl %ecx, %cr3
54 /* Flush TLB, including "global" things (vmalloc) */ 59 /* Flush TLB, including "global" things (vmalloc) */
55 movl mmu_cr4_features, %eax 60 movl mmu_cr4_features, %eax
56 movl %eax, %edx 61 movl %eax, %edx
diff --git a/arch/ia64/ia32/binfmt_elf32.c b/arch/ia64/ia32/binfmt_elf32.c
index daa6b91bc921..578737ec7629 100644
--- a/arch/ia64/ia32/binfmt_elf32.c
+++ b/arch/ia64/ia32/binfmt_elf32.c
@@ -91,7 +91,7 @@ ia64_elf32_init (struct pt_regs *regs)
91 * it with privilege level 3 because the IVE uses non-privileged accesses to these 91 * it with privilege level 3 because the IVE uses non-privileged accesses to these
92 * tables. IA-32 segmentation is used to protect against IA-32 accesses to them. 92 * tables. IA-32 segmentation is used to protect against IA-32 accesses to them.
93 */ 93 */
94 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 94 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
95 if (vma) { 95 if (vma) {
96 memset(vma, 0, sizeof(*vma)); 96 memset(vma, 0, sizeof(*vma));
97 vma->vm_mm = current->mm; 97 vma->vm_mm = current->mm;
@@ -117,7 +117,7 @@ ia64_elf32_init (struct pt_regs *regs)
117 * code is locked in specific gate page, which is pointed by pretcode 117 * code is locked in specific gate page, which is pointed by pretcode
118 * when setup_frame_ia32 118 * when setup_frame_ia32
119 */ 119 */
120 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 120 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
121 if (vma) { 121 if (vma) {
122 memset(vma, 0, sizeof(*vma)); 122 memset(vma, 0, sizeof(*vma));
123 vma->vm_mm = current->mm; 123 vma->vm_mm = current->mm;
@@ -142,7 +142,7 @@ ia64_elf32_init (struct pt_regs *regs)
142 * Install LDT as anonymous memory. This gives us all-zero segment descriptors 142 * Install LDT as anonymous memory. This gives us all-zero segment descriptors
143 * until a task modifies them via modify_ldt(). 143 * until a task modifies them via modify_ldt().
144 */ 144 */
145 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 145 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
146 if (vma) { 146 if (vma) {
147 memset(vma, 0, sizeof(*vma)); 147 memset(vma, 0, sizeof(*vma));
148 vma->vm_mm = current->mm; 148 vma->vm_mm = current->mm;
@@ -214,7 +214,7 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
214 bprm->loader += stack_base; 214 bprm->loader += stack_base;
215 bprm->exec += stack_base; 215 bprm->exec += stack_base;
216 216
217 mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 217 mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
218 if (!mpnt) 218 if (!mpnt)
219 return -ENOMEM; 219 return -ENOMEM;
220 220
diff --git a/arch/ia64/ia32/ia32_support.c b/arch/ia64/ia32/ia32_support.c
index c187743965a0..6af400a12ca1 100644
--- a/arch/ia64/ia32/ia32_support.c
+++ b/arch/ia64/ia32/ia32_support.c
@@ -249,7 +249,7 @@ ia32_init (void)
249 249
250#if PAGE_SHIFT > IA32_PAGE_SHIFT 250#if PAGE_SHIFT > IA32_PAGE_SHIFT
251 { 251 {
252 extern kmem_cache_t *partial_page_cachep; 252 extern struct kmem_cache *partial_page_cachep;
253 253
254 partial_page_cachep = kmem_cache_create("partial_page_cache", 254 partial_page_cachep = kmem_cache_create("partial_page_cache",
255 sizeof(struct partial_page), 0, 0, 255 sizeof(struct partial_page), 0, 0,
diff --git a/arch/ia64/ia32/ia32priv.h b/arch/ia64/ia32/ia32priv.h
index 703a67c934f8..cfa0bc0026b5 100644
--- a/arch/ia64/ia32/ia32priv.h
+++ b/arch/ia64/ia32/ia32priv.h
@@ -330,8 +330,6 @@ struct old_linux32_dirent {
330void ia64_elf32_init(struct pt_regs *regs); 330void ia64_elf32_init(struct pt_regs *regs);
331#define ELF_PLAT_INIT(_r, load_addr) ia64_elf32_init(_r) 331#define ELF_PLAT_INIT(_r, load_addr) ia64_elf32_init(_r)
332 332
333#define elf_addr_t u32
334
335/* This macro yields a bitmask that programs can use to figure out 333/* This macro yields a bitmask that programs can use to figure out
336 what instruction set this CPU supports. */ 334 what instruction set this CPU supports. */
337#define ELF_HWCAP 0 335#define ELF_HWCAP 0
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 9d6a3f210148..a4a6e1463af8 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -254,7 +254,7 @@ mmap_subpage (struct file *file, unsigned long start, unsigned long end, int pro
254} 254}
255 255
256/* SLAB cache for partial_page structures */ 256/* SLAB cache for partial_page structures */
257kmem_cache_t *partial_page_cachep; 257struct kmem_cache *partial_page_cachep;
258 258
259/* 259/*
260 * init partial_page_list. 260 * init partial_page_list.
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 51217d63285e..4d592ee9300b 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -481,7 +481,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
481void __kprobes arch_remove_kprobe(struct kprobe *p) 481void __kprobes arch_remove_kprobe(struct kprobe *p)
482{ 482{
483 mutex_lock(&kprobe_mutex); 483 mutex_lock(&kprobe_mutex);
484 free_insn_slot(p->ainsn.insn); 484 free_insn_slot(p->ainsn.insn, 0);
485 mutex_unlock(&kprobe_mutex); 485 mutex_unlock(&kprobe_mutex);
486} 486}
487/* 487/*
diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
index 0b546e2b36ac..c4c10a0b99d9 100644
--- a/arch/ia64/kernel/palinfo.c
+++ b/arch/ia64/kernel/palinfo.c
@@ -952,7 +952,6 @@ remove_palinfo_proc_entries(unsigned int hcpu)
952 } 952 }
953} 953}
954 954
955#ifdef CONFIG_HOTPLUG_CPU
956static int palinfo_cpu_callback(struct notifier_block *nfb, 955static int palinfo_cpu_callback(struct notifier_block *nfb,
957 unsigned long action, void *hcpu) 956 unsigned long action, void *hcpu)
958{ 957{
@@ -974,7 +973,6 @@ static struct notifier_block palinfo_cpu_notifier =
974 .notifier_call = palinfo_cpu_callback, 973 .notifier_call = palinfo_cpu_callback,
975 .priority = 0, 974 .priority = 0,
976}; 975};
977#endif
978 976
979static int __init 977static int __init
980palinfo_init(void) 978palinfo_init(void)
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 3aaede0d6981..e2321536ee4c 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -2302,7 +2302,7 @@ pfm_smpl_buffer_alloc(struct task_struct *task, pfm_context_t *ctx, unsigned lon
2302 DPRINT(("smpl_buf @%p\n", smpl_buf)); 2302 DPRINT(("smpl_buf @%p\n", smpl_buf));
2303 2303
2304 /* allocate vma */ 2304 /* allocate vma */
2305 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 2305 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
2306 if (!vma) { 2306 if (!vma) {
2307 DPRINT(("Cannot allocate vma\n")); 2307 DPRINT(("Cannot allocate vma\n"));
2308 goto error_kmem; 2308 goto error_kmem;
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index e63b8ca5344a..fd607ca51a8d 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -575,7 +575,6 @@ static struct file_operations salinfo_data_fops = {
575 .write = salinfo_log_write, 575 .write = salinfo_log_write,
576}; 576};
577 577
578#ifdef CONFIG_HOTPLUG_CPU
579static int __devinit 578static int __devinit
580salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu) 579salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
581{ 580{
@@ -620,7 +619,6 @@ static struct notifier_block salinfo_cpu_notifier =
620 .notifier_call = salinfo_cpu_callback, 619 .notifier_call = salinfo_cpu_callback,
621 .priority = 0, 620 .priority = 0,
622}; 621};
623#endif /* CONFIG_HOTPLUG_CPU */
624 622
625static int __init 623static int __init
626salinfo_init(void) 624salinfo_init(void)
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 5629b45e89c6..687500ddb4b8 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -31,11 +31,11 @@ int arch_register_cpu(int num)
31{ 31{
32#if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU) 32#if defined (CONFIG_ACPI) && defined (CONFIG_HOTPLUG_CPU)
33 /* 33 /*
34 * If CPEI cannot be re-targetted, and this is 34 * If CPEI can be re-targetted or if this is not
35 * CPEI target, then dont create the control file 35 * CPEI target, then it is hotpluggable
36 */ 36 */
37 if (!can_cpei_retarget() && is_cpu_cpei_target(num)) 37 if (can_cpei_retarget() || !is_cpu_cpei_target(num))
38 sysfs_cpus[num].cpu.no_control = 1; 38 sysfs_cpus[num].cpu.hotpluggable = 1;
39 map_cpu_to_node(num, node_cpuid[num].nid); 39 map_cpu_to_node(num, node_cpuid[num].nid);
40#endif 40#endif
41 41
diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
index f3a9585e98a8..0c7e94edc20e 100644
--- a/arch/ia64/mm/hugetlbpage.c
+++ b/arch/ia64/mm/hugetlbpage.c
@@ -64,6 +64,11 @@ huge_pte_offset (struct mm_struct *mm, unsigned long addr)
64 return pte; 64 return pte;
65} 65}
66 66
67int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
68{
69 return 0;
70}
71
67#define mk_pte_huge(entry) { pte_val(entry) |= _PAGE_P; } 72#define mk_pte_huge(entry) { pte_val(entry) |= _PAGE_P; }
68 73
69/* 74/*
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index ff87a5cba399..56dc2024220e 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -156,7 +156,7 @@ ia64_init_addr_space (void)
156 * the problem. When the process attempts to write to the register backing store 156 * the problem. When the process attempts to write to the register backing store
157 * for the first time, it will get a SEGFAULT in this case. 157 * for the first time, it will get a SEGFAULT in this case.
158 */ 158 */
159 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 159 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
160 if (vma) { 160 if (vma) {
161 memset(vma, 0, sizeof(*vma)); 161 memset(vma, 0, sizeof(*vma));
162 vma->vm_mm = current->mm; 162 vma->vm_mm = current->mm;
@@ -175,7 +175,7 @@ ia64_init_addr_space (void)
175 175
176 /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */ 176 /* map NaT-page at address zero to speed up speculative dereferencing of NULL: */
177 if (!(current->personality & MMAP_PAGE_ZERO)) { 177 if (!(current->personality & MMAP_PAGE_ZERO)) {
178 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 178 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
179 if (vma) { 179 if (vma) {
180 memset(vma, 0, sizeof(*vma)); 180 memset(vma, 0, sizeof(*vma));
181 vma->vm_mm = current->mm; 181 vma->vm_mm = current->mm;
diff --git a/arch/m32r/kernel/setup.c b/arch/m32r/kernel/setup.c
index 0e7778be33cc..936205f7aba0 100644
--- a/arch/m32r/kernel/setup.c
+++ b/arch/m32r/kernel/setup.c
@@ -196,9 +196,7 @@ static unsigned long __init setup_memory(void)
196 if (LOADER_TYPE && INITRD_START) { 196 if (LOADER_TYPE && INITRD_START) {
197 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { 197 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
198 reserve_bootmem(INITRD_START, INITRD_SIZE); 198 reserve_bootmem(INITRD_START, INITRD_SIZE);
199 initrd_start = INITRD_START ? 199 initrd_start = INITRD_START + PAGE_OFFSET;
200 INITRD_START + PAGE_OFFSET : 0;
201
202 initrd_end = initrd_start + INITRD_SIZE; 200 initrd_end = initrd_start + INITRD_SIZE;
203 printk("initrd:start[%08lx],size[%08lx]\n", 201 printk("initrd:start[%08lx],size[%08lx]\n",
204 initrd_start, INITRD_SIZE); 202 initrd_start, INITRD_SIZE);
diff --git a/arch/m32r/kernel/signal.c b/arch/m32r/kernel/signal.c
index b60cea4aebaa..092ea86bb079 100644
--- a/arch/m32r/kernel/signal.c
+++ b/arch/m32r/kernel/signal.c
@@ -21,7 +21,7 @@
21#include <linux/unistd.h> 21#include <linux/unistd.h>
22#include <linux/stddef.h> 22#include <linux/stddef.h>
23#include <linux/personality.h> 23#include <linux/personality.h>
24#include <linux/suspend.h> 24#include <linux/freezer.h>
25#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
26#include <asm/ucontext.h> 26#include <asm/ucontext.h>
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
diff --git a/arch/m32r/mm/discontig.c b/arch/m32r/mm/discontig.c
index abb34ccd5986..c7efdb0aefc5 100644
--- a/arch/m32r/mm/discontig.c
+++ b/arch/m32r/mm/discontig.c
@@ -105,9 +105,7 @@ unsigned long __init setup_memory(void)
105 if (INITRD_START + INITRD_SIZE <= PFN_PHYS(max_low_pfn)) { 105 if (INITRD_START + INITRD_SIZE <= PFN_PHYS(max_low_pfn)) {
106 reserve_bootmem_node(NODE_DATA(0), INITRD_START, 106 reserve_bootmem_node(NODE_DATA(0), INITRD_START,
107 INITRD_SIZE); 107 INITRD_SIZE);
108 initrd_start = INITRD_START ? 108 initrd_start = INITRD_START + PAGE_OFFSET;
109 INITRD_START + PAGE_OFFSET : 0;
110
111 initrd_end = initrd_start + INITRD_SIZE; 109 initrd_end = initrd_start + INITRD_SIZE;
112 printk("initrd:start[%08lx],size[%08lx]\n", 110 printk("initrd:start[%08lx],size[%08lx]\n",
113 initrd_start, INITRD_SIZE); 111 initrd_start, INITRD_SIZE);
diff --git a/arch/m68k/amiga/chipram.c b/arch/m68k/amiga/chipram.c
index de1304c91112..fa015d801617 100644
--- a/arch/m68k/amiga/chipram.c
+++ b/arch/m68k/amiga/chipram.c
@@ -52,10 +52,9 @@ void *amiga_chip_alloc(unsigned long size, const char *name)
52#ifdef DEBUG 52#ifdef DEBUG
53 printk("amiga_chip_alloc: allocate %ld bytes\n", size); 53 printk("amiga_chip_alloc: allocate %ld bytes\n", size);
54#endif 54#endif
55 res = kmalloc(sizeof(struct resource), GFP_KERNEL); 55 res = kzalloc(sizeof(struct resource), GFP_KERNEL);
56 if (!res) 56 if (!res)
57 return NULL; 57 return NULL;
58 memset(res, 0, sizeof(struct resource));
59 res->name = name; 58 res->name = name;
60 59
61 if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) { 60 if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) {
diff --git a/arch/m68k/atari/hades-pci.c b/arch/m68k/atari/hades-pci.c
index 6ca57b6564da..bee2b1443e36 100644
--- a/arch/m68k/atari/hades-pci.c
+++ b/arch/m68k/atari/hades-pci.c
@@ -375,10 +375,9 @@ struct pci_bus_info * __init init_hades_pci(void)
375 * Allocate memory for bus info structure. 375 * Allocate memory for bus info structure.
376 */ 376 */
377 377
378 bus = kmalloc(sizeof(struct pci_bus_info), GFP_KERNEL); 378 bus = kzalloc(sizeof(struct pci_bus_info), GFP_KERNEL);
379 if (!bus) 379 if (!bus)
380 return NULL; 380 return NULL;
381 memset(bus, 0, sizeof(struct pci_bus_info));
382 381
383 /* 382 /*
384 * Claim resources. The m68k has no separate I/O space, both 383 * Claim resources. The m68k has no separate I/O space, both
diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c
index 911f2ce3f53e..2adbeb16e1b8 100644
--- a/arch/m68k/mm/fault.c
+++ b/arch/m68k/mm/fault.c
@@ -99,7 +99,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
99 * If we're in an interrupt or have no user 99 * If we're in an interrupt or have no user
100 * context, we must not take the fault.. 100 * context, we must not take the fault..
101 */ 101 */
102 if (in_interrupt() || !mm) 102 if (in_atomic() || !mm)
103 goto no_context; 103 goto no_context;
104 104
105 down_read(&mm->mmap_sem); 105 down_read(&mm->mmap_sem);
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
index 58afa8be604e..2b2a10da64a4 100644
--- a/arch/m68knommu/kernel/vmlinux.lds.S
+++ b/arch/m68knommu/kernel/vmlinux.lds.S
@@ -60,6 +60,7 @@ SECTIONS {
60#endif 60#endif
61 61
62 .text : { 62 .text : {
63 _text = .;
63 _stext = . ; 64 _stext = . ;
64 *(.text) 65 *(.text)
65 SCHED_TEXT 66 SCHED_TEXT
diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
index 4a9f1ecefaf2..9b34238d41c0 100644
--- a/arch/mips/kernel/binfmt_elfn32.c
+++ b/arch/mips/kernel/binfmt_elfn32.c
@@ -90,7 +90,6 @@ struct elf_prpsinfo32
90 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ 90 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
91}; 91};
92 92
93#define elf_addr_t u32
94#define elf_caddr_t u32 93#define elf_caddr_t u32
95#define init_elf_binfmt init_elfn32_binfmt 94#define init_elf_binfmt init_elfn32_binfmt
96 95
diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
index e31813779895..993f7ec70f35 100644
--- a/arch/mips/kernel/binfmt_elfo32.c
+++ b/arch/mips/kernel/binfmt_elfo32.c
@@ -92,7 +92,6 @@ struct elf_prpsinfo32
92 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ 92 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
93}; 93};
94 94
95#define elf_addr_t u32
96#define elf_caddr_t u32 95#define elf_caddr_t u32
97#define init_elf_binfmt init_elf32_binfmt 96#define init_elf_binfmt init_elf32_binfmt
98 97
diff --git a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c
index ab12c8f01518..1bbefbf43373 100644
--- a/arch/mips/kernel/irixelf.c
+++ b/arch/mips/kernel/irixelf.c
@@ -52,10 +52,6 @@ static struct linux_binfmt irix_format = {
52 irix_core_dump, PAGE_SIZE 52 irix_core_dump, PAGE_SIZE
53}; 53};
54 54
55#ifndef elf_addr_t
56#define elf_addr_t unsigned long
57#endif
58
59#ifdef DEBUG 55#ifdef DEBUG
60/* Debugging routines. */ 56/* Debugging routines. */
61static char *get_elf_p_type(Elf32_Word p_type) 57static char *get_elf_p_type(Elf32_Word p_type)
@@ -1013,7 +1009,7 @@ static int notesize(struct memelfnote *en)
1013 int sz; 1009 int sz;
1014 1010
1015 sz = sizeof(struct elf_note); 1011 sz = sizeof(struct elf_note);
1016 sz += roundup(strlen(en->name), 4); 1012 sz += roundup(strlen(en->name) + 1, 4);
1017 sz += roundup(en->datasz, 4); 1013 sz += roundup(en->datasz, 4);
1018 1014
1019 return sz; 1015 return sz;
@@ -1032,7 +1028,7 @@ static int writenote(struct memelfnote *men, struct file *file)
1032{ 1028{
1033 struct elf_note en; 1029 struct elf_note en;
1034 1030
1035 en.n_namesz = strlen(men->name); 1031 en.n_namesz = strlen(men->name) + 1;
1036 en.n_descsz = men->datasz; 1032 en.n_descsz = men->datasz;
1037 en.n_type = men->type; 1033 en.n_type = men->type;
1038 1034
diff --git a/arch/mips/mm/dma-coherent.c b/arch/mips/mm/dma-coherent.c
index 7fa5fd16e46b..5697c6e250a3 100644
--- a/arch/mips/mm/dma-coherent.c
+++ b/arch/mips/mm/dma-coherent.c
@@ -190,14 +190,14 @@ int dma_supported(struct device *dev, u64 mask)
190 190
191EXPORT_SYMBOL(dma_supported); 191EXPORT_SYMBOL(dma_supported);
192 192
193int dma_is_consistent(dma_addr_t dma_addr) 193int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
194{ 194{
195 return 1; 195 return 1;
196} 196}
197 197
198EXPORT_SYMBOL(dma_is_consistent); 198EXPORT_SYMBOL(dma_is_consistent);
199 199
200void dma_cache_sync(void *vaddr, size_t size, 200void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
201 enum dma_data_direction direction) 201 enum dma_data_direction direction)
202{ 202{
203 BUG_ON(direction == DMA_NONE); 203 BUG_ON(direction == DMA_NONE);
diff --git a/arch/mips/mm/dma-ip27.c b/arch/mips/mm/dma-ip27.c
index 8da19fd22ac6..f088344db465 100644
--- a/arch/mips/mm/dma-ip27.c
+++ b/arch/mips/mm/dma-ip27.c
@@ -197,14 +197,14 @@ int dma_supported(struct device *dev, u64 mask)
197 197
198EXPORT_SYMBOL(dma_supported); 198EXPORT_SYMBOL(dma_supported);
199 199
200int dma_is_consistent(dma_addr_t dma_addr) 200int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
201{ 201{
202 return 1; 202 return 1;
203} 203}
204 204
205EXPORT_SYMBOL(dma_is_consistent); 205EXPORT_SYMBOL(dma_is_consistent);
206 206
207void dma_cache_sync(void *vaddr, size_t size, 207void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
208 enum dma_data_direction direction) 208 enum dma_data_direction direction)
209{ 209{
210 BUG_ON(direction == DMA_NONE); 210 BUG_ON(direction == DMA_NONE);
diff --git a/arch/mips/mm/dma-ip32.c b/arch/mips/mm/dma-ip32.c
index ec54ed0d26ff..b42b6f7456e6 100644
--- a/arch/mips/mm/dma-ip32.c
+++ b/arch/mips/mm/dma-ip32.c
@@ -363,14 +363,15 @@ int dma_supported(struct device *dev, u64 mask)
363 363
364EXPORT_SYMBOL(dma_supported); 364EXPORT_SYMBOL(dma_supported);
365 365
366int dma_is_consistent(dma_addr_t dma_addr) 366int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
367{ 367{
368 return 1; 368 return 1;
369} 369}
370 370
371EXPORT_SYMBOL(dma_is_consistent); 371EXPORT_SYMBOL(dma_is_consistent);
372 372
373void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction direction) 373void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
374 enum dma_data_direction direction)
374{ 375{
375 if (direction == DMA_NONE) 376 if (direction == DMA_NONE)
376 return; 377 return;
diff --git a/arch/mips/mm/dma-noncoherent.c b/arch/mips/mm/dma-noncoherent.c
index 2eeffe5c2a3a..8cecef0957c3 100644
--- a/arch/mips/mm/dma-noncoherent.c
+++ b/arch/mips/mm/dma-noncoherent.c
@@ -299,14 +299,15 @@ int dma_supported(struct device *dev, u64 mask)
299 299
300EXPORT_SYMBOL(dma_supported); 300EXPORT_SYMBOL(dma_supported);
301 301
302int dma_is_consistent(dma_addr_t dma_addr) 302int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
303{ 303{
304 return 1; 304 return 1;
305} 305}
306 306
307EXPORT_SYMBOL(dma_is_consistent); 307EXPORT_SYMBOL(dma_is_consistent);
308 308
309void dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction direction) 309void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
310 enum dma_data_direction direction)
310{ 311{
311 if (direction == DMA_NONE) 312 if (direction == DMA_NONE)
312 return; 313 return;
diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c
index 99ebf3ccc222..675502ada5a2 100644
--- a/arch/mips/mm/highmem.c
+++ b/arch/mips/mm/highmem.c
@@ -39,7 +39,7 @@ void *__kmap_atomic(struct page *page, enum km_type type)
39 unsigned long vaddr; 39 unsigned long vaddr;
40 40
41 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 41 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
42 inc_preempt_count(); 42 pagefault_disable();
43 if (!PageHighMem(page)) 43 if (!PageHighMem(page))
44 return page_address(page); 44 return page_address(page);
45 45
@@ -62,8 +62,7 @@ void __kunmap_atomic(void *kvaddr, enum km_type type)
62 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); 62 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
63 63
64 if (vaddr < FIXADDR_START) { // FIXME 64 if (vaddr < FIXADDR_START) { // FIXME
65 dec_preempt_count(); 65 pagefault_enable();
66 preempt_check_resched();
67 return; 66 return;
68 } 67 }
69 68
@@ -78,8 +77,7 @@ void __kunmap_atomic(void *kvaddr, enum km_type type)
78 local_flush_tlb_one(vaddr); 77 local_flush_tlb_one(vaddr);
79#endif 78#endif
80 79
81 dec_preempt_count(); 80 pagefault_enable();
82 preempt_check_resched();
83} 81}
84 82
85#ifndef CONFIG_LIMITED_DMA 83#ifndef CONFIG_LIMITED_DMA
@@ -92,7 +90,7 @@ void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
92 enum fixed_addresses idx; 90 enum fixed_addresses idx;
93 unsigned long vaddr; 91 unsigned long vaddr;
94 92
95 inc_preempt_count(); 93 pagefault_disable();
96 94
97 idx = type + KM_TYPE_NR*smp_processor_id(); 95 idx = type + KM_TYPE_NR*smp_processor_id();
98 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 96 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
diff --git a/arch/parisc/kernel/binfmt_elf32.c b/arch/parisc/kernel/binfmt_elf32.c
index 1e64e7b88110..ecb10a4f63c6 100644
--- a/arch/parisc/kernel/binfmt_elf32.c
+++ b/arch/parisc/kernel/binfmt_elf32.c
@@ -75,7 +75,6 @@ struct elf_prpsinfo32
75 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */ 75 char pr_psargs[ELF_PRARGSZ]; /* initial part of arg list */
76}; 76};
77 77
78#define elf_addr_t unsigned int
79#define init_elf_binfmt init_elf32_binfmt 78#define init_elf_binfmt init_elf32_binfmt
80 79
81#define ELF_PLATFORM ("PARISC32\0") 80#define ELF_PLATFORM ("PARISC32\0")
diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
index 64785e46f93b..641f9c920eee 100644
--- a/arch/parisc/mm/fault.c
+++ b/arch/parisc/mm/fault.c
@@ -152,7 +152,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,
152 const struct exception_table_entry *fix; 152 const struct exception_table_entry *fix;
153 unsigned long acc_type; 153 unsigned long acc_type;
154 154
155 if (in_interrupt() || !mm) 155 if (in_atomic() || !mm)
156 goto no_context; 156 goto no_context;
157 157
158 down_read(&mm->mmap_sem); 158 down_read(&mm->mmap_sem);
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 89b03c8da9d2..d3f2080d2eee 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -46,61 +46,6 @@ int crashing_cpu = -1;
46static cpumask_t cpus_in_crash = CPU_MASK_NONE; 46static cpumask_t cpus_in_crash = CPU_MASK_NONE;
47cpumask_t cpus_in_sr = CPU_MASK_NONE; 47cpumask_t cpus_in_sr = CPU_MASK_NONE;
48 48
49static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
50 size_t data_len)
51{
52 struct elf_note note;
53
54 note.n_namesz = strlen(name) + 1;
55 note.n_descsz = data_len;
56 note.n_type = type;
57 memcpy(buf, &note, sizeof(note));
58 buf += (sizeof(note) +3)/4;
59 memcpy(buf, name, note.n_namesz);
60 buf += (note.n_namesz + 3)/4;
61 memcpy(buf, data, note.n_descsz);
62 buf += (note.n_descsz + 3)/4;
63
64 return buf;
65}
66
67static void final_note(u32 *buf)
68{
69 struct elf_note note;
70
71 note.n_namesz = 0;
72 note.n_descsz = 0;
73 note.n_type = 0;
74 memcpy(buf, &note, sizeof(note));
75}
76
77static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
78{
79 struct elf_prstatus prstatus;
80 u32 *buf;
81
82 if ((cpu < 0) || (cpu >= NR_CPUS))
83 return;
84
85 /* Using ELF notes here is opportunistic.
86 * I need a well defined structure format
87 * for the data I pass, and I need tags
88 * on the data to indicate what information I have
89 * squirrelled away. ELF notes happen to provide
90 * all of that that no need to invent something new.
91 */
92 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
93 if (!buf)
94 return;
95
96 memset(&prstatus, 0, sizeof(prstatus));
97 prstatus.pr_pid = current->pid;
98 elf_core_copy_regs(&prstatus.pr_reg, regs);
99 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
100 sizeof(prstatus));
101 final_note(buf);
102}
103
104#ifdef CONFIG_SMP 49#ifdef CONFIG_SMP
105static atomic_t enter_on_soft_reset = ATOMIC_INIT(0); 50static atomic_t enter_on_soft_reset = ATOMIC_INIT(0);
106 51
@@ -113,7 +58,7 @@ void crash_ipi_callback(struct pt_regs *regs)
113 58
114 hard_irq_disable(); 59 hard_irq_disable();
115 if (!cpu_isset(cpu, cpus_in_crash)) 60 if (!cpu_isset(cpu, cpus_in_crash))
116 crash_save_this_cpu(regs, cpu); 61 crash_save_cpu(regs, cpu);
117 cpu_set(cpu, cpus_in_crash); 62 cpu_set(cpu, cpus_in_crash);
118 63
119 /* 64 /*
@@ -306,7 +251,7 @@ void default_machine_crash_shutdown(struct pt_regs *regs)
306 * such that another IPI will not be sent. 251 * such that another IPI will not be sent.
307 */ 252 */
308 crashing_cpu = smp_processor_id(); 253 crashing_cpu = smp_processor_id();
309 crash_save_this_cpu(regs, crashing_cpu); 254 crash_save_cpu(regs, crashing_cpu);
310 crash_kexec_prepare_cpus(crashing_cpu); 255 crash_kexec_prepare_cpus(crashing_cpu);
311 cpu_set(crashing_cpu, cpus_in_crash); 256 cpu_set(crashing_cpu, cpus_in_crash);
312 if (ppc_md.kexec_cpu_down) 257 if (ppc_md.kexec_cpu_down)
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 7b8d12b9026c..4657563f8813 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -85,7 +85,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
85void __kprobes arch_remove_kprobe(struct kprobe *p) 85void __kprobes arch_remove_kprobe(struct kprobe *p)
86{ 86{
87 mutex_lock(&kprobe_mutex); 87 mutex_lock(&kprobe_mutex);
88 free_insn_slot(p->ainsn.insn); 88 free_insn_slot(p->ainsn.insn, 0);
89 mutex_unlock(&kprobe_mutex); 89 mutex_unlock(&kprobe_mutex);
90} 90}
91 91
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index b9561d300516..7d0f13fecc0e 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -101,7 +101,7 @@ struct flash_block_list_header { /* just the header of flash_block_list */
101static struct flash_block_list_header rtas_firmware_flash_list = {0, NULL}; 101static struct flash_block_list_header rtas_firmware_flash_list = {0, NULL};
102 102
103/* Use slab cache to guarantee 4k alignment */ 103/* Use slab cache to guarantee 4k alignment */
104static kmem_cache_t *flash_block_cache = NULL; 104static struct kmem_cache *flash_block_cache = NULL;
105 105
106#define FLASH_BLOCK_LIST_VERSION (1UL) 106#define FLASH_BLOCK_LIST_VERSION (1UL)
107 107
@@ -286,7 +286,7 @@ static ssize_t rtas_flash_read(struct file *file, char __user *buf,
286} 286}
287 287
288/* constructor for flash_block_cache */ 288/* constructor for flash_block_cache */
289void rtas_block_ctor(void *ptr, kmem_cache_t *cache, unsigned long flags) 289void rtas_block_ctor(void *ptr, struct kmem_cache *cache, unsigned long flags)
290{ 290{
291 memset(ptr, 0, RTAS_BLK_SIZE); 291 memset(ptr, 0, RTAS_BLK_SIZE);
292} 292}
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 320353f0926f..e4ebe1a6228e 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -36,7 +36,7 @@
36#include <linux/stddef.h> 36#include <linux/stddef.h>
37#include <linux/tty.h> 37#include <linux/tty.h>
38#include <linux/binfmts.h> 38#include <linux/binfmts.h>
39#include <linux/suspend.h> 39#include <linux/freezer.h>
40#endif 40#endif
41 41
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 22123a0d5416..63ed265b7f09 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -239,7 +239,7 @@ static void unregister_cpu_online(unsigned int cpu)
239 struct cpu *c = &per_cpu(cpu_devices, cpu); 239 struct cpu *c = &per_cpu(cpu_devices, cpu);
240 struct sys_device *s = &c->sysdev; 240 struct sys_device *s = &c->sysdev;
241 241
242 BUG_ON(c->no_control); 242 BUG_ON(!c->hotpluggable);
243 243
244 if (!firmware_has_feature(FW_FEATURE_ISERIES) && 244 if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
245 cpu_has_feature(CPU_FTR_SMT)) 245 cpu_has_feature(CPU_FTR_SMT))
@@ -424,10 +424,10 @@ static int __init topology_init(void)
424 * CPU. For instance, the boot cpu might never be valid 424 * CPU. For instance, the boot cpu might never be valid
425 * for hotplugging. 425 * for hotplugging.
426 */ 426 */
427 if (!ppc_md.cpu_die) 427 if (ppc_md.cpu_die)
428 c->no_control = 1; 428 c->hotpluggable = 1;
429 429
430 if (cpu_online(cpu) || (c->no_control == 0)) { 430 if (cpu_online(cpu) || c->hotpluggable) {
431 register_cpu(c, cpu); 431 register_cpu(c, cpu);
432 432
433 sysdev_create_file(&c->sysdev, &attr_physical_id); 433 sysdev_create_file(&c->sysdev, &attr_physical_id);
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index c913ad5cad29..a4b28c73bba0 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -264,7 +264,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
264 264
265 265
266 /* Allocate a VMA structure and fill it up */ 266 /* Allocate a VMA structure and fill it up */
267 vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL); 267 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
268 if (vma == NULL) { 268 if (vma == NULL) {
269 rc = -ENOMEM; 269 rc = -ENOMEM;
270 goto fail_mmapsem; 270 goto fail_mmapsem;
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index e8342d867536..04b98671a060 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -33,6 +33,7 @@ SECTIONS
33 33
34 /* Text and gots */ 34 /* Text and gots */
35 .text : { 35 .text : {
36 _text = .;
36 *(.text .text.*) 37 *(.text .text.*)
37 SCHED_TEXT 38 SCHED_TEXT
38 LOCK_TEXT 39 LOCK_TEXT
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 506d89768d45..89c836d54809 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -146,6 +146,11 @@ pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
146 return hugepte_offset(hpdp, addr); 146 return hugepte_offset(hpdp, addr);
147} 147}
148 148
149int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
150{
151 return 0;
152}
153
149static void free_hugepte_range(struct mmu_gather *tlb, hugepd_t *hpdp) 154static void free_hugepte_range(struct mmu_gather *tlb, hugepd_t *hpdp)
150{ 155{
151 pte_t *hugepte = hugepd_page(*hpdp); 156 pte_t *hugepte = hugepd_page(*hpdp);
@@ -1042,7 +1047,7 @@ repeat:
1042 return err; 1047 return err;
1043} 1048}
1044 1049
1045static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) 1050static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
1046{ 1051{
1047 memset(addr, 0, kmem_cache_size(cache)); 1052 memset(addr, 0, kmem_cache_size(cache));
1048} 1053}
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 9a178549cbcf..d12a87ec5ae9 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -141,7 +141,7 @@ static int __init setup_kcore(void)
141} 141}
142module_init(setup_kcore); 142module_init(setup_kcore);
143 143
144static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) 144static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
145{ 145{
146 memset(addr, 0, kmem_cache_size(cache)); 146 memset(addr, 0, kmem_cache_size(cache));
147} 147}
@@ -166,9 +166,9 @@ static const char *pgtable_cache_name[ARRAY_SIZE(pgtable_cache_size)] = {
166/* Hugepages need one extra cache, initialized in hugetlbpage.c. We 166/* Hugepages need one extra cache, initialized in hugetlbpage.c. We
167 * can't put into the tables above, because HPAGE_SHIFT is not compile 167 * can't put into the tables above, because HPAGE_SHIFT is not compile
168 * time constant. */ 168 * time constant. */
169kmem_cache_t *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)+1]; 169struct kmem_cache *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)+1];
170#else 170#else
171kmem_cache_t *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)]; 171struct kmem_cache *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)];
172#endif 172#endif
173 173
174void pgtable_cache_init(void) 174void pgtable_cache_init(void)
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index c7d010749a18..e3af9112c026 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -40,7 +40,7 @@
40 40
41#include "spufs.h" 41#include "spufs.h"
42 42
43static kmem_cache_t *spufs_inode_cache; 43static struct kmem_cache *spufs_inode_cache;
44char *isolated_loader; 44char *isolated_loader;
45 45
46static struct inode * 46static struct inode *
@@ -48,7 +48,7 @@ spufs_alloc_inode(struct super_block *sb)
48{ 48{
49 struct spufs_inode_info *ei; 49 struct spufs_inode_info *ei;
50 50
51 ei = kmem_cache_alloc(spufs_inode_cache, SLAB_KERNEL); 51 ei = kmem_cache_alloc(spufs_inode_cache, GFP_KERNEL);
52 if (!ei) 52 if (!ei)
53 return NULL; 53 return NULL;
54 54
@@ -65,7 +65,7 @@ spufs_destroy_inode(struct inode *inode)
65} 65}
66 66
67static void 67static void
68spufs_init_once(void *p, kmem_cache_t * cachep, unsigned long flags) 68spufs_init_once(void *p, struct kmem_cache * cachep, unsigned long flags)
69{ 69{
70 struct spufs_inode_info *ei = p; 70 struct spufs_inode_info *ei = p;
71 71
diff --git a/arch/ppc/kernel/vmlinux.lds.S b/arch/ppc/kernel/vmlinux.lds.S
index 16e8661e1fec..61921268a0d0 100644
--- a/arch/ppc/kernel/vmlinux.lds.S
+++ b/arch/ppc/kernel/vmlinux.lds.S
@@ -31,6 +31,7 @@ SECTIONS
31 .plt : { *(.plt) } 31 .plt : { *(.plt) }
32 .text : 32 .text :
33 { 33 {
34 _text = .;
34 *(.text) 35 *(.text)
35 SCHED_TEXT 36 SCHED_TEXT
36 LOCK_TEXT 37 LOCK_TEXT
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index 67d5cf9cba83..b8c237290263 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -561,7 +561,6 @@ appldata_offline_cpu(int cpu)
561 spin_unlock(&appldata_timer_lock); 561 spin_unlock(&appldata_timer_lock);
562} 562}
563 563
564#ifdef CONFIG_HOTPLUG_CPU
565static int __cpuinit 564static int __cpuinit
566appldata_cpu_notify(struct notifier_block *self, 565appldata_cpu_notify(struct notifier_block *self,
567 unsigned long action, void *hcpu) 566 unsigned long action, void *hcpu)
@@ -582,7 +581,6 @@ appldata_cpu_notify(struct notifier_block *self,
582static struct notifier_block appldata_nb = { 581static struct notifier_block appldata_nb = {
583 .notifier_call = appldata_cpu_notify, 582 .notifier_call = appldata_cpu_notify,
584}; 583};
585#endif
586 584
587/* 585/*
588 * appldata_init() 586 * appldata_init()
diff --git a/arch/s390/kernel/binfmt_elf32.c b/arch/s390/kernel/binfmt_elf32.c
index 9565a2dcfadc..5c46054195cb 100644
--- a/arch/s390/kernel/binfmt_elf32.c
+++ b/arch/s390/kernel/binfmt_elf32.c
@@ -176,7 +176,6 @@ struct elf_prpsinfo32
176 176
177#include <linux/highuid.h> 177#include <linux/highuid.h>
178 178
179#define elf_addr_t u32
180/* 179/*
181#define init_elf_binfmt init_elf32_binfmt 180#define init_elf_binfmt init_elf32_binfmt
182*/ 181*/
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 67914fe7f317..576368c4f605 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -200,7 +200,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
200void __kprobes arch_remove_kprobe(struct kprobe *p) 200void __kprobes arch_remove_kprobe(struct kprobe *p)
201{ 201{
202 mutex_lock(&kprobe_mutex); 202 mutex_lock(&kprobe_mutex);
203 free_insn_slot(p->ainsn.insn); 203 free_insn_slot(p->ainsn.insn, 0);
204 mutex_unlock(&kprobe_mutex); 204 mutex_unlock(&kprobe_mutex);
205} 205}
206 206
diff --git a/arch/s390/lib/uaccess_std.c b/arch/s390/lib/uaccess_std.c
index 2d549ed2e113..bbaca66fa293 100644
--- a/arch/s390/lib/uaccess_std.c
+++ b/arch/s390/lib/uaccess_std.c
@@ -11,7 +11,7 @@
11 11
12#include <linux/errno.h> 12#include <linux/errno.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <asm/uaccess.h> 14#include <linux/uaccess.h>
15#include <asm/futex.h> 15#include <asm/futex.h>
16 16
17#ifndef __s390x__ 17#ifndef __s390x__
@@ -258,7 +258,7 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
258{ 258{
259 int oldval = 0, newval, ret; 259 int oldval = 0, newval, ret;
260 260
261 inc_preempt_count(); 261 pagefault_disable();
262 262
263 switch (op) { 263 switch (op) {
264 case FUTEX_OP_SET: 264 case FUTEX_OP_SET:
@@ -284,7 +284,7 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
284 default: 284 default:
285 ret = -ENOSYS; 285 ret = -ENOSYS;
286 } 286 }
287 dec_preempt_count(); 287 pagefault_enable();
288 *old = oldval; 288 *old = oldval;
289 return ret; 289 return ret;
290} 290}
diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
index 55f43506995a..0c9ea38d2caa 100644
--- a/arch/sh/kernel/cpu/sh4/sq.c
+++ b/arch/sh/kernel/cpu/sh4/sq.c
@@ -38,7 +38,7 @@ struct sq_mapping {
38 38
39static struct sq_mapping *sq_mapping_list; 39static struct sq_mapping *sq_mapping_list;
40static DEFINE_SPINLOCK(sq_mapping_lock); 40static DEFINE_SPINLOCK(sq_mapping_lock);
41static kmem_cache_t *sq_cache; 41static struct kmem_cache *sq_cache;
42static unsigned long *sq_bitmap; 42static unsigned long *sq_bitmap;
43 43
44#define store_queue_barrier() \ 44#define store_queue_barrier() \
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 696ca75752d9..f8dd6b7bfab0 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -332,8 +332,7 @@ void __init setup_arch(char **cmdline_p)
332 if (LOADER_TYPE && INITRD_START) { 332 if (LOADER_TYPE && INITRD_START) {
333 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) { 333 if (INITRD_START + INITRD_SIZE <= (max_low_pfn << PAGE_SHIFT)) {
334 reserve_bootmem_node(NODE_DATA(0), INITRD_START+__MEMORY_START, INITRD_SIZE); 334 reserve_bootmem_node(NODE_DATA(0), INITRD_START+__MEMORY_START, INITRD_SIZE);
335 initrd_start = 335 initrd_start = INITRD_START + PAGE_OFFSET + __MEMORY_START;
336 INITRD_START ? INITRD_START + PAGE_OFFSET + __MEMORY_START : 0;
337 initrd_end = initrd_start + INITRD_SIZE; 336 initrd_end = initrd_start + INITRD_SIZE;
338 } else { 337 } else {
339 printk("initrd extends beyond end of memory " 338 printk("initrd extends beyond end of memory "
diff --git a/arch/sh/kernel/sh_ksyms.c b/arch/sh/kernel/sh_ksyms.c
index c706f3bfd897..ceee79143401 100644
--- a/arch/sh/kernel/sh_ksyms.c
+++ b/arch/sh/kernel/sh_ksyms.c
@@ -99,10 +99,6 @@ EXPORT_SYMBOL(__down_trylock);
99EXPORT_SYMBOL(synchronize_irq); 99EXPORT_SYMBOL(synchronize_irq);
100#endif 100#endif
101 101
102#ifdef CONFIG_PM
103EXPORT_SYMBOL(pm_suspend);
104#endif
105
106EXPORT_SYMBOL(csum_partial); 102EXPORT_SYMBOL(csum_partial);
107#ifdef CONFIG_IPV6 103#ifdef CONFIG_IPV6
108EXPORT_SYMBOL(csum_ipv6_magic); 104EXPORT_SYMBOL(csum_ipv6_magic);
diff --git a/arch/sh/kernel/signal.c b/arch/sh/kernel/signal.c
index 50d7c4993bef..bb1c480a59c7 100644
--- a/arch/sh/kernel/signal.c
+++ b/arch/sh/kernel/signal.c
@@ -23,6 +23,7 @@
23#include <linux/elf.h> 23#include <linux/elf.h>
24#include <linux/personality.h> 24#include <linux/personality.h>
25#include <linux/binfmts.h> 25#include <linux/binfmts.h>
26#include <linux/freezer.h>
26 27
27#include <asm/ucontext.h> 28#include <asm/ucontext.h>
28#include <asm/uaccess.h> 29#include <asm/uaccess.h>
diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c
index 075d6cc1a2d7..deb46941f315 100644
--- a/arch/sh/kernel/vsyscall/vsyscall.c
+++ b/arch/sh/kernel/vsyscall/vsyscall.c
@@ -97,7 +97,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm,
97 goto up_fail; 97 goto up_fail;
98 } 98 }
99 99
100 vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL); 100 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
101 if (!vma) { 101 if (!vma) {
102 ret = -ENOMEM; 102 ret = -ENOMEM;
103 goto up_fail; 103 goto up_fail;
diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c
index 329059d6b54a..cf2c2ee35a37 100644
--- a/arch/sh/mm/hugetlbpage.c
+++ b/arch/sh/mm/hugetlbpage.c
@@ -63,6 +63,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
63 return pte; 63 return pte;
64} 64}
65 65
66int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
67{
68 return 0;
69}
70
66struct page *follow_huge_addr(struct mm_struct *mm, 71struct page *follow_huge_addr(struct mm_struct *mm,
67 unsigned long address, int write) 72 unsigned long address, int write)
68{ 73{
diff --git a/arch/sh/mm/pmb.c b/arch/sh/mm/pmb.c
index 92e745341e4d..b60ad83a7635 100644
--- a/arch/sh/mm/pmb.c
+++ b/arch/sh/mm/pmb.c
@@ -30,7 +30,7 @@
30 30
31#define NR_PMB_ENTRIES 16 31#define NR_PMB_ENTRIES 16
32 32
33static kmem_cache_t *pmb_cache; 33static struct kmem_cache *pmb_cache;
34static unsigned long pmb_map; 34static unsigned long pmb_map;
35 35
36static struct pmb_entry pmb_init_map[] = { 36static struct pmb_entry pmb_init_map[] = {
@@ -283,7 +283,7 @@ void pmb_unmap(unsigned long addr)
283 } while (pmbe); 283 } while (pmbe);
284} 284}
285 285
286static void pmb_cache_ctor(void *pmb, kmem_cache_t *cachep, unsigned long flags) 286static void pmb_cache_ctor(void *pmb, struct kmem_cache *cachep, unsigned long flags)
287{ 287{
288 struct pmb_entry *pmbe = pmb; 288 struct pmb_entry *pmbe = pmb;
289 289
@@ -297,7 +297,7 @@ static void pmb_cache_ctor(void *pmb, kmem_cache_t *cachep, unsigned long flags)
297 spin_unlock_irq(&pmb_list_lock); 297 spin_unlock_irq(&pmb_list_lock);
298} 298}
299 299
300static void pmb_cache_dtor(void *pmb, kmem_cache_t *cachep, unsigned long flags) 300static void pmb_cache_dtor(void *pmb, struct kmem_cache *cachep, unsigned long flags)
301{ 301{
302 spin_lock_irq(&pmb_list_lock); 302 spin_lock_irq(&pmb_list_lock);
303 pmb_list_del(pmb); 303 pmb_list_del(pmb);
diff --git a/arch/sh64/kernel/setup.c b/arch/sh64/kernel/setup.c
index ffb310e33cef..b9e7d54d7b85 100644
--- a/arch/sh64/kernel/setup.c
+++ b/arch/sh64/kernel/setup.c
@@ -243,9 +243,7 @@ void __init setup_arch(char **cmdline_p)
243 if (INITRD_START + INITRD_SIZE <= (PFN_PHYS(last_pfn))) { 243 if (INITRD_START + INITRD_SIZE <= (PFN_PHYS(last_pfn))) {
244 reserve_bootmem_node(NODE_DATA(0), INITRD_START + __MEMORY_START, INITRD_SIZE); 244 reserve_bootmem_node(NODE_DATA(0), INITRD_START + __MEMORY_START, INITRD_SIZE);
245 245
246 initrd_start = 246 initrd_start = (long) INITRD_START + PAGE_OFFSET + __MEMORY_START;
247 (long) INITRD_START ? INITRD_START + PAGE_OFFSET + __MEMORY_START : 0;
248
249 initrd_end = initrd_start + INITRD_SIZE; 247 initrd_end = initrd_start + INITRD_SIZE;
250 } else { 248 } else {
251 printk("initrd extends beyond end of memory " 249 printk("initrd extends beyond end of memory "
diff --git a/arch/sh64/kernel/signal.c b/arch/sh64/kernel/signal.c
index 9e2ffc45c0e0..1666d3efb52e 100644
--- a/arch/sh64/kernel/signal.c
+++ b/arch/sh64/kernel/signal.c
@@ -22,7 +22,7 @@
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/wait.h> 23#include <linux/wait.h>
24#include <linux/personality.h> 24#include <linux/personality.h>
25#include <linux/suspend.h> 25#include <linux/freezer.h>
26#include <linux/ptrace.h> 26#include <linux/ptrace.h>
27#include <linux/unistd.h> 27#include <linux/unistd.h>
28#include <linux/stddef.h> 28#include <linux/stddef.h>
diff --git a/arch/sh64/mm/fault.c b/arch/sh64/mm/fault.c
index 8e2f6c28b739..4f72ab33bb2b 100644
--- a/arch/sh64/mm/fault.c
+++ b/arch/sh64/mm/fault.c
@@ -154,7 +154,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
154 * If we're in an interrupt or have no user 154 * If we're in an interrupt or have no user
155 * context, we must not take the fault.. 155 * context, we must not take the fault..
156 */ 156 */
157 if (in_interrupt() || !mm) 157 if (in_atomic() || !mm)
158 goto no_context; 158 goto no_context;
159 159
160 /* TLB misses upon some cache flushes get done under cli() */ 160 /* TLB misses upon some cache flushes get done under cli() */
diff --git a/arch/sh64/mm/hugetlbpage.c b/arch/sh64/mm/hugetlbpage.c
index 187cf01750b8..4b455f611146 100644
--- a/arch/sh64/mm/hugetlbpage.c
+++ b/arch/sh64/mm/hugetlbpage.c
@@ -53,6 +53,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
53 return pte; 53 return pte;
54} 54}
55 55
56int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
57{
58 return 0;
59}
60
56void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, 61void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
57 pte_t *ptep, pte_t entry) 62 pte_t *ptep, pte_t entry)
58{ 63{
diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
index 5cc5ff7f8824..b73e6b9067ed 100644
--- a/arch/sparc/kernel/vmlinux.lds.S
+++ b/arch/sparc/kernel/vmlinux.lds.S
@@ -11,6 +11,7 @@ SECTIONS
11 . = 0x10000 + SIZEOF_HEADERS; 11 . = 0x10000 + SIZEOF_HEADERS;
12 .text 0xf0004000 : 12 .text 0xf0004000 :
13 { 13 {
14 _text = .;
14 *(.text) 15 *(.text)
15 SCHED_TEXT 16 SCHED_TEXT
16 LOCK_TEXT 17 LOCK_TEXT
diff --git a/arch/sparc/mm/highmem.c b/arch/sparc/mm/highmem.c
index 4d8ed9c65182..01fc6c254292 100644
--- a/arch/sparc/mm/highmem.c
+++ b/arch/sparc/mm/highmem.c
@@ -35,7 +35,7 @@ void *kmap_atomic(struct page *page, enum km_type type)
35 unsigned long vaddr; 35 unsigned long vaddr;
36 36
37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 37 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
38 inc_preempt_count(); 38 pagefault_disable();
39 if (!PageHighMem(page)) 39 if (!PageHighMem(page))
40 return page_address(page); 40 return page_address(page);
41 41
@@ -70,8 +70,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
70 unsigned long idx = type + KM_TYPE_NR*smp_processor_id(); 70 unsigned long idx = type + KM_TYPE_NR*smp_processor_id();
71 71
72 if (vaddr < FIXADDR_START) { // FIXME 72 if (vaddr < FIXADDR_START) { // FIXME
73 dec_preempt_count(); 73 pagefault_enable();
74 preempt_check_resched();
75 return; 74 return;
76 } 75 }
77 76
@@ -97,8 +96,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
97#endif 96#endif
98#endif 97#endif
99 98
100 dec_preempt_count(); 99 pagefault_enable();
101 preempt_check_resched();
102} 100}
103 101
104/* We may be fed a pagetable here by ptep_to_xxx and others. */ 102/* We may be fed a pagetable here by ptep_to_xxx and others. */
diff --git a/arch/sparc64/kernel/binfmt_elf32.c b/arch/sparc64/kernel/binfmt_elf32.c
index a98f3ae175a3..9ad84ff10a17 100644
--- a/arch/sparc64/kernel/binfmt_elf32.c
+++ b/arch/sparc64/kernel/binfmt_elf32.c
@@ -141,7 +141,6 @@ cputime_to_compat_timeval(const cputime_t cputime, struct compat_timeval *value)
141 value->tv_sec = jiffies / HZ; 141 value->tv_sec = jiffies / HZ;
142} 142}
143 143
144#define elf_addr_t u32
145#undef start_thread 144#undef start_thread
146#define start_thread start_thread32 145#define start_thread start_thread32
147#define init_elf_binfmt init_elf32_binfmt 146#define init_elf_binfmt init_elf32_binfmt
diff --git a/arch/sparc64/kernel/vmlinux.lds.S b/arch/sparc64/kernel/vmlinux.lds.S
index bd9de8c2a2aa..4a6063f33e7a 100644
--- a/arch/sparc64/kernel/vmlinux.lds.S
+++ b/arch/sparc64/kernel/vmlinux.lds.S
@@ -13,6 +13,7 @@ SECTIONS
13 . = 0x4000; 13 . = 0x4000;
14 .text 0x0000000000404000 : 14 .text 0x0000000000404000 :
15 { 15 {
16 _text = .;
16 *(.text) 17 *(.text)
17 SCHED_TEXT 18 SCHED_TEXT
18 LOCK_TEXT 19 LOCK_TEXT
diff --git a/arch/sparc64/mm/hugetlbpage.c b/arch/sparc64/mm/hugetlbpage.c
index 53b9b1f528e5..33fd0b265e70 100644
--- a/arch/sparc64/mm/hugetlbpage.c
+++ b/arch/sparc64/mm/hugetlbpage.c
@@ -235,6 +235,11 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
235 return pte; 235 return pte;
236} 236}
237 237
238int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
239{
240 return 0;
241}
242
238void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, 243void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
239 pte_t *ptep, pte_t entry) 244 pte_t *ptep, pte_t entry)
240{ 245{
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 09cb7fccc03a..a8e8802eed4d 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -176,9 +176,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
176 176
177int bigkernel = 0; 177int bigkernel = 0;
178 178
179kmem_cache_t *pgtable_cache __read_mostly; 179struct kmem_cache *pgtable_cache __read_mostly;
180 180
181static void zero_ctor(void *addr, kmem_cache_t *cache, unsigned long flags) 181static void zero_ctor(void *addr, struct kmem_cache *cache, unsigned long flags)
182{ 182{
183 clear_page(addr); 183 clear_page(addr);
184} 184}
diff --git a/arch/sparc64/mm/tsb.c b/arch/sparc64/mm/tsb.c
index beaa02810f0e..236d02f41a01 100644
--- a/arch/sparc64/mm/tsb.c
+++ b/arch/sparc64/mm/tsb.c
@@ -239,7 +239,7 @@ static void setup_tsb_params(struct mm_struct *mm, unsigned long tsb_idx, unsign
239 } 239 }
240} 240}
241 241
242static kmem_cache_t *tsb_caches[8] __read_mostly; 242static struct kmem_cache *tsb_caches[8] __read_mostly;
243 243
244static const char *tsb_cache_names[8] = { 244static const char *tsb_cache_names[8] = {
245 "tsb_8KB", 245 "tsb_8KB",
diff --git a/arch/um/drivers/daemon_kern.c b/arch/um/drivers/daemon_kern.c
index 824386974f88..9c2e7a758f21 100644
--- a/arch/um/drivers/daemon_kern.c
+++ b/arch/um/drivers/daemon_kern.c
@@ -98,4 +98,4 @@ static int register_daemon(void)
98 return 0; 98 return 0;
99} 99}
100 100
101__initcall(register_daemon); 101late_initcall(register_daemon);
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 426633e5d6e3..aa3090d05a8f 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -31,9 +31,9 @@ static irqreturn_t line_interrupt(int irq, void *data)
31 return IRQ_HANDLED; 31 return IRQ_HANDLED;
32} 32}
33 33
34static void line_timer_cb(void *arg) 34static void line_timer_cb(struct work_struct *work)
35{ 35{
36 struct line *line = arg; 36 struct line *line = container_of(work, struct line, task.work);
37 37
38 if(!line->throttled) 38 if(!line->throttled)
39 chan_interrupt(&line->chan_list, &line->task, line->tty, 39 chan_interrupt(&line->chan_list, &line->task, line->tty,
@@ -443,7 +443,7 @@ int line_open(struct line *lines, struct tty_struct *tty)
443 * is registered. 443 * is registered.
444 */ 444 */
445 enable_chan(line); 445 enable_chan(line);
446 INIT_WORK(&line->task, line_timer_cb, line); 446 INIT_DELAYED_WORK(&line->task, line_timer_cb);
447 447
448 if(!line->sigio){ 448 if(!line->sigio){
449 chan_enable_winch(&line->chan_list, tty); 449 chan_enable_winch(&line->chan_list, tty);
diff --git a/arch/um/drivers/mcast_kern.c b/arch/um/drivers/mcast_kern.c
index c090fbd464e7..52ccb7b53cd2 100644
--- a/arch/um/drivers/mcast_kern.c
+++ b/arch/um/drivers/mcast_kern.c
@@ -127,4 +127,4 @@ static int register_mcast(void)
127 return 0; 127 return 0;
128} 128}
129 129
130__initcall(register_mcast); 130late_initcall(register_mcast);
diff --git a/arch/um/drivers/pcap_kern.c b/arch/um/drivers/pcap_kern.c
index 6e1ef8558283..e67362acf0e7 100644
--- a/arch/um/drivers/pcap_kern.c
+++ b/arch/um/drivers/pcap_kern.c
@@ -109,4 +109,4 @@ static int register_pcap(void)
109 return 0; 109 return 0;
110} 110}
111 111
112__initcall(register_pcap); 112late_initcall(register_pcap);
diff --git a/arch/um/drivers/slip_kern.c b/arch/um/drivers/slip_kern.c
index 788da5439a2d..25634bd1f585 100644
--- a/arch/um/drivers/slip_kern.c
+++ b/arch/um/drivers/slip_kern.c
@@ -95,4 +95,4 @@ static int register_slip(void)
95 return 0; 95 return 0;
96} 96}
97 97
98__initcall(register_slip); 98late_initcall(register_slip);
diff --git a/arch/um/drivers/slirp_kern.c b/arch/um/drivers/slirp_kern.c
index ae322e1c8a87..b3ed8fb874ab 100644
--- a/arch/um/drivers/slirp_kern.c
+++ b/arch/um/drivers/slirp_kern.c
@@ -119,4 +119,4 @@ static int register_slirp(void)
119 return 0; 119 return 0;
120} 120}
121 121
122__initcall(register_slirp); 122late_initcall(register_slirp);
diff --git a/arch/um/include/chan_kern.h b/arch/um/include/chan_kern.h
index 572d286ed2c6..9003a343e148 100644
--- a/arch/um/include/chan_kern.h
+++ b/arch/um/include/chan_kern.h
@@ -27,7 +27,7 @@ struct chan {
27 void *data; 27 void *data;
28}; 28};
29 29
30extern void chan_interrupt(struct list_head *chans, struct work_struct *task, 30extern void chan_interrupt(struct list_head *chans, struct delayed_work *task,
31 struct tty_struct *tty, int irq); 31 struct tty_struct *tty, int irq);
32extern int parse_chan_pair(char *str, struct line *line, int device, 32extern int parse_chan_pair(char *str, struct line *line, int device,
33 const struct chan_opts *opts); 33 const struct chan_opts *opts);
diff --git a/arch/um/include/line.h b/arch/um/include/line.h
index 7be24811bb30..214ee76c40df 100644
--- a/arch/um/include/line.h
+++ b/arch/um/include/line.h
@@ -51,7 +51,7 @@ struct line {
51 char *tail; 51 char *tail;
52 52
53 int sigio; 53 int sigio;
54 struct work_struct task; 54 struct delayed_work task;
55 const struct line_driver *driver; 55 const struct line_driver *driver;
56 int have_irq; 56 int have_irq;
57}; 57};
diff --git a/arch/um/include/sysdep-i386/ptrace.h b/arch/um/include/sysdep-i386/ptrace.h
index 6670cc992ecb..52b398bcafcf 100644
--- a/arch/um/include/sysdep-i386/ptrace.h
+++ b/arch/um/include/sysdep-i386/ptrace.h
@@ -75,7 +75,7 @@ union uml_pt_regs {
75#endif 75#endif
76#ifdef UML_CONFIG_MODE_SKAS 76#ifdef UML_CONFIG_MODE_SKAS
77 struct skas_regs { 77 struct skas_regs {
78 unsigned long regs[HOST_FRAME_SIZE]; 78 unsigned long regs[MAX_REG_NR];
79 unsigned long fp[HOST_FP_SIZE]; 79 unsigned long fp[HOST_FP_SIZE];
80 unsigned long xfp[HOST_XFP_SIZE]; 80 unsigned long xfp[HOST_XFP_SIZE];
81 struct faultinfo faultinfo; 81 struct faultinfo faultinfo;
diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/include/sysdep-i386/stub.h
index b492b12b4a10..4fffae75ba53 100644
--- a/arch/um/include/sysdep-i386/stub.h
+++ b/arch/um/include/sysdep-i386/stub.h
@@ -9,6 +9,7 @@
9#include <sys/mman.h> 9#include <sys/mman.h>
10#include <asm/ptrace.h> 10#include <asm/ptrace.h>
11#include <asm/unistd.h> 11#include <asm/unistd.h>
12#include <asm/page.h>
12#include "stub-data.h" 13#include "stub-data.h"
13#include "kern_constants.h" 14#include "kern_constants.h"
14#include "uml-config.h" 15#include "uml-config.h"
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h
index 617bb9efc934..66cb400c2c92 100644
--- a/arch/um/include/sysdep-x86_64/ptrace.h
+++ b/arch/um/include/sysdep-x86_64/ptrace.h
@@ -108,7 +108,7 @@ union uml_pt_regs {
108 * file size, while i386 uses FRAME_SIZE. Therefore, we need 108 * file size, while i386 uses FRAME_SIZE. Therefore, we need
109 * to use UM_FRAME_SIZE here instead of HOST_FRAME_SIZE. 109 * to use UM_FRAME_SIZE here instead of HOST_FRAME_SIZE.
110 */ 110 */
111 unsigned long regs[UM_FRAME_SIZE]; 111 unsigned long regs[MAX_REG_NR];
112 unsigned long fp[HOST_FP_SIZE]; 112 unsigned long fp[HOST_FP_SIZE];
113 struct faultinfo faultinfo; 113 struct faultinfo faultinfo;
114 long syscall; 114 long syscall;
diff --git a/arch/um/os-Linux/drivers/ethertap_kern.c b/arch/um/os-Linux/drivers/ethertap_kern.c
index 16385e2ada85..70541821775f 100644
--- a/arch/um/os-Linux/drivers/ethertap_kern.c
+++ b/arch/um/os-Linux/drivers/ethertap_kern.c
@@ -105,4 +105,4 @@ static int register_ethertap(void)
105 return 0; 105 return 0;
106} 106}
107 107
108__initcall(register_ethertap); 108late_initcall(register_ethertap);
diff --git a/arch/um/os-Linux/drivers/tuntap_kern.c b/arch/um/os-Linux/drivers/tuntap_kern.c
index 0edbac63c527..76570a2c25c3 100644
--- a/arch/um/os-Linux/drivers/tuntap_kern.c
+++ b/arch/um/os-Linux/drivers/tuntap_kern.c
@@ -90,4 +90,4 @@ static int register_tuntap(void)
90 return 0; 90 return 0;
91} 91}
92 92
93__initcall(register_tuntap); 93late_initcall(register_tuntap);
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index e299ee5a753d..49057d8bc668 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -3,7 +3,6 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include "linux/stddef.h"
7#include "linux/sched.h" 6#include "linux/sched.h"
8#include "linux/slab.h" 7#include "linux/slab.h"
9#include "linux/types.h" 8#include "linux/types.h"
diff --git a/arch/um/sys-i386/ptrace_user.c b/arch/um/sys-i386/ptrace_user.c
index 5f3cc6685820..01212c88fcc4 100644
--- a/arch/um/sys-i386/ptrace_user.c
+++ b/arch/um/sys-i386/ptrace_user.c
@@ -4,9 +4,9 @@
4 */ 4 */
5 5
6#include <stdio.h> 6#include <stdio.h>
7#include <stddef.h>
7#include <errno.h> 8#include <errno.h>
8#include <unistd.h> 9#include <unistd.h>
9#include <linux/stddef.h>
10#include "ptrace_user.h" 10#include "ptrace_user.h"
11/* Grr, asm/user.h includes asm/ptrace.h, so has to follow ptrace_user.h */ 11/* Grr, asm/user.h includes asm/ptrace.h, so has to follow ptrace_user.h */
12#include <asm/user.h> 12#include <asm/user.h>
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c
index 6f4ef2b7fa4a..447306b20aea 100644
--- a/arch/um/sys-i386/user-offsets.c
+++ b/arch/um/sys-i386/user-offsets.c
@@ -2,7 +2,7 @@
2#include <signal.h> 2#include <signal.h>
3#include <asm/ptrace.h> 3#include <asm/ptrace.h>
4#include <asm/user.h> 4#include <asm/user.h>
5#include <linux/stddef.h> 5#include <stddef.h>
6#include <sys/poll.h> 6#include <sys/poll.h>
7 7
8#define DEFINE(sym, val) \ 8#define DEFINE(sym, val) \
diff --git a/arch/v850/kernel/vmlinux.lds.S b/arch/v850/kernel/vmlinux.lds.S
index 88d087f527c9..3a5fd07fe064 100644
--- a/arch/v850/kernel/vmlinux.lds.S
+++ b/arch/v850/kernel/vmlinux.lds.S
@@ -90,6 +90,7 @@
90 90
91/* Kernel text segment, and some constant data areas. */ 91/* Kernel text segment, and some constant data areas. */
92#define TEXT_CONTENTS \ 92#define TEXT_CONTENTS \
93 _text = .; \
93 __stext = . ; \ 94 __stext = . ; \
94 *(.text) \ 95 *(.text) \
95 SCHED_TEXT \ 96 SCHED_TEXT \
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 010d2265f1cf..bfbb9bcae123 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -122,7 +122,7 @@ endchoice
122 122
123choice 123choice
124 prompt "Processor family" 124 prompt "Processor family"
125 default MK8 125 default GENERIC_CPU
126 126
127config MK8 127config MK8
128 bool "AMD-Opteron/Athlon64" 128 bool "AMD-Opteron/Athlon64"
@@ -130,16 +130,31 @@ config MK8
130 Optimize for AMD Opteron/Athlon64/Hammer/K8 CPUs. 130 Optimize for AMD Opteron/Athlon64/Hammer/K8 CPUs.
131 131
132config MPSC 132config MPSC
133 bool "Intel EM64T" 133 bool "Intel P4 / older Netburst based Xeon"
134 help 134 help
135 Optimize for Intel Pentium 4 and Xeon CPUs with Intel 135 Optimize for Intel Pentium 4 and older Nocona/Dempsey Xeon CPUs
136 Extended Memory 64 Technology(EM64T). For details see 136 with Intel Extended Memory 64 Technology(EM64T). For details see
137 <http://www.intel.com/technology/64bitextensions/>. 137 <http://www.intel.com/technology/64bitextensions/>.
138 Note the the latest Xeons (Xeon 51xx and 53xx) are not based on the
139 Netburst core and shouldn't use this option. You can distingush them
140 using the cpu family field
141 in /proc/cpuinfo. Family 15 is a older Xeon, Family 6 a newer one
142 (this rule only applies to system that support EM64T)
143
144config MCORE2
145 bool "Intel Core2 / newer Xeon"
146 help
147 Optimize for Intel Core2 and newer Xeons (51xx)
148 You can distingush the newer Xeons from the older ones using
149 the cpu family field in /proc/cpuinfo. 15 is a older Xeon
150 (use CONFIG_MPSC then), 6 is a newer one. This rule only
151 applies to CPUs that support EM64T.
138 152
139config GENERIC_CPU 153config GENERIC_CPU
140 bool "Generic-x86-64" 154 bool "Generic-x86-64"
141 help 155 help
142 Generic x86-64 CPU. 156 Generic x86-64 CPU.
157 Run equally well on all x86-64 CPUs.
143 158
144endchoice 159endchoice
145 160
@@ -149,12 +164,12 @@ endchoice
149config X86_L1_CACHE_BYTES 164config X86_L1_CACHE_BYTES
150 int 165 int
151 default "128" if GENERIC_CPU || MPSC 166 default "128" if GENERIC_CPU || MPSC
152 default "64" if MK8 167 default "64" if MK8 || MCORE2
153 168
154config X86_L1_CACHE_SHIFT 169config X86_L1_CACHE_SHIFT
155 int 170 int
156 default "7" if GENERIC_CPU || MPSC 171 default "7" if GENERIC_CPU || MPSC
157 default "6" if MK8 172 default "6" if MK8 || MCORE2
158 173
159config X86_INTERNODE_CACHE_BYTES 174config X86_INTERNODE_CACHE_BYTES
160 int 175 int
@@ -344,11 +359,6 @@ config ARCH_DISCONTIGMEM_ENABLE
344 depends on NUMA 359 depends on NUMA
345 default y 360 default y
346 361
347
348config ARCH_DISCONTIGMEM_ENABLE
349 def_bool y
350 depends on NUMA
351
352config ARCH_DISCONTIGMEM_DEFAULT 362config ARCH_DISCONTIGMEM_DEFAULT
353 def_bool y 363 def_bool y
354 depends on NUMA 364 depends on NUMA
@@ -455,6 +465,17 @@ config CALGARY_IOMMU
455 Normally the kernel will make the right choice by itself. 465 Normally the kernel will make the right choice by itself.
456 If unsure, say Y. 466 If unsure, say Y.
457 467
468config CALGARY_IOMMU_ENABLED_BY_DEFAULT
469 bool "Should Calgary be enabled by default?"
470 default y
471 depends on CALGARY_IOMMU
472 help
473 Should Calgary be enabled by default? if you choose 'y', Calgary
474 will be used (if it exists). If you choose 'n', Calgary will not be
475 used even if it exists. If you choose 'n' and would like to use
476 Calgary anyway, pass 'iommu=calgary' on the kernel command line.
477 If unsure, say Y.
478
458# need this always selected by IOMMU for the VIA workaround 479# need this always selected by IOMMU for the VIA workaround
459config SWIOTLB 480config SWIOTLB
460 bool 481 bool
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index 6e38d4daeed7..b471b8550d03 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -30,6 +30,10 @@ cflags-y :=
30cflags-kernel-y := 30cflags-kernel-y :=
31cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8) 31cflags-$(CONFIG_MK8) += $(call cc-option,-march=k8)
32cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona) 32cflags-$(CONFIG_MPSC) += $(call cc-option,-march=nocona)
33# gcc doesn't support -march=core2 yet as of gcc 4.3, but I hope it
34# will eventually. Use -mtune=generic as fallback
35cflags-$(CONFIG_MCORE2) += \
36 $(call cc-option,-march=core2,$(call cc-option,-mtune=generic))
33cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic) 37cflags-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=generic)
34 38
35cflags-y += -m64 39cflags-y += -m64
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 0f5d44e86be5..96f226cfb339 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.19-rc2-git4 3# Linux kernel version: 2.6.19-git7
4# Sat Oct 21 03:38:52 2006 4# Wed Dec 6 23:50:47 2006
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -47,13 +47,14 @@ CONFIG_POSIX_MQUEUE=y
47CONFIG_IKCONFIG=y 47CONFIG_IKCONFIG=y
48CONFIG_IKCONFIG_PROC=y 48CONFIG_IKCONFIG_PROC=y
49# CONFIG_CPUSETS is not set 49# CONFIG_CPUSETS is not set
50CONFIG_SYSFS_DEPRECATED=y
50# CONFIG_RELAY is not set 51# CONFIG_RELAY is not set
51CONFIG_INITRAMFS_SOURCE="" 52CONFIG_INITRAMFS_SOURCE=""
52CONFIG_CC_OPTIMIZE_FOR_SIZE=y 53CONFIG_CC_OPTIMIZE_FOR_SIZE=y
53CONFIG_SYSCTL=y 54CONFIG_SYSCTL=y
54# CONFIG_EMBEDDED is not set 55# CONFIG_EMBEDDED is not set
55CONFIG_UID16=y 56CONFIG_UID16=y
56# CONFIG_SYSCTL_SYSCALL is not set 57CONFIG_SYSCTL_SYSCALL=y
57CONFIG_KALLSYMS=y 58CONFIG_KALLSYMS=y
58CONFIG_KALLSYMS_ALL=y 59CONFIG_KALLSYMS_ALL=y
59# CONFIG_KALLSYMS_EXTRA_PASS is not set 60# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -87,9 +88,7 @@ CONFIG_STOP_MACHINE=y
87# Block layer 88# Block layer
88# 89#
89CONFIG_BLOCK=y 90CONFIG_BLOCK=y
90CONFIG_LBD=y
91# CONFIG_BLK_DEV_IO_TRACE is not set 91# CONFIG_BLK_DEV_IO_TRACE is not set
92# CONFIG_LSF is not set
93 92
94# 93#
95# IO Schedulers 94# IO Schedulers
@@ -111,10 +110,11 @@ CONFIG_X86_PC=y
111# CONFIG_X86_VSMP is not set 110# CONFIG_X86_VSMP is not set
112# CONFIG_MK8 is not set 111# CONFIG_MK8 is not set
113# CONFIG_MPSC is not set 112# CONFIG_MPSC is not set
114CONFIG_GENERIC_CPU=y 113CONFIG_MCORE2=y
115CONFIG_X86_L1_CACHE_BYTES=128 114# CONFIG_GENERIC_CPU is not set
116CONFIG_X86_L1_CACHE_SHIFT=7 115CONFIG_X86_L1_CACHE_BYTES=64
117CONFIG_X86_INTERNODE_CACHE_BYTES=128 116CONFIG_X86_L1_CACHE_SHIFT=6
117CONFIG_X86_INTERNODE_CACHE_BYTES=64
118CONFIG_X86_TSC=y 118CONFIG_X86_TSC=y
119CONFIG_X86_GOOD_APIC=y 119CONFIG_X86_GOOD_APIC=y
120# CONFIG_MICROCODE is not set 120# CONFIG_MICROCODE is not set
@@ -322,6 +322,7 @@ CONFIG_INET_TCP_DIAG=y
322# CONFIG_TCP_CONG_ADVANCED is not set 322# CONFIG_TCP_CONG_ADVANCED is not set
323CONFIG_TCP_CONG_CUBIC=y 323CONFIG_TCP_CONG_CUBIC=y
324CONFIG_DEFAULT_TCP_CONG="cubic" 324CONFIG_DEFAULT_TCP_CONG="cubic"
325# CONFIG_TCP_MD5SIG is not set
325CONFIG_IPV6=y 326CONFIG_IPV6=y
326# CONFIG_IPV6_PRIVACY is not set 327# CONFIG_IPV6_PRIVACY is not set
327# CONFIG_IPV6_ROUTER_PREF is not set 328# CONFIG_IPV6_ROUTER_PREF is not set
@@ -624,6 +625,7 @@ CONFIG_SATA_INTEL_COMBINED=y
624# CONFIG_PATA_IT821X is not set 625# CONFIG_PATA_IT821X is not set
625# CONFIG_PATA_JMICRON is not set 626# CONFIG_PATA_JMICRON is not set
626# CONFIG_PATA_TRIFLEX is not set 627# CONFIG_PATA_TRIFLEX is not set
628# CONFIG_PATA_MARVELL is not set
627# CONFIG_PATA_MPIIX is not set 629# CONFIG_PATA_MPIIX is not set
628# CONFIG_PATA_OLDPIIX is not set 630# CONFIG_PATA_OLDPIIX is not set
629# CONFIG_PATA_NETCELL is not set 631# CONFIG_PATA_NETCELL is not set
@@ -795,6 +797,7 @@ CONFIG_BNX2=y
795CONFIG_S2IO=m 797CONFIG_S2IO=m
796# CONFIG_S2IO_NAPI is not set 798# CONFIG_S2IO_NAPI is not set
797# CONFIG_MYRI10GE is not set 799# CONFIG_MYRI10GE is not set
800# CONFIG_NETXEN_NIC is not set
798 801
799# 802#
800# Token Ring devices 803# Token Ring devices
@@ -927,10 +930,6 @@ CONFIG_RTC=y
927# CONFIG_DTLK is not set 930# CONFIG_DTLK is not set
928# CONFIG_R3964 is not set 931# CONFIG_R3964 is not set
929# CONFIG_APPLICOM is not set 932# CONFIG_APPLICOM is not set
930
931#
932# Ftape, the floppy tape device driver
933#
934CONFIG_AGP=y 933CONFIG_AGP=y
935CONFIG_AGP_AMD64=y 934CONFIG_AGP_AMD64=y
936CONFIG_AGP_INTEL=y 935CONFIG_AGP_INTEL=y
@@ -1135,6 +1134,7 @@ CONFIG_USB_DEVICEFS=y
1135# CONFIG_USB_BANDWIDTH is not set 1134# CONFIG_USB_BANDWIDTH is not set
1136# CONFIG_USB_DYNAMIC_MINORS is not set 1135# CONFIG_USB_DYNAMIC_MINORS is not set
1137# CONFIG_USB_SUSPEND is not set 1136# CONFIG_USB_SUSPEND is not set
1137# CONFIG_USB_MULTITHREAD_PROBE is not set
1138# CONFIG_USB_OTG is not set 1138# CONFIG_USB_OTG is not set
1139 1139
1140# 1140#
@@ -1212,6 +1212,7 @@ CONFIG_USB_HIDINPUT=y
1212# CONFIG_USB_KAWETH is not set 1212# CONFIG_USB_KAWETH is not set
1213# CONFIG_USB_PEGASUS is not set 1213# CONFIG_USB_PEGASUS is not set
1214# CONFIG_USB_RTL8150 is not set 1214# CONFIG_USB_RTL8150 is not set
1215# CONFIG_USB_USBNET_MII is not set
1215# CONFIG_USB_USBNET is not set 1216# CONFIG_USB_USBNET is not set
1216CONFIG_USB_MON=y 1217CONFIG_USB_MON=y
1217 1218
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index 82ef182de6ae..543ef4f405e9 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -305,8 +305,6 @@ MODULE_AUTHOR("Eric Youngdale, Andi Kleen");
305#undef MODULE_DESCRIPTION 305#undef MODULE_DESCRIPTION
306#undef MODULE_AUTHOR 306#undef MODULE_AUTHOR
307 307
308#define elf_addr_t __u32
309
310static void elf32_init(struct pt_regs *); 308static void elf32_init(struct pt_regs *);
311 309
312#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 310#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
@@ -351,7 +349,7 @@ int ia32_setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top,
351 bprm->loader += stack_base; 349 bprm->loader += stack_base;
352 bprm->exec += stack_base; 350 bprm->exec += stack_base;
353 351
354 mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 352 mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
355 if (!mpnt) 353 if (!mpnt)
356 return -ENOMEM; 354 return -ENOMEM;
357 355
diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
index 0e0a266d976f..ff499ef2a1ba 100644
--- a/arch/x86_64/ia32/ia32_signal.c
+++ b/arch/x86_64/ia32/ia32_signal.c
@@ -584,6 +584,11 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
584 regs->rdx = (unsigned long) &frame->info; 584 regs->rdx = (unsigned long) &frame->info;
585 regs->rcx = (unsigned long) &frame->uc; 585 regs->rcx = (unsigned long) &frame->uc;
586 586
587 /* Make -mregparm=3 work */
588 regs->rax = sig;
589 regs->rdx = (unsigned long) &frame->info;
590 regs->rcx = (unsigned long) &frame->uc;
591
587 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS)); 592 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS));
588 asm volatile("movl %0,%%es" :: "r" (__USER32_DS)); 593 asm volatile("movl %0,%%es" :: "r" (__USER32_DS));
589 594
diff --git a/arch/x86_64/ia32/syscall32.c b/arch/x86_64/ia32/syscall32.c
index 3a01329473ab..3e5ed20cba45 100644
--- a/arch/x86_64/ia32/syscall32.c
+++ b/arch/x86_64/ia32/syscall32.c
@@ -49,7 +49,7 @@ int syscall32_setup_pages(struct linux_binprm *bprm, int exstack)
49 struct mm_struct *mm = current->mm; 49 struct mm_struct *mm = current->mm;
50 int ret; 50 int ret;
51 51
52 vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 52 vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
53 if (!vma) 53 if (!vma)
54 return -ENOMEM; 54 return -ENOMEM;
55 55
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 4d9d5ed942b2..124b2d27b4ac 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -25,6 +25,7 @@
25#include <linux/kernel_stat.h> 25#include <linux/kernel_stat.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/ioport.h>
28 29
29#include <asm/atomic.h> 30#include <asm/atomic.h>
30#include <asm/smp.h> 31#include <asm/smp.h>
@@ -45,6 +46,12 @@ int apic_calibrate_pmtmr __initdata;
45 46
46int disable_apic_timer __initdata; 47int disable_apic_timer __initdata;
47 48
49static struct resource *ioapic_resources;
50static struct resource lapic_resource = {
51 .name = "Local APIC",
52 .flags = IORESOURCE_MEM | IORESOURCE_BUSY,
53};
54
48/* 55/*
49 * cpu_mask that denotes the CPUs that needs timer interrupt coming in as 56 * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
50 * IPIs in place of local APIC timers 57 * IPIs in place of local APIC timers
@@ -133,7 +140,6 @@ void clear_local_APIC(void)
133 apic_write(APIC_LVTERR, APIC_LVT_MASKED); 140 apic_write(APIC_LVTERR, APIC_LVT_MASKED);
134 if (maxlvt >= 4) 141 if (maxlvt >= 4)
135 apic_write(APIC_LVTPC, APIC_LVT_MASKED); 142 apic_write(APIC_LVTPC, APIC_LVT_MASKED);
136 v = GET_APIC_VERSION(apic_read(APIC_LVR));
137 apic_write(APIC_ESR, 0); 143 apic_write(APIC_ESR, 0);
138 apic_read(APIC_ESR); 144 apic_read(APIC_ESR);
139} 145}
@@ -452,23 +458,30 @@ static struct {
452static int lapic_suspend(struct sys_device *dev, pm_message_t state) 458static int lapic_suspend(struct sys_device *dev, pm_message_t state)
453{ 459{
454 unsigned long flags; 460 unsigned long flags;
461 int maxlvt;
455 462
456 if (!apic_pm_state.active) 463 if (!apic_pm_state.active)
457 return 0; 464 return 0;
458 465
466 maxlvt = get_maxlvt();
467
459 apic_pm_state.apic_id = apic_read(APIC_ID); 468 apic_pm_state.apic_id = apic_read(APIC_ID);
460 apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI); 469 apic_pm_state.apic_taskpri = apic_read(APIC_TASKPRI);
461 apic_pm_state.apic_ldr = apic_read(APIC_LDR); 470 apic_pm_state.apic_ldr = apic_read(APIC_LDR);
462 apic_pm_state.apic_dfr = apic_read(APIC_DFR); 471 apic_pm_state.apic_dfr = apic_read(APIC_DFR);
463 apic_pm_state.apic_spiv = apic_read(APIC_SPIV); 472 apic_pm_state.apic_spiv = apic_read(APIC_SPIV);
464 apic_pm_state.apic_lvtt = apic_read(APIC_LVTT); 473 apic_pm_state.apic_lvtt = apic_read(APIC_LVTT);
465 apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC); 474 if (maxlvt >= 4)
475 apic_pm_state.apic_lvtpc = apic_read(APIC_LVTPC);
466 apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0); 476 apic_pm_state.apic_lvt0 = apic_read(APIC_LVT0);
467 apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1); 477 apic_pm_state.apic_lvt1 = apic_read(APIC_LVT1);
468 apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR); 478 apic_pm_state.apic_lvterr = apic_read(APIC_LVTERR);
469 apic_pm_state.apic_tmict = apic_read(APIC_TMICT); 479 apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
470 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR); 480 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
471 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR); 481#ifdef CONFIG_X86_MCE_INTEL
482 if (maxlvt >= 5)
483 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
484#endif
472 local_irq_save(flags); 485 local_irq_save(flags);
473 disable_local_APIC(); 486 disable_local_APIC();
474 local_irq_restore(flags); 487 local_irq_restore(flags);
@@ -479,10 +492,13 @@ static int lapic_resume(struct sys_device *dev)
479{ 492{
480 unsigned int l, h; 493 unsigned int l, h;
481 unsigned long flags; 494 unsigned long flags;
495 int maxlvt;
482 496
483 if (!apic_pm_state.active) 497 if (!apic_pm_state.active)
484 return 0; 498 return 0;
485 499
500 maxlvt = get_maxlvt();
501
486 local_irq_save(flags); 502 local_irq_save(flags);
487 rdmsr(MSR_IA32_APICBASE, l, h); 503 rdmsr(MSR_IA32_APICBASE, l, h);
488 l &= ~MSR_IA32_APICBASE_BASE; 504 l &= ~MSR_IA32_APICBASE_BASE;
@@ -496,8 +512,12 @@ static int lapic_resume(struct sys_device *dev)
496 apic_write(APIC_SPIV, apic_pm_state.apic_spiv); 512 apic_write(APIC_SPIV, apic_pm_state.apic_spiv);
497 apic_write(APIC_LVT0, apic_pm_state.apic_lvt0); 513 apic_write(APIC_LVT0, apic_pm_state.apic_lvt0);
498 apic_write(APIC_LVT1, apic_pm_state.apic_lvt1); 514 apic_write(APIC_LVT1, apic_pm_state.apic_lvt1);
499 apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr); 515#ifdef CONFIG_X86_MCE_INTEL
500 apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc); 516 if (maxlvt >= 5)
517 apic_write(APIC_LVTTHMR, apic_pm_state.apic_thmr);
518#endif
519 if (maxlvt >= 4)
520 apic_write(APIC_LVTPC, apic_pm_state.apic_lvtpc);
501 apic_write(APIC_LVTT, apic_pm_state.apic_lvtt); 521 apic_write(APIC_LVTT, apic_pm_state.apic_lvtt);
502 apic_write(APIC_TDCR, apic_pm_state.apic_tdcr); 522 apic_write(APIC_TDCR, apic_pm_state.apic_tdcr);
503 apic_write(APIC_TMICT, apic_pm_state.apic_tmict); 523 apic_write(APIC_TMICT, apic_pm_state.apic_tmict);
@@ -585,6 +605,64 @@ static int __init detect_init_APIC (void)
585 return 0; 605 return 0;
586} 606}
587 607
608#ifdef CONFIG_X86_IO_APIC
609static struct resource * __init ioapic_setup_resources(void)
610{
611#define IOAPIC_RESOURCE_NAME_SIZE 11
612 unsigned long n;
613 struct resource *res;
614 char *mem;
615 int i;
616
617 if (nr_ioapics <= 0)
618 return NULL;
619
620 n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
621 n *= nr_ioapics;
622
623 mem = alloc_bootmem(n);
624 res = (void *)mem;
625
626 if (mem != NULL) {
627 memset(mem, 0, n);
628 mem += sizeof(struct resource) * nr_ioapics;
629
630 for (i = 0; i < nr_ioapics; i++) {
631 res[i].name = mem;
632 res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
633 sprintf(mem, "IOAPIC %u", i);
634 mem += IOAPIC_RESOURCE_NAME_SIZE;
635 }
636 }
637
638 ioapic_resources = res;
639
640 return res;
641}
642
643static int __init ioapic_insert_resources(void)
644{
645 int i;
646 struct resource *r = ioapic_resources;
647
648 if (!r) {
649 printk("IO APIC resources could be not be allocated.\n");
650 return -1;
651 }
652
653 for (i = 0; i < nr_ioapics; i++) {
654 insert_resource(&iomem_resource, r);
655 r++;
656 }
657
658 return 0;
659}
660
661/* Insert the IO APIC resources after PCI initialization has occured to handle
662 * IO APICS that are mapped in on a BAR in PCI space. */
663late_initcall(ioapic_insert_resources);
664#endif
665
588void __init init_apic_mappings(void) 666void __init init_apic_mappings(void)
589{ 667{
590 unsigned long apic_phys; 668 unsigned long apic_phys;
@@ -604,6 +682,11 @@ void __init init_apic_mappings(void)
604 apic_mapped = 1; 682 apic_mapped = 1;
605 apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys); 683 apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys);
606 684
685 /* Put local APIC into the resource map. */
686 lapic_resource.start = apic_phys;
687 lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1;
688 insert_resource(&iomem_resource, &lapic_resource);
689
607 /* 690 /*
608 * Fetch the APIC ID of the BSP in case we have a 691 * Fetch the APIC ID of the BSP in case we have a
609 * default configuration (or the MP table is broken). 692 * default configuration (or the MP table is broken).
@@ -613,7 +696,9 @@ void __init init_apic_mappings(void)
613 { 696 {
614 unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0; 697 unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0;
615 int i; 698 int i;
699 struct resource *ioapic_res;
616 700
701 ioapic_res = ioapic_setup_resources();
617 for (i = 0; i < nr_ioapics; i++) { 702 for (i = 0; i < nr_ioapics; i++) {
618 if (smp_found_config) { 703 if (smp_found_config) {
619 ioapic_phys = mp_ioapics[i].mpc_apicaddr; 704 ioapic_phys = mp_ioapics[i].mpc_apicaddr;
@@ -625,6 +710,12 @@ void __init init_apic_mappings(void)
625 apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n", 710 apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n",
626 __fix_to_virt(idx), ioapic_phys); 711 __fix_to_virt(idx), ioapic_phys);
627 idx++; 712 idx++;
713
714 if (ioapic_res != NULL) {
715 ioapic_res->start = ioapic_phys;
716 ioapic_res->end = ioapic_phys + (4 * 1024) - 1;
717 ioapic_res++;
718 }
628 } 719 }
629 } 720 }
630} 721}
@@ -644,10 +735,9 @@ void __init init_apic_mappings(void)
644 735
645static void __setup_APIC_LVTT(unsigned int clocks) 736static void __setup_APIC_LVTT(unsigned int clocks)
646{ 737{
647 unsigned int lvtt_value, tmp_value, ver; 738 unsigned int lvtt_value, tmp_value;
648 int cpu = smp_processor_id(); 739 int cpu = smp_processor_id();
649 740
650 ver = GET_APIC_VERSION(apic_read(APIC_LVR));
651 lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR; 741 lvtt_value = APIC_LVT_TIMER_PERIODIC | LOCAL_TIMER_VECTOR;
652 742
653 if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask)) 743 if (cpu_isset(cpu, timer_interrupt_broadcast_ipi_mask))
diff --git a/arch/x86_64/kernel/crash.c b/arch/x86_64/kernel/crash.c
index 3525f884af82..95a7a2c13131 100644
--- a/arch/x86_64/kernel/crash.c
+++ b/arch/x86_64/kernel/crash.c
@@ -28,71 +28,6 @@
28/* This keeps a track of which one is crashing cpu. */ 28/* This keeps a track of which one is crashing cpu. */
29static int crashing_cpu; 29static int crashing_cpu;
30 30
31static u32 *append_elf_note(u32 *buf, char *name, unsigned type,
32 void *data, size_t data_len)
33{
34 struct elf_note note;
35
36 note.n_namesz = strlen(name) + 1;
37 note.n_descsz = data_len;
38 note.n_type = type;
39 memcpy(buf, &note, sizeof(note));
40 buf += (sizeof(note) +3)/4;
41 memcpy(buf, name, note.n_namesz);
42 buf += (note.n_namesz + 3)/4;
43 memcpy(buf, data, note.n_descsz);
44 buf += (note.n_descsz + 3)/4;
45
46 return buf;
47}
48
49static void final_note(u32 *buf)
50{
51 struct elf_note note;
52
53 note.n_namesz = 0;
54 note.n_descsz = 0;
55 note.n_type = 0;
56 memcpy(buf, &note, sizeof(note));
57}
58
59static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
60{
61 struct elf_prstatus prstatus;
62 u32 *buf;
63
64 if ((cpu < 0) || (cpu >= NR_CPUS))
65 return;
66
67 /* Using ELF notes here is opportunistic.
68 * I need a well defined structure format
69 * for the data I pass, and I need tags
70 * on the data to indicate what information I have
71 * squirrelled away. ELF notes happen to provide
72 * all of that, no need to invent something new.
73 */
74
75 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
76
77 if (!buf)
78 return;
79
80 memset(&prstatus, 0, sizeof(prstatus));
81 prstatus.pr_pid = current->pid;
82 elf_core_copy_regs(&prstatus.pr_reg, regs);
83 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
84 sizeof(prstatus));
85 final_note(buf);
86}
87
88static void crash_save_self(struct pt_regs *regs)
89{
90 int cpu;
91
92 cpu = smp_processor_id();
93 crash_save_this_cpu(regs, cpu);
94}
95
96#ifdef CONFIG_SMP 31#ifdef CONFIG_SMP
97static atomic_t waiting_for_crash_ipi; 32static atomic_t waiting_for_crash_ipi;
98 33
@@ -117,7 +52,7 @@ static int crash_nmi_callback(struct notifier_block *self,
117 return NOTIFY_STOP; 52 return NOTIFY_STOP;
118 local_irq_disable(); 53 local_irq_disable();
119 54
120 crash_save_this_cpu(regs, cpu); 55 crash_save_cpu(regs, cpu);
121 disable_local_APIC(); 56 disable_local_APIC();
122 atomic_dec(&waiting_for_crash_ipi); 57 atomic_dec(&waiting_for_crash_ipi);
123 /* Assume hlt works */ 58 /* Assume hlt works */
@@ -196,5 +131,5 @@ void machine_crash_shutdown(struct pt_regs *regs)
196 131
197 disable_IO_APIC(); 132 disable_IO_APIC();
198 133
199 crash_save_self(regs); 134 crash_save_cpu(regs, smp_processor_id());
200} 135}
diff --git a/arch/x86_64/kernel/early-quirks.c b/arch/x86_64/kernel/early-quirks.c
index 68273bff58cc..829698f6d049 100644
--- a/arch/x86_64/kernel/early-quirks.c
+++ b/arch/x86_64/kernel/early-quirks.c
@@ -69,11 +69,18 @@ static void nvidia_bugs(void)
69 69
70static void ati_bugs(void) 70static void ati_bugs(void)
71{ 71{
72 if (timer_over_8254 == 1) { 72}
73 timer_over_8254 = 0; 73
74 printk(KERN_INFO 74static void intel_bugs(void)
75 "ATI board detected. Disabling timer routing over 8254.\n"); 75{
76 } 76 u16 device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID);
77
78#ifdef CONFIG_SMP
79 if (device == PCI_DEVICE_ID_INTEL_E7320_MCH ||
80 device == PCI_DEVICE_ID_INTEL_E7520_MCH ||
81 device == PCI_DEVICE_ID_INTEL_E7525_MCH)
82 quirk_intel_irqbalance();
83#endif
77} 84}
78 85
79struct chipset { 86struct chipset {
@@ -85,6 +92,7 @@ static struct chipset early_qrk[] = {
85 { PCI_VENDOR_ID_NVIDIA, nvidia_bugs }, 92 { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
86 { PCI_VENDOR_ID_VIA, via_bugs }, 93 { PCI_VENDOR_ID_VIA, via_bugs },
87 { PCI_VENDOR_ID_ATI, ati_bugs }, 94 { PCI_VENDOR_ID_ATI, ati_bugs },
95 { PCI_VENDOR_ID_INTEL, intel_bugs},
88 {} 96 {}
89}; 97};
90 98
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index 7d401b00d822..601d332c4b79 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -230,7 +230,6 @@ ENTRY(system_call)
230 CFI_REL_OFFSET rip,RIP-ARGOFFSET 230 CFI_REL_OFFSET rip,RIP-ARGOFFSET
231 GET_THREAD_INFO(%rcx) 231 GET_THREAD_INFO(%rcx)
232 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%rcx) 232 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP),threadinfo_flags(%rcx)
233 CFI_REMEMBER_STATE
234 jnz tracesys 233 jnz tracesys
235 cmpq $__NR_syscall_max,%rax 234 cmpq $__NR_syscall_max,%rax
236 ja badsys 235 ja badsys
@@ -241,7 +240,6 @@ ENTRY(system_call)
241 * Syscall return path ending with SYSRET (fast path) 240 * Syscall return path ending with SYSRET (fast path)
242 * Has incomplete stack frame and undefined top of stack. 241 * Has incomplete stack frame and undefined top of stack.
243 */ 242 */
244 .globl ret_from_sys_call
245ret_from_sys_call: 243ret_from_sys_call:
246 movl $_TIF_ALLWORK_MASK,%edi 244 movl $_TIF_ALLWORK_MASK,%edi
247 /* edi: flagmask */ 245 /* edi: flagmask */
@@ -251,8 +249,8 @@ sysret_check:
251 TRACE_IRQS_OFF 249 TRACE_IRQS_OFF
252 movl threadinfo_flags(%rcx),%edx 250 movl threadinfo_flags(%rcx),%edx
253 andl %edi,%edx 251 andl %edi,%edx
254 CFI_REMEMBER_STATE
255 jnz sysret_careful 252 jnz sysret_careful
253 CFI_REMEMBER_STATE
256 /* 254 /*
257 * sysretq will re-enable interrupts: 255 * sysretq will re-enable interrupts:
258 */ 256 */
@@ -265,10 +263,10 @@ sysret_check:
265 swapgs 263 swapgs
266 sysretq 264 sysretq
267 265
266 CFI_RESTORE_STATE
268 /* Handle reschedules */ 267 /* Handle reschedules */
269 /* edx: work, edi: workmask */ 268 /* edx: work, edi: workmask */
270sysret_careful: 269sysret_careful:
271 CFI_RESTORE_STATE
272 bt $TIF_NEED_RESCHED,%edx 270 bt $TIF_NEED_RESCHED,%edx
273 jnc sysret_signal 271 jnc sysret_signal
274 TRACE_IRQS_ON 272 TRACE_IRQS_ON
@@ -306,7 +304,6 @@ badsys:
306 304
307 /* Do syscall tracing */ 305 /* Do syscall tracing */
308tracesys: 306tracesys:
309 CFI_RESTORE_STATE
310 SAVE_REST 307 SAVE_REST
311 movq $-ENOSYS,RAX(%rsp) 308 movq $-ENOSYS,RAX(%rsp)
312 FIXUP_TOP_OF_STACK %rdi 309 FIXUP_TOP_OF_STACK %rdi
@@ -322,32 +319,13 @@ tracesys:
322 call *sys_call_table(,%rax,8) 319 call *sys_call_table(,%rax,8)
3231: movq %rax,RAX-ARGOFFSET(%rsp) 3201: movq %rax,RAX-ARGOFFSET(%rsp)
324 /* Use IRET because user could have changed frame */ 321 /* Use IRET because user could have changed frame */
325 jmp int_ret_from_sys_call
326 CFI_ENDPROC
327END(system_call)
328 322
329/* 323/*
330 * Syscall return path ending with IRET. 324 * Syscall return path ending with IRET.
331 * Has correct top of stack, but partial stack frame. 325 * Has correct top of stack, but partial stack frame.
332 */ 326 */
333ENTRY(int_ret_from_sys_call) 327 .globl int_ret_from_sys_call
334 CFI_STARTPROC simple 328int_ret_from_sys_call:
335 CFI_SIGNAL_FRAME
336 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
337 /*CFI_REL_OFFSET ss,SS-ARGOFFSET*/
338 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
339 /*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
340 /*CFI_REL_OFFSET cs,CS-ARGOFFSET*/
341 CFI_REL_OFFSET rip,RIP-ARGOFFSET
342 CFI_REL_OFFSET rdx,RDX-ARGOFFSET
343 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
344 CFI_REL_OFFSET rax,RAX-ARGOFFSET
345 CFI_REL_OFFSET rdi,RDI-ARGOFFSET
346 CFI_REL_OFFSET rsi,RSI-ARGOFFSET
347 CFI_REL_OFFSET r8,R8-ARGOFFSET
348 CFI_REL_OFFSET r9,R9-ARGOFFSET
349 CFI_REL_OFFSET r10,R10-ARGOFFSET
350 CFI_REL_OFFSET r11,R11-ARGOFFSET
351 cli 329 cli
352 TRACE_IRQS_OFF 330 TRACE_IRQS_OFF
353 testl $3,CS-ARGOFFSET(%rsp) 331 testl $3,CS-ARGOFFSET(%rsp)
@@ -394,8 +372,6 @@ int_very_careful:
394 popq %rdi 372 popq %rdi
395 CFI_ADJUST_CFA_OFFSET -8 373 CFI_ADJUST_CFA_OFFSET -8
396 andl $~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edi 374 andl $~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP),%edi
397 cli
398 TRACE_IRQS_OFF
399 jmp int_restore_rest 375 jmp int_restore_rest
400 376
401int_signal: 377int_signal:
@@ -411,7 +387,7 @@ int_restore_rest:
411 TRACE_IRQS_OFF 387 TRACE_IRQS_OFF
412 jmp int_with_check 388 jmp int_with_check
413 CFI_ENDPROC 389 CFI_ENDPROC
414END(int_ret_from_sys_call) 390END(system_call)
415 391
416/* 392/*
417 * Certain special system calls that need to save a complete full stack frame. 393 * Certain special system calls that need to save a complete full stack frame.
diff --git a/arch/x86_64/kernel/genapic.c b/arch/x86_64/kernel/genapic.c
index 8e78a75d1866..b007433f96bb 100644
--- a/arch/x86_64/kernel/genapic.c
+++ b/arch/x86_64/kernel/genapic.c
@@ -33,7 +33,7 @@ extern struct genapic apic_flat;
33extern struct genapic apic_physflat; 33extern struct genapic apic_physflat;
34 34
35struct genapic *genapic = &apic_flat; 35struct genapic *genapic = &apic_flat;
36 36struct genapic *genapic_force;
37 37
38/* 38/*
39 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode. 39 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
@@ -46,6 +46,13 @@ void __init clustered_apic_check(void)
46 u8 cluster_cnt[NUM_APIC_CLUSTERS]; 46 u8 cluster_cnt[NUM_APIC_CLUSTERS];
47 int max_apic = 0; 47 int max_apic = 0;
48 48
49 /* genapic selection can be forced because of certain quirks.
50 */
51 if (genapic_force) {
52 genapic = genapic_force;
53 goto print;
54 }
55
49#if defined(CONFIG_ACPI) 56#if defined(CONFIG_ACPI)
50 /* 57 /*
51 * Some x86_64 machines use physical APIC mode regardless of how many 58 * Some x86_64 machines use physical APIC mode regardless of how many
diff --git a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
index 9561eb3c5b5c..cc230b93cd1c 100644
--- a/arch/x86_64/kernel/head64.c
+++ b/arch/x86_64/kernel/head64.c
@@ -57,10 +57,12 @@ void __init x86_64_start_kernel(char * real_mode_data)
57{ 57{
58 int i; 58 int i;
59 59
60 for (i = 0; i < 256; i++) 60 /* clear bss before set_intr_gate with early_idt_handler */
61 clear_bss();
62
63 for (i = 0; i < IDT_ENTRIES; i++)
61 set_intr_gate(i, early_idt_handler); 64 set_intr_gate(i, early_idt_handler);
62 asm volatile("lidt %0" :: "m" (idt_descr)); 65 asm volatile("lidt %0" :: "m" (idt_descr));
63 clear_bss();
64 66
65 early_printk("Kernel alive\n"); 67 early_printk("Kernel alive\n");
66 68
diff --git a/arch/x86_64/kernel/i387.c b/arch/x86_64/kernel/i387.c
index 3aa1e9bb781d..1d58c13bc6bc 100644
--- a/arch/x86_64/kernel/i387.c
+++ b/arch/x86_64/kernel/i387.c
@@ -82,11 +82,8 @@ int save_i387(struct _fpstate __user *buf)
82 struct task_struct *tsk = current; 82 struct task_struct *tsk = current;
83 int err = 0; 83 int err = 0;
84 84
85 { 85 BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
86 extern void bad_user_i387_struct(void); 86 sizeof(tsk->thread.i387.fxsave));
87 if (sizeof(struct user_i387_struct) != sizeof(tsk->thread.i387.fxsave))
88 bad_user_i387_struct();
89 }
90 87
91 if ((unsigned long)buf % 16) 88 if ((unsigned long)buf % 16)
92 printk("save_i387: bad fpstate %p\n",buf); 89 printk("save_i387: bad fpstate %p\n",buf);
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index c4ef801b765b..d73c79e821f1 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -76,7 +76,8 @@ BUILD_16_IRQS(0xc) BUILD_16_IRQS(0xd) BUILD_16_IRQS(0xe) BUILD_16_IRQS(0xf)
76 IRQ(x,8), IRQ(x,9), IRQ(x,a), IRQ(x,b), \ 76 IRQ(x,8), IRQ(x,9), IRQ(x,a), IRQ(x,b), \
77 IRQ(x,c), IRQ(x,d), IRQ(x,e), IRQ(x,f) 77 IRQ(x,c), IRQ(x,d), IRQ(x,e), IRQ(x,f)
78 78
79void (*interrupt[NR_IRQS])(void) = { 79/* for the irq vectors */
80static void (*interrupt[NR_VECTORS - FIRST_EXTERNAL_VECTOR])(void) = {
80 IRQLIST_16(0x2), IRQLIST_16(0x3), 81 IRQLIST_16(0x2), IRQLIST_16(0x3),
81 IRQLIST_16(0x4), IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7), 82 IRQLIST_16(0x4), IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7),
82 IRQLIST_16(0x8), IRQLIST_16(0x9), IRQLIST_16(0xa), IRQLIST_16(0xb), 83 IRQLIST_16(0x8), IRQLIST_16(0x9), IRQLIST_16(0xa), IRQLIST_16(0xb),
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index c80081a6ba41..2a1dcd5f69c2 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -55,10 +55,6 @@ int sis_apic_bug; /* not actually supported, dummy for compile */
55 55
56static int no_timer_check; 56static int no_timer_check;
57 57
58static int disable_timer_pin_1 __initdata;
59
60int timer_over_8254 __initdata = 1;
61
62/* Where if anywhere is the i8259 connect in external int mode */ 58/* Where if anywhere is the i8259 connect in external int mode */
63static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; 59static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
64 60
@@ -178,14 +174,20 @@ static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
178 * the interrupt, and we need to make sure the entry is fully populated 174 * the interrupt, and we need to make sure the entry is fully populated
179 * before that happens. 175 * before that happens.
180 */ 176 */
181static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) 177static void
178__ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
182{ 179{
183 unsigned long flags;
184 union entry_union eu; 180 union entry_union eu;
185 eu.entry = e; 181 eu.entry = e;
186 spin_lock_irqsave(&ioapic_lock, flags);
187 io_apic_write(apic, 0x11 + 2*pin, eu.w2); 182 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
188 io_apic_write(apic, 0x10 + 2*pin, eu.w1); 183 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
184}
185
186static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
187{
188 unsigned long flags;
189 spin_lock_irqsave(&ioapic_lock, flags);
190 __ioapic_write_entry(apic, pin, e);
189 spin_unlock_irqrestore(&ioapic_lock, flags); 191 spin_unlock_irqrestore(&ioapic_lock, flags);
190} 192}
191 193
@@ -348,29 +350,6 @@ static int __init disable_ioapic_setup(char *str)
348} 350}
349early_param("noapic", disable_ioapic_setup); 351early_param("noapic", disable_ioapic_setup);
350 352
351/* Actually the next is obsolete, but keep it for paranoid reasons -AK */
352static int __init disable_timer_pin_setup(char *arg)
353{
354 disable_timer_pin_1 = 1;
355 return 1;
356}
357__setup("disable_timer_pin_1", disable_timer_pin_setup);
358
359static int __init setup_disable_8254_timer(char *s)
360{
361 timer_over_8254 = -1;
362 return 1;
363}
364static int __init setup_enable_8254_timer(char *s)
365{
366 timer_over_8254 = 2;
367 return 1;
368}
369
370__setup("disable_8254_timer", setup_disable_8254_timer);
371__setup("enable_8254_timer", setup_enable_8254_timer);
372
373
374/* 353/*
375 * Find the IRQ entry number of a certain pin. 354 * Find the IRQ entry number of a certain pin.
376 */ 355 */
@@ -750,6 +729,22 @@ static int assign_irq_vector(int irq, cpumask_t mask, cpumask_t *result)
750 return vector; 729 return vector;
751} 730}
752 731
732static void __clear_irq_vector(int irq)
733{
734 cpumask_t mask;
735 int cpu, vector;
736
737 BUG_ON(!irq_vector[irq]);
738
739 vector = irq_vector[irq];
740 cpus_and(mask, irq_domain[irq], cpu_online_map);
741 for_each_cpu_mask(cpu, mask)
742 per_cpu(vector_irq, cpu)[vector] = -1;
743
744 irq_vector[irq] = 0;
745 irq_domain[irq] = CPU_MASK_NONE;
746}
747
753void __setup_vector_irq(int cpu) 748void __setup_vector_irq(int cpu)
754{ 749{
755 /* Initialize vector_irq on a new cpu */ 750 /* Initialize vector_irq on a new cpu */
@@ -794,27 +789,65 @@ static void ioapic_register_intr(int irq, int vector, unsigned long trigger)
794 handle_edge_irq, "edge"); 789 handle_edge_irq, "edge");
795 } 790 }
796} 791}
797 792static void __init setup_IO_APIC_irq(int apic, int pin, int idx, int irq)
798static void __init setup_IO_APIC_irqs(void)
799{ 793{
800 struct IO_APIC_route_entry entry; 794 struct IO_APIC_route_entry entry;
801 int apic, pin, idx, irq, first_notcon = 1, vector; 795 int vector;
802 unsigned long flags; 796 unsigned long flags;
803 797
804 apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
805 798
806 for (apic = 0; apic < nr_ioapics; apic++) { 799 /*
807 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { 800 * add it to the IO-APIC irq-routing table:
801 */
802 memset(&entry,0,sizeof(entry));
808 803
809 /* 804 entry.delivery_mode = INT_DELIVERY_MODE;
810 * add it to the IO-APIC irq-routing table: 805 entry.dest_mode = INT_DEST_MODE;
811 */ 806 entry.mask = 0; /* enable IRQ */
812 memset(&entry,0,sizeof(entry)); 807 entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
808
809 entry.trigger = irq_trigger(idx);
810 entry.polarity = irq_polarity(idx);
813 811
814 entry.delivery_mode = INT_DELIVERY_MODE; 812 if (irq_trigger(idx)) {
815 entry.dest_mode = INT_DEST_MODE; 813 entry.trigger = 1;
816 entry.mask = 0; /* enable IRQ */ 814 entry.mask = 1;
817 entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS); 815 entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
816 }
817
818 if (!apic && !IO_APIC_IRQ(irq))
819 return;
820
821 if (IO_APIC_IRQ(irq)) {
822 cpumask_t mask;
823 vector = assign_irq_vector(irq, TARGET_CPUS, &mask);
824 if (vector < 0)
825 return;
826
827 entry.dest.logical.logical_dest = cpu_mask_to_apicid(mask);
828 entry.vector = vector;
829
830 ioapic_register_intr(irq, vector, IOAPIC_AUTO);
831 if (!apic && (irq < 16))
832 disable_8259A_irq(irq);
833 }
834
835 ioapic_write_entry(apic, pin, entry);
836
837 spin_lock_irqsave(&ioapic_lock, flags);
838 set_native_irq_info(irq, TARGET_CPUS);
839 spin_unlock_irqrestore(&ioapic_lock, flags);
840
841}
842
843static void __init setup_IO_APIC_irqs(void)
844{
845 int apic, pin, idx, irq, first_notcon = 1;
846
847 apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
848
849 for (apic = 0; apic < nr_ioapics; apic++) {
850 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
818 851
819 idx = find_irq_entry(apic,pin,mp_INT); 852 idx = find_irq_entry(apic,pin,mp_INT);
820 if (idx == -1) { 853 if (idx == -1) {
@@ -826,39 +859,11 @@ static void __init setup_IO_APIC_irqs(void)
826 continue; 859 continue;
827 } 860 }
828 861
829 entry.trigger = irq_trigger(idx);
830 entry.polarity = irq_polarity(idx);
831
832 if (irq_trigger(idx)) {
833 entry.trigger = 1;
834 entry.mask = 1;
835 entry.dest.logical.logical_dest = cpu_mask_to_apicid(TARGET_CPUS);
836 }
837
838 irq = pin_2_irq(idx, apic, pin); 862 irq = pin_2_irq(idx, apic, pin);
839 add_pin_to_irq(irq, apic, pin); 863 add_pin_to_irq(irq, apic, pin);
840 864
841 if (!apic && !IO_APIC_IRQ(irq)) 865 setup_IO_APIC_irq(apic, pin, idx, irq);
842 continue;
843
844 if (IO_APIC_IRQ(irq)) {
845 cpumask_t mask;
846 vector = assign_irq_vector(irq, TARGET_CPUS, &mask);
847 if (vector < 0)
848 continue;
849
850 entry.dest.logical.logical_dest = cpu_mask_to_apicid(mask);
851 entry.vector = vector;
852
853 ioapic_register_intr(irq, vector, IOAPIC_AUTO);
854 if (!apic && (irq < 16))
855 disable_8259A_irq(irq);
856 }
857 ioapic_write_entry(apic, pin, entry);
858 866
859 spin_lock_irqsave(&ioapic_lock, flags);
860 set_native_irq_info(irq, TARGET_CPUS);
861 spin_unlock_irqrestore(&ioapic_lock, flags);
862 } 867 }
863 } 868 }
864 869
@@ -1563,10 +1568,33 @@ static inline void unlock_ExtINT_logic(void)
1563 * a wide range of boards and BIOS bugs. Fortunately only the timer IRQ 1568 * a wide range of boards and BIOS bugs. Fortunately only the timer IRQ
1564 * is so screwy. Thanks to Brian Perkins for testing/hacking this beast 1569 * is so screwy. Thanks to Brian Perkins for testing/hacking this beast
1565 * fanatically on his truly buggy board. 1570 * fanatically on his truly buggy board.
1566 *
1567 * FIXME: really need to revamp this for modern platforms only.
1568 */ 1571 */
1569static inline void check_timer(void) 1572
1573static int try_apic_pin(int apic, int pin, char *msg)
1574{
1575 apic_printk(APIC_VERBOSE, KERN_INFO
1576 "..TIMER: trying IO-APIC=%d PIN=%d %s",
1577 apic, pin, msg);
1578
1579 /*
1580 * Ok, does IRQ0 through the IOAPIC work?
1581 */
1582 if (!no_timer_check && timer_irq_works()) {
1583 nmi_watchdog_default();
1584 if (nmi_watchdog == NMI_IO_APIC) {
1585 disable_8259A_irq(0);
1586 setup_nmi();
1587 enable_8259A_irq(0);
1588 }
1589 return 1;
1590 }
1591 clear_IO_APIC_pin(apic, pin);
1592 apic_printk(APIC_QUIET, KERN_ERR " .. failed\n");
1593 return 0;
1594}
1595
1596/* The function from hell */
1597static void check_timer(void)
1570{ 1598{
1571 int apic1, pin1, apic2, pin2; 1599 int apic1, pin1, apic2, pin2;
1572 int vector; 1600 int vector;
@@ -1587,61 +1615,43 @@ static inline void check_timer(void)
1587 */ 1615 */
1588 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT); 1616 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
1589 init_8259A(1); 1617 init_8259A(1);
1590 if (timer_over_8254 > 0)
1591 enable_8259A_irq(0);
1592 1618
1593 pin1 = find_isa_irq_pin(0, mp_INT); 1619 pin1 = find_isa_irq_pin(0, mp_INT);
1594 apic1 = find_isa_irq_apic(0, mp_INT); 1620 apic1 = find_isa_irq_apic(0, mp_INT);
1595 pin2 = ioapic_i8259.pin; 1621 pin2 = ioapic_i8259.pin;
1596 apic2 = ioapic_i8259.apic; 1622 apic2 = ioapic_i8259.apic;
1597 1623
1598 apic_printk(APIC_VERBOSE,KERN_INFO "..TIMER: vector=0x%02X apic1=%d pin1=%d apic2=%d pin2=%d\n", 1624 /* Do this first, otherwise we get double interrupts on ATI boards */
1599 vector, apic1, pin1, apic2, pin2); 1625 if ((pin1 != -1) && try_apic_pin(apic1, pin1,"with 8259 IRQ0 disabled"))
1626 return;
1600 1627
1601 if (pin1 != -1) { 1628 /* Now try again with IRQ0 8259A enabled.
1602 /* 1629 Assumes timer is on IO-APIC 0 ?!? */
1603 * Ok, does IRQ0 through the IOAPIC work? 1630 enable_8259A_irq(0);
1604 */ 1631 unmask_IO_APIC_irq(0);
1605 unmask_IO_APIC_irq(0); 1632 if (try_apic_pin(apic1, pin1, "with 8259 IRQ0 enabled"))
1606 if (!no_timer_check && timer_irq_works()) { 1633 return;
1607 nmi_watchdog_default(); 1634 disable_8259A_irq(0);
1608 if (nmi_watchdog == NMI_IO_APIC) { 1635
1609 disable_8259A_irq(0); 1636 /* Always try pin0 and pin2 on APIC 0 to handle buggy timer overrides
1610 setup_nmi(); 1637 on Nvidia boards */
1611 enable_8259A_irq(0); 1638 if (!(apic1 == 0 && pin1 == 0) &&
1612 } 1639 try_apic_pin(0, 0, "fallback with 8259 IRQ0 disabled"))
1613 if (disable_timer_pin_1 > 0) 1640 return;
1614 clear_IO_APIC_pin(0, pin1); 1641 if (!(apic1 == 0 && pin1 == 2) &&
1615 return; 1642 try_apic_pin(0, 2, "fallback with 8259 IRQ0 disabled"))
1616 } 1643 return;
1617 clear_IO_APIC_pin(apic1, pin1);
1618 apic_printk(APIC_QUIET,KERN_ERR "..MP-BIOS bug: 8254 timer not "
1619 "connected to IO-APIC\n");
1620 }
1621 1644
1622 apic_printk(APIC_VERBOSE,KERN_INFO "...trying to set up timer (IRQ0) " 1645 /* Then try pure 8259A routing on the 8259 as reported by BIOS*/
1623 "through the 8259A ... "); 1646 enable_8259A_irq(0);
1624 if (pin2 != -1) { 1647 if (pin2 != -1) {
1625 apic_printk(APIC_VERBOSE,"\n..... (found apic %d pin %d) ...",
1626 apic2, pin2);
1627 /*
1628 * legacy devices should be connected to IO APIC #0
1629 */
1630 setup_ExtINT_IRQ0_pin(apic2, pin2, vector); 1648 setup_ExtINT_IRQ0_pin(apic2, pin2, vector);
1631 if (timer_irq_works()) { 1649 if (try_apic_pin(apic2,pin2,"8259A broadcast ExtINT from BIOS"))
1632 apic_printk(APIC_VERBOSE," works.\n");
1633 nmi_watchdog_default();
1634 if (nmi_watchdog == NMI_IO_APIC) {
1635 setup_nmi();
1636 }
1637 return; 1650 return;
1638 }
1639 /*
1640 * Cleanup, just in case ...
1641 */
1642 clear_IO_APIC_pin(apic2, pin2);
1643 } 1651 }
1644 apic_printk(APIC_VERBOSE," failed.\n"); 1652
1653 /* Tried all possibilities to go through the IO-APIC. Now come the
1654 really cheesy fallbacks. */
1645 1655
1646 if (nmi_watchdog == NMI_IO_APIC) { 1656 if (nmi_watchdog == NMI_IO_APIC) {
1647 printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n"); 1657 printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n");
@@ -1837,7 +1847,7 @@ void destroy_irq(unsigned int irq)
1837 dynamic_irq_cleanup(irq); 1847 dynamic_irq_cleanup(irq);
1838 1848
1839 spin_lock_irqsave(&vector_lock, flags); 1849 spin_lock_irqsave(&vector_lock, flags);
1840 irq_vector[irq] = 0; 1850 __clear_irq_vector(irq);
1841 spin_unlock_irqrestore(&vector_lock, flags); 1851 spin_unlock_irqrestore(&vector_lock, flags);
1842} 1852}
1843 1853
@@ -2139,7 +2149,15 @@ void __init setup_ioapic_dest(void)
2139 if (irq_entry == -1) 2149 if (irq_entry == -1)
2140 continue; 2150 continue;
2141 irq = pin_2_irq(irq_entry, ioapic, pin); 2151 irq = pin_2_irq(irq_entry, ioapic, pin);
2142 set_ioapic_affinity_irq(irq, TARGET_CPUS); 2152
2153 /* setup_IO_APIC_irqs could fail to get vector for some device
2154 * when you have too many devices, because at that time only boot
2155 * cpu is online.
2156 */
2157 if(!irq_vector[irq])
2158 setup_IO_APIC_irq(ioapic, pin, irq_entry, irq);
2159 else
2160 set_ioapic_affinity_irq(irq, TARGET_CPUS);
2143 } 2161 }
2144 2162
2145 } 2163 }
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
index e46c55856d40..0c06af6c13bc 100644
--- a/arch/x86_64/kernel/irq.c
+++ b/arch/x86_64/kernel/irq.c
@@ -120,7 +120,7 @@ asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
120 120
121 if (likely(irq < NR_IRQS)) 121 if (likely(irq < NR_IRQS))
122 generic_handle_irq(irq); 122 generic_handle_irq(irq);
123 else 123 else if (printk_ratelimit())
124 printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n", 124 printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n",
125 __func__, smp_processor_id(), vector); 125 __func__, smp_processor_id(), vector);
126 126
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index ac241567e682..209c8c0bec71 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -224,7 +224,7 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
224void __kprobes arch_remove_kprobe(struct kprobe *p) 224void __kprobes arch_remove_kprobe(struct kprobe *p)
225{ 225{
226 mutex_lock(&kprobe_mutex); 226 mutex_lock(&kprobe_mutex);
227 free_insn_slot(p->ainsn.insn); 227 free_insn_slot(p->ainsn.insn, 0);
228 mutex_unlock(&kprobe_mutex); 228 mutex_unlock(&kprobe_mutex);
229} 229}
230 230
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index c7587fc39015..ac085038af29 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -641,7 +641,6 @@ static __cpuinit int mce_create_device(unsigned int cpu)
641 return err; 641 return err;
642} 642}
643 643
644#ifdef CONFIG_HOTPLUG_CPU
645static void mce_remove_device(unsigned int cpu) 644static void mce_remove_device(unsigned int cpu)
646{ 645{
647 int i; 646 int i;
@@ -652,6 +651,7 @@ static void mce_remove_device(unsigned int cpu)
652 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_tolerant); 651 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_tolerant);
653 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_check_interval); 652 sysdev_remove_file(&per_cpu(device_mce,cpu), &attr_check_interval);
654 sysdev_unregister(&per_cpu(device_mce,cpu)); 653 sysdev_unregister(&per_cpu(device_mce,cpu));
654 memset(&per_cpu(device_mce, cpu).kobj, 0, sizeof(struct kobject));
655} 655}
656 656
657/* Get notified when a cpu comes on/off. Be hotplug friendly. */ 657/* Get notified when a cpu comes on/off. Be hotplug friendly. */
@@ -674,7 +674,6 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
674static struct notifier_block mce_cpu_notifier = { 674static struct notifier_block mce_cpu_notifier = {
675 .notifier_call = mce_cpu_callback, 675 .notifier_call = mce_cpu_callback,
676}; 676};
677#endif
678 677
679static __init int mce_init_device(void) 678static __init int mce_init_device(void)
680{ 679{
diff --git a/arch/x86_64/kernel/mce_amd.c b/arch/x86_64/kernel/mce_amd.c
index 883fe747f64c..fa09debad4b7 100644
--- a/arch/x86_64/kernel/mce_amd.c
+++ b/arch/x86_64/kernel/mce_amd.c
@@ -551,7 +551,6 @@ out:
551 return err; 551 return err;
552} 552}
553 553
554#ifdef CONFIG_HOTPLUG_CPU
555/* 554/*
556 * let's be hotplug friendly. 555 * let's be hotplug friendly.
557 * in case of multiple core processors, the first core always takes ownership 556 * in case of multiple core processors, the first core always takes ownership
@@ -594,12 +593,14 @@ static void threshold_remove_bank(unsigned int cpu, int bank)
594 593
595 sprintf(name, "threshold_bank%i", bank); 594 sprintf(name, "threshold_bank%i", bank);
596 595
596#ifdef CONFIG_SMP
597 /* sibling symlink */ 597 /* sibling symlink */
598 if (shared_bank[bank] && b->blocks->cpu != cpu) { 598 if (shared_bank[bank] && b->blocks->cpu != cpu) {
599 sysfs_remove_link(&per_cpu(device_mce, cpu).kobj, name); 599 sysfs_remove_link(&per_cpu(device_mce, cpu).kobj, name);
600 per_cpu(threshold_banks, cpu)[bank] = NULL; 600 per_cpu(threshold_banks, cpu)[bank] = NULL;
601 return; 601 return;
602 } 602 }
603#endif
603 604
604 /* remove all sibling symlinks before unregistering */ 605 /* remove all sibling symlinks before unregistering */
605 for_each_cpu_mask(i, b->cpus) { 606 for_each_cpu_mask(i, b->cpus) {
@@ -656,7 +657,6 @@ static int threshold_cpu_callback(struct notifier_block *nfb,
656static struct notifier_block threshold_cpu_notifier = { 657static struct notifier_block threshold_cpu_notifier = {
657 .notifier_call = threshold_cpu_callback, 658 .notifier_call = threshold_cpu_callback,
658}; 659};
659#endif /* CONFIG_HOTPLUG_CPU */
660 660
661static __init int threshold_init_device(void) 661static __init int threshold_init_device(void)
662{ 662{
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index b147ab19fbd4..08072568847d 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -35,8 +35,6 @@
35int smp_found_config; 35int smp_found_config;
36unsigned int __initdata maxcpus = NR_CPUS; 36unsigned int __initdata maxcpus = NR_CPUS;
37 37
38int acpi_found_madt;
39
40/* 38/*
41 * Various Linux-internal data structures created from the 39 * Various Linux-internal data structures created from the
42 * MP-table. 40 * MP-table.
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 7af9cb3e2d99..27e95e7922c1 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -12,14 +12,15 @@
12 * Mikael Pettersson : PM converted to driver model. Disable/enable API. 12 * Mikael Pettersson : PM converted to driver model. Disable/enable API.
13 */ 13 */
14 14
15#include <linux/nmi.h>
15#include <linux/mm.h> 16#include <linux/mm.h>
16#include <linux/delay.h> 17#include <linux/delay.h>
17#include <linux/interrupt.h> 18#include <linux/interrupt.h>
18#include <linux/module.h> 19#include <linux/module.h>
19#include <linux/sysdev.h> 20#include <linux/sysdev.h>
20#include <linux/nmi.h>
21#include <linux/sysctl.h> 21#include <linux/sysctl.h>
22#include <linux/kprobes.h> 22#include <linux/kprobes.h>
23#include <linux/cpumask.h>
23 24
24#include <asm/smp.h> 25#include <asm/smp.h>
25#include <asm/nmi.h> 26#include <asm/nmi.h>
@@ -41,6 +42,8 @@ int panic_on_unrecovered_nmi;
41static DEFINE_PER_CPU(unsigned, perfctr_nmi_owner); 42static DEFINE_PER_CPU(unsigned, perfctr_nmi_owner);
42static DEFINE_PER_CPU(unsigned, evntsel_nmi_owner[2]); 43static DEFINE_PER_CPU(unsigned, evntsel_nmi_owner[2]);
43 44
45static cpumask_t backtrace_mask = CPU_MASK_NONE;
46
44/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's 47/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's
45 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now) 48 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now)
46 */ 49 */
@@ -782,6 +785,7 @@ int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
782{ 785{
783 int sum; 786 int sum;
784 int touched = 0; 787 int touched = 0;
788 int cpu = smp_processor_id();
785 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk); 789 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
786 u64 dummy; 790 u64 dummy;
787 int rc=0; 791 int rc=0;
@@ -799,6 +803,16 @@ int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
799 touched = 1; 803 touched = 1;
800 } 804 }
801 805
806 if (cpu_isset(cpu, backtrace_mask)) {
807 static DEFINE_SPINLOCK(lock); /* Serialise the printks */
808
809 spin_lock(&lock);
810 printk("NMI backtrace for cpu %d\n", cpu);
811 dump_stack();
812 spin_unlock(&lock);
813 cpu_clear(cpu, backtrace_mask);
814 }
815
802#ifdef CONFIG_X86_MCE 816#ifdef CONFIG_X86_MCE
803 /* Could check oops_in_progress here too, but it's safer 817 /* Could check oops_in_progress here too, but it's safer
804 not too */ 818 not too */
@@ -931,6 +945,19 @@ int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
931 945
932#endif 946#endif
933 947
948void __trigger_all_cpu_backtrace(void)
949{
950 int i;
951
952 backtrace_mask = cpu_online_map;
953 /* Wait for up to 10 seconds for all CPUs to do the backtrace */
954 for (i = 0; i < 10 * 1000; i++) {
955 if (cpus_empty(backtrace_mask))
956 break;
957 mdelay(1);
958 }
959}
960
934EXPORT_SYMBOL(nmi_active); 961EXPORT_SYMBOL(nmi_active);
935EXPORT_SYMBOL(nmi_watchdog); 962EXPORT_SYMBOL(nmi_watchdog);
936EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi); 963EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi);
diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index 37a770859e71..3215675ab128 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -41,6 +41,13 @@
41#include <asm/pci-direct.h> 41#include <asm/pci-direct.h>
42#include <asm/system.h> 42#include <asm/system.h>
43#include <asm/dma.h> 43#include <asm/dma.h>
44#include <asm/rio.h>
45
46#ifdef CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT
47int use_calgary __read_mostly = 1;
48#else
49int use_calgary __read_mostly = 0;
50#endif /* CONFIG_CALGARY_DEFAULT_ENABLED */
44 51
45#define PCI_DEVICE_ID_IBM_CALGARY 0x02a1 52#define PCI_DEVICE_ID_IBM_CALGARY 0x02a1
46#define PCI_VENDOR_DEVICE_ID_CALGARY \ 53#define PCI_VENDOR_DEVICE_ID_CALGARY \
@@ -115,14 +122,35 @@ static const unsigned long phb_offsets[] = {
115 0xB000 /* PHB3 */ 122 0xB000 /* PHB3 */
116}; 123};
117 124
125/* PHB debug registers */
126
127static const unsigned long phb_debug_offsets[] = {
128 0x4000 /* PHB 0 DEBUG */,
129 0x5000 /* PHB 1 DEBUG */,
130 0x6000 /* PHB 2 DEBUG */,
131 0x7000 /* PHB 3 DEBUG */
132};
133
134/*
135 * STUFF register for each debug PHB,
136 * byte 1 = start bus number, byte 2 = end bus number
137 */
138
139#define PHB_DEBUG_STUFF_OFFSET 0x0020
140
118unsigned int specified_table_size = TCE_TABLE_SIZE_UNSPECIFIED; 141unsigned int specified_table_size = TCE_TABLE_SIZE_UNSPECIFIED;
119static int translate_empty_slots __read_mostly = 0; 142static int translate_empty_slots __read_mostly = 0;
120static int calgary_detected __read_mostly = 0; 143static int calgary_detected __read_mostly = 0;
121 144
145static struct rio_table_hdr *rio_table_hdr __initdata;
146static struct scal_detail *scal_devs[MAX_NUMNODES] __initdata;
147static struct rio_detail *rio_devs[MAX_NUMNODES * 4] __initdata;
148
122struct calgary_bus_info { 149struct calgary_bus_info {
123 void *tce_space; 150 void *tce_space;
124 unsigned char translation_disabled; 151 unsigned char translation_disabled;
125 signed char phbid; 152 signed char phbid;
153 void __iomem *bbar;
126}; 154};
127 155
128static struct calgary_bus_info bus_info[MAX_PHB_BUS_NUM] = { { NULL, 0, 0 }, }; 156static struct calgary_bus_info bus_info[MAX_PHB_BUS_NUM] = { { NULL, 0, 0 }, };
@@ -475,6 +503,11 @@ static struct dma_mapping_ops calgary_dma_ops = {
475 .unmap_sg = calgary_unmap_sg, 503 .unmap_sg = calgary_unmap_sg,
476}; 504};
477 505
506static inline void __iomem * busno_to_bbar(unsigned char num)
507{
508 return bus_info[num].bbar;
509}
510
478static inline int busno_to_phbid(unsigned char num) 511static inline int busno_to_phbid(unsigned char num)
479{ 512{
480 return bus_info[num].phbid; 513 return bus_info[num].phbid;
@@ -620,14 +653,9 @@ static void __init calgary_reserve_peripheral_mem_2(struct pci_dev *dev)
620static void __init calgary_reserve_regions(struct pci_dev *dev) 653static void __init calgary_reserve_regions(struct pci_dev *dev)
621{ 654{
622 unsigned int npages; 655 unsigned int npages;
623 void __iomem *bbar;
624 unsigned char busnum;
625 u64 start; 656 u64 start;
626 struct iommu_table *tbl = dev->sysdata; 657 struct iommu_table *tbl = dev->sysdata;
627 658
628 bbar = tbl->bbar;
629 busnum = dev->bus->number;
630
631 /* reserve bad_dma_address in case it's a legal address */ 659 /* reserve bad_dma_address in case it's a legal address */
632 iommu_range_reserve(tbl, bad_dma_address, 1); 660 iommu_range_reserve(tbl, bad_dma_address, 1);
633 661
@@ -740,7 +768,7 @@ static void __init calgary_increase_split_completion_timeout(void __iomem *bbar,
740{ 768{
741 u64 val64; 769 u64 val64;
742 void __iomem *target; 770 void __iomem *target;
743 unsigned long phb_shift = -1; 771 unsigned int phb_shift = ~0; /* silence gcc */
744 u64 mask; 772 u64 mask;
745 773
746 switch (busno_to_phbid(busnum)) { 774 switch (busno_to_phbid(busnum)) {
@@ -828,33 +856,6 @@ static void __init calgary_disable_translation(struct pci_dev *dev)
828 del_timer_sync(&tbl->watchdog_timer); 856 del_timer_sync(&tbl->watchdog_timer);
829} 857}
830 858
831static inline unsigned int __init locate_register_space(struct pci_dev *dev)
832{
833 int rionodeid;
834 u32 address;
835
836 /*
837 * Each Calgary has four busses. The first four busses (first Calgary)
838 * have RIO node ID 2, then the next four (second Calgary) have RIO
839 * node ID 3, the next four (third Calgary) have node ID 2 again, etc.
840 * We use a gross hack - relying on the dev->bus->number ordering,
841 * modulo 14 - to decide which Calgary a given bus is on. Busses 0, 1,
842 * 2 and 4 are on the first Calgary (id 2), 6, 8, a and c are on the
843 * second (id 3), and then it repeats modulo 14.
844 */
845 rionodeid = (dev->bus->number % 14 > 4) ? 3 : 2;
846 /*
847 * register space address calculation as follows:
848 * FE0MB-8MB*OneBasedChassisNumber+1MB*(RioNodeId-ChassisBase)
849 * ChassisBase is always zero for x366/x260/x460
850 * RioNodeId is 2 for first Calgary, 3 for second Calgary
851 */
852 address = START_ADDRESS -
853 (0x800000 * (ONE_BASED_CHASSIS_NUM + dev->bus->number / 14)) +
854 (0x100000) * (rionodeid - CHASSIS_BASE);
855 return address;
856}
857
858static void __init calgary_init_one_nontraslated(struct pci_dev *dev) 859static void __init calgary_init_one_nontraslated(struct pci_dev *dev)
859{ 860{
860 pci_dev_get(dev); 861 pci_dev_get(dev);
@@ -864,23 +865,15 @@ static void __init calgary_init_one_nontraslated(struct pci_dev *dev)
864 865
865static int __init calgary_init_one(struct pci_dev *dev) 866static int __init calgary_init_one(struct pci_dev *dev)
866{ 867{
867 u32 address;
868 void __iomem *bbar; 868 void __iomem *bbar;
869 int ret; 869 int ret;
870 870
871 BUG_ON(dev->bus->number >= MAX_PHB_BUS_NUM); 871 BUG_ON(dev->bus->number >= MAX_PHB_BUS_NUM);
872 872
873 address = locate_register_space(dev); 873 bbar = busno_to_bbar(dev->bus->number);
874 /* map entire 1MB of Calgary config space */
875 bbar = ioremap_nocache(address, 1024 * 1024);
876 if (!bbar) {
877 ret = -ENODATA;
878 goto done;
879 }
880
881 ret = calgary_setup_tar(dev, bbar); 874 ret = calgary_setup_tar(dev, bbar);
882 if (ret) 875 if (ret)
883 goto iounmap; 876 goto done;
884 877
885 pci_dev_get(dev); 878 pci_dev_get(dev);
886 dev->bus->self = dev; 879 dev->bus->self = dev;
@@ -888,17 +881,66 @@ static int __init calgary_init_one(struct pci_dev *dev)
888 881
889 return 0; 882 return 0;
890 883
891iounmap:
892 iounmap(bbar);
893done: 884done:
894 return ret; 885 return ret;
895} 886}
896 887
888static int __init calgary_locate_bbars(void)
889{
890 int ret;
891 int rioidx, phb, bus;
892 void __iomem *bbar;
893 void __iomem *target;
894 unsigned long offset;
895 u8 start_bus, end_bus;
896 u32 val;
897
898 ret = -ENODATA;
899 for (rioidx = 0; rioidx < rio_table_hdr->num_rio_dev; rioidx++) {
900 struct rio_detail *rio = rio_devs[rioidx];
901
902 if ((rio->type != COMPAT_CALGARY) && (rio->type != ALT_CALGARY))
903 continue;
904
905 /* map entire 1MB of Calgary config space */
906 bbar = ioremap_nocache(rio->BBAR, 1024 * 1024);
907 if (!bbar)
908 goto error;
909
910 for (phb = 0; phb < PHBS_PER_CALGARY; phb++) {
911 offset = phb_debug_offsets[phb] | PHB_DEBUG_STUFF_OFFSET;
912 target = calgary_reg(bbar, offset);
913
914 val = be32_to_cpu(readl(target));
915 start_bus = (u8)((val & 0x00FF0000) >> 16);
916 end_bus = (u8)((val & 0x0000FF00) >> 8);
917 for (bus = start_bus; bus <= end_bus; bus++) {
918 bus_info[bus].bbar = bbar;
919 bus_info[bus].phbid = phb;
920 }
921 }
922 }
923
924 return 0;
925
926error:
927 /* scan bus_info and iounmap any bbars we previously ioremap'd */
928 for (bus = 0; bus < ARRAY_SIZE(bus_info); bus++)
929 if (bus_info[bus].bbar)
930 iounmap(bus_info[bus].bbar);
931
932 return ret;
933}
934
897static int __init calgary_init(void) 935static int __init calgary_init(void)
898{ 936{
899 int ret = -ENODEV; 937 int ret;
900 struct pci_dev *dev = NULL; 938 struct pci_dev *dev = NULL;
901 939
940 ret = calgary_locate_bbars();
941 if (ret)
942 return ret;
943
902 do { 944 do {
903 dev = pci_get_device(PCI_VENDOR_ID_IBM, 945 dev = pci_get_device(PCI_VENDOR_ID_IBM,
904 PCI_DEVICE_ID_IBM_CALGARY, 946 PCI_DEVICE_ID_IBM_CALGARY,
@@ -921,7 +963,7 @@ static int __init calgary_init(void)
921 963
922error: 964error:
923 do { 965 do {
924 dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM, 966 dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
925 PCI_DEVICE_ID_IBM_CALGARY, 967 PCI_DEVICE_ID_IBM_CALGARY,
926 dev); 968 dev);
927 if (!dev) 969 if (!dev)
@@ -962,13 +1004,56 @@ static inline int __init determine_tce_table_size(u64 ram)
962 return ret; 1004 return ret;
963} 1005}
964 1006
1007static int __init build_detail_arrays(void)
1008{
1009 unsigned long ptr;
1010 int i, scal_detail_size, rio_detail_size;
1011
1012 if (rio_table_hdr->num_scal_dev > MAX_NUMNODES){
1013 printk(KERN_WARNING
1014 "Calgary: MAX_NUMNODES too low! Defined as %d, "
1015 "but system has %d nodes.\n",
1016 MAX_NUMNODES, rio_table_hdr->num_scal_dev);
1017 return -ENODEV;
1018 }
1019
1020 switch (rio_table_hdr->version){
1021 case 2:
1022 scal_detail_size = 11;
1023 rio_detail_size = 13;
1024 break;
1025 case 3:
1026 scal_detail_size = 12;
1027 rio_detail_size = 15;
1028 break;
1029 default:
1030 printk(KERN_WARNING
1031 "Calgary: Invalid Rio Grande Table Version: %d\n",
1032 rio_table_hdr->version);
1033 return -EPROTO;
1034 }
1035
1036 ptr = ((unsigned long)rio_table_hdr) + 3;
1037 for (i = 0; i < rio_table_hdr->num_scal_dev;
1038 i++, ptr += scal_detail_size)
1039 scal_devs[i] = (struct scal_detail *)ptr;
1040
1041 for (i = 0; i < rio_table_hdr->num_rio_dev;
1042 i++, ptr += rio_detail_size)
1043 rio_devs[i] = (struct rio_detail *)ptr;
1044
1045 return 0;
1046}
1047
965void __init detect_calgary(void) 1048void __init detect_calgary(void)
966{ 1049{
967 u32 val; 1050 u32 val;
968 int bus; 1051 int bus;
969 void *tbl; 1052 void *tbl;
970 int calgary_found = 0; 1053 int calgary_found = 0;
971 int phb = -1; 1054 unsigned long ptr;
1055 int offset;
1056 int ret;
972 1057
973 /* 1058 /*
974 * if the user specified iommu=off or iommu=soft or we found 1059 * if the user specified iommu=off or iommu=soft or we found
@@ -977,25 +1062,47 @@ void __init detect_calgary(void)
977 if (swiotlb || no_iommu || iommu_detected) 1062 if (swiotlb || no_iommu || iommu_detected)
978 return; 1063 return;
979 1064
1065 if (!use_calgary)
1066 return;
1067
980 if (!early_pci_allowed()) 1068 if (!early_pci_allowed())
981 return; 1069 return;
982 1070
1071 ptr = (unsigned long)phys_to_virt(get_bios_ebda());
1072
1073 rio_table_hdr = NULL;
1074 offset = 0x180;
1075 while (offset) {
1076 /* The block id is stored in the 2nd word */
1077 if (*((unsigned short *)(ptr + offset + 2)) == 0x4752){
1078 /* set the pointer past the offset & block id */
1079 rio_table_hdr = (struct rio_table_hdr *)(ptr + offset + 4);
1080 break;
1081 }
1082 /* The next offset is stored in the 1st word. 0 means no more */
1083 offset = *((unsigned short *)(ptr + offset));
1084 }
1085 if (!rio_table_hdr) {
1086 printk(KERN_ERR "Calgary: Unable to locate "
1087 "Rio Grande Table in EBDA - bailing!\n");
1088 return;
1089 }
1090
1091 ret = build_detail_arrays();
1092 if (ret) {
1093 printk(KERN_ERR "Calgary: build_detail_arrays ret %d\n", ret);
1094 return;
1095 }
1096
983 specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE); 1097 specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE);
984 1098
985 for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) { 1099 for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
986 int dev; 1100 int dev;
987 struct calgary_bus_info *info = &bus_info[bus]; 1101 struct calgary_bus_info *info = &bus_info[bus];
988 info->phbid = -1;
989 1102
990 if (read_pci_config(bus, 0, 0, 0) != PCI_VENDOR_DEVICE_ID_CALGARY) 1103 if (read_pci_config(bus, 0, 0, 0) != PCI_VENDOR_DEVICE_ID_CALGARY)
991 continue; 1104 continue;
992 1105
993 /*
994 * There are 4 PHBs per Calgary chip. Set phb to which phb (0-3)
995 * it is connected to releative to the clagary chip.
996 */
997 phb = (phb + 1) % PHBS_PER_CALGARY;
998
999 if (info->translation_disabled) 1106 if (info->translation_disabled)
1000 continue; 1107 continue;
1001 1108
@@ -1010,7 +1117,6 @@ void __init detect_calgary(void)
1010 if (!tbl) 1117 if (!tbl)
1011 goto cleanup; 1118 goto cleanup;
1012 info->tce_space = tbl; 1119 info->tce_space = tbl;
1013 info->phbid = phb;
1014 calgary_found = 1; 1120 calgary_found = 1;
1015 break; 1121 break;
1016 } 1122 }
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
index f8d857453f8a..683b7a5c1ab3 100644
--- a/arch/x86_64/kernel/pci-dma.c
+++ b/arch/x86_64/kernel/pci-dma.c
@@ -296,6 +296,11 @@ __init int iommu_setup(char *p)
296 gart_parse_options(p); 296 gart_parse_options(p);
297#endif 297#endif
298 298
299#ifdef CONFIG_CALGARY_IOMMU
300 if (!strncmp(p, "calgary", 7))
301 use_calgary = 1;
302#endif /* CONFIG_CALGARY_IOMMU */
303
299 p += strcspn(p, ","); 304 p += strcspn(p, ",");
300 if (*p == ',') 305 if (*p == ',')
301 ++p; 306 ++p;
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 16261a8a3303..fc1960f1f243 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -601,10 +601,9 @@ void __init gart_iommu_init(void)
601 (!force_iommu && end_pfn <= MAX_DMA32_PFN) || 601 (!force_iommu && end_pfn <= MAX_DMA32_PFN) ||
602 !iommu_aperture || 602 !iommu_aperture ||
603 (no_agp && init_k8_gatt(&info) < 0)) { 603 (no_agp && init_k8_gatt(&info) < 0)) {
604 printk(KERN_INFO "PCI-DMA: Disabling IOMMU.\n");
605 if (end_pfn > MAX_DMA32_PFN) { 604 if (end_pfn > MAX_DMA32_PFN) {
606 printk(KERN_ERR "WARNING more than 4GB of memory " 605 printk(KERN_ERR "WARNING more than 4GB of memory "
607 "but IOMMU not available.\n" 606 "but GART IOMMU not available.\n"
608 KERN_ERR "WARNING 32bit PCI may malfunction.\n"); 607 KERN_ERR "WARNING 32bit PCI may malfunction.\n");
609 } 608 }
610 return; 609 return;
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 7451a4c43c16..a418ee4c8c62 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -108,17 +108,15 @@ void exit_idle(void)
108 */ 108 */
109static void default_idle(void) 109static void default_idle(void)
110{ 110{
111 local_irq_enable();
112
113 current_thread_info()->status &= ~TS_POLLING; 111 current_thread_info()->status &= ~TS_POLLING;
114 smp_mb__after_clear_bit(); 112 smp_mb__after_clear_bit();
115 while (!need_resched()) { 113 local_irq_disable();
116 local_irq_disable(); 114 if (!need_resched()) {
117 if (!need_resched()) 115 /* Enables interrupts one instruction before HLT.
118 safe_halt(); 116 x86 special cases this so there is no race. */
119 else 117 safe_halt();
120 local_irq_enable(); 118 } else
121 } 119 local_irq_enable();
122 current_thread_info()->status |= TS_POLLING; 120 current_thread_info()->status |= TS_POLLING;
123} 121}
124 122
@@ -130,15 +128,7 @@ static void default_idle(void)
130static void poll_idle (void) 128static void poll_idle (void)
131{ 129{
132 local_irq_enable(); 130 local_irq_enable();
133 131 cpu_relax();
134 asm volatile(
135 "2:"
136 "testl %0,%1;"
137 "rep; nop;"
138 "je 2b;"
139 : :
140 "i" (_TIF_NEED_RESCHED),
141 "m" (current_thread_info()->flags));
142} 132}
143 133
144void cpu_idle_wait(void) 134void cpu_idle_wait(void)
@@ -219,6 +209,12 @@ void cpu_idle (void)
219 idle = default_idle; 209 idle = default_idle;
220 if (cpu_is_offline(smp_processor_id())) 210 if (cpu_is_offline(smp_processor_id()))
221 play_dead(); 211 play_dead();
212 /*
213 * Idle routines should keep interrupts disabled
214 * from here on, until they go to idle.
215 * Otherwise, idle callbacks can misfire.
216 */
217 local_irq_disable();
222 enter_idle(); 218 enter_idle();
223 idle(); 219 idle();
224 /* In many cases the interrupt that ended idle 220 /* In many cases the interrupt that ended idle
@@ -256,9 +252,16 @@ void mwait_idle_with_hints(unsigned long eax, unsigned long ecx)
256/* Default MONITOR/MWAIT with no hints, used for default C1 state */ 252/* Default MONITOR/MWAIT with no hints, used for default C1 state */
257static void mwait_idle(void) 253static void mwait_idle(void)
258{ 254{
259 local_irq_enable(); 255 if (!need_resched()) {
260 while (!need_resched()) 256 __monitor((void *)&current_thread_info()->flags, 0, 0);
261 mwait_idle_with_hints(0,0); 257 smp_mb();
258 if (!need_resched())
259 __sti_mwait(0, 0);
260 else
261 local_irq_enable();
262 } else {
263 local_irq_enable();
264 }
262} 265}
263 266
264void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) 267void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index fc944b5e8f4a..af425a8049fb 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -471,8 +471,7 @@ void __init setup_arch(char **cmdline_p)
471 if (LOADER_TYPE && INITRD_START) { 471 if (LOADER_TYPE && INITRD_START) {
472 if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) { 472 if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
473 reserve_bootmem_generic(INITRD_START, INITRD_SIZE); 473 reserve_bootmem_generic(INITRD_START, INITRD_SIZE);
474 initrd_start = 474 initrd_start = INITRD_START + PAGE_OFFSET;
475 INITRD_START ? INITRD_START + PAGE_OFFSET : 0;
476 initrd_end = initrd_start+INITRD_SIZE; 475 initrd_end = initrd_start+INITRD_SIZE;
477 } 476 }
478 else { 477 else {
@@ -732,11 +731,8 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
732 /* Fix cpuid4 emulation for more */ 731 /* Fix cpuid4 emulation for more */
733 num_cache_leaves = 3; 732 num_cache_leaves = 3;
734 733
735 /* When there is only one core no need to synchronize RDTSC */ 734 /* RDTSC can be speculated around */
736 if (num_possible_cpus() == 1) 735 clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
737 set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
738 else
739 clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
740} 736}
741 737
742static void __cpuinit detect_ht(struct cpuinfo_x86 *c) 738static void __cpuinit detect_ht(struct cpuinfo_x86 *c)
@@ -835,6 +831,15 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
835 set_bit(X86_FEATURE_ARCH_PERFMON, &c->x86_capability); 831 set_bit(X86_FEATURE_ARCH_PERFMON, &c->x86_capability);
836 } 832 }
837 833
834 if (cpu_has_ds) {
835 unsigned int l1, l2;
836 rdmsr(MSR_IA32_MISC_ENABLE, l1, l2);
837 if (!(l1 & (1<<11)))
838 set_bit(X86_FEATURE_BTS, c->x86_capability);
839 if (!(l1 & (1<<12)))
840 set_bit(X86_FEATURE_PEBS, c->x86_capability);
841 }
842
838 n = c->extended_cpuid_level; 843 n = c->extended_cpuid_level;
839 if (n >= 0x80000008) { 844 if (n >= 0x80000008) {
840 unsigned eax = cpuid_eax(0x80000008); 845 unsigned eax = cpuid_eax(0x80000008);
@@ -854,7 +859,10 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
854 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability); 859 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
855 if (c->x86 == 6) 860 if (c->x86 == 6)
856 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability); 861 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
857 set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability); 862 if (c->x86 == 15)
863 set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
864 else
865 clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
858 c->x86_max_cores = intel_num_cpu_cores(c); 866 c->x86_max_cores = intel_num_cpu_cores(c);
859 867
860 srat_detect_node(); 868 srat_detect_node();
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index 9f74c883568c..af1ec4d23cf8 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -379,12 +379,17 @@ int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
379 put_cpu(); 379 put_cpu();
380 return 0; 380 return 0;
381 } 381 }
382
383 /* Can deadlock when called with interrupts disabled */
384 WARN_ON(irqs_disabled());
385
382 spin_lock_bh(&call_lock); 386 spin_lock_bh(&call_lock);
383 __smp_call_function_single(cpu, func, info, nonatomic, wait); 387 __smp_call_function_single(cpu, func, info, nonatomic, wait);
384 spin_unlock_bh(&call_lock); 388 spin_unlock_bh(&call_lock);
385 put_cpu(); 389 put_cpu();
386 return 0; 390 return 0;
387} 391}
392EXPORT_SYMBOL(smp_call_function_single);
388 393
389/* 394/*
390 * this function sends a 'generic call function' IPI to all other CPUs 395 * this function sends a 'generic call function' IPI to all other CPUs
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 9800147c4c68..daf19332f0dd 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -60,6 +60,7 @@
60#include <asm/irq.h> 60#include <asm/irq.h>
61#include <asm/hw_irq.h> 61#include <asm/hw_irq.h>
62#include <asm/numa.h> 62#include <asm/numa.h>
63#include <asm/genapic.h>
63 64
64/* Number of siblings per CPU package */ 65/* Number of siblings per CPU package */
65int smp_num_siblings = 1; 66int smp_num_siblings = 1;
@@ -1169,6 +1170,13 @@ int __cpuinit __cpu_up(unsigned int cpu)
1169 1170
1170 while (!cpu_isset(cpu, cpu_online_map)) 1171 while (!cpu_isset(cpu, cpu_online_map))
1171 cpu_relax(); 1172 cpu_relax();
1173
1174 if (num_online_cpus() > 8 && genapic == &apic_flat) {
1175 printk(KERN_WARNING
1176 "flat APIC routing can't be used with > 8 cpus\n");
1177 BUG();
1178 }
1179
1172 err = 0; 1180 err = 0;
1173 1181
1174 return err; 1182 return err;
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 0d65b22f229c..a1641ffdffcf 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -30,9 +30,9 @@
30#include <linux/kprobes.h> 30#include <linux/kprobes.h>
31#include <linux/kexec.h> 31#include <linux/kexec.h>
32#include <linux/unwind.h> 32#include <linux/unwind.h>
33#include <linux/uaccess.h>
33 34
34#include <asm/system.h> 35#include <asm/system.h>
35#include <asm/uaccess.h>
36#include <asm/io.h> 36#include <asm/io.h>
37#include <asm/atomic.h> 37#include <asm/atomic.h>
38#include <asm/debugreg.h> 38#include <asm/debugreg.h>
@@ -108,7 +108,7 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
108 preempt_enable_no_resched(); 108 preempt_enable_no_resched();
109} 109}
110 110
111static int kstack_depth_to_print = 12; 111int kstack_depth_to_print = 12;
112#ifdef CONFIG_STACK_UNWIND 112#ifdef CONFIG_STACK_UNWIND
113static int call_trace = 1; 113static int call_trace = 1;
114#else 114#else
@@ -225,16 +225,25 @@ static int dump_trace_unwind(struct unwind_frame_info *info, void *context)
225{ 225{
226 struct ops_and_data *oad = (struct ops_and_data *)context; 226 struct ops_and_data *oad = (struct ops_and_data *)context;
227 int n = 0; 227 int n = 0;
228 unsigned long sp = UNW_SP(info);
228 229
230 if (arch_unw_user_mode(info))
231 return -1;
229 while (unwind(info) == 0 && UNW_PC(info)) { 232 while (unwind(info) == 0 && UNW_PC(info)) {
230 n++; 233 n++;
231 oad->ops->address(oad->data, UNW_PC(info)); 234 oad->ops->address(oad->data, UNW_PC(info));
232 if (arch_unw_user_mode(info)) 235 if (arch_unw_user_mode(info))
233 break; 236 break;
237 if ((sp & ~(PAGE_SIZE - 1)) == (UNW_SP(info) & ~(PAGE_SIZE - 1))
238 && sp > UNW_SP(info))
239 break;
240 sp = UNW_SP(info);
234 } 241 }
235 return n; 242 return n;
236} 243}
237 244
245#define MSG(txt) ops->warning(data, txt)
246
238/* 247/*
239 * x86-64 can have upto three kernel stacks: 248 * x86-64 can have upto three kernel stacks:
240 * process stack 249 * process stack
@@ -248,11 +257,12 @@ static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
248 return p > t && p < t + THREAD_SIZE - 3; 257 return p > t && p < t + THREAD_SIZE - 3;
249} 258}
250 259
251void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * stack, 260void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
261 unsigned long *stack,
252 struct stacktrace_ops *ops, void *data) 262 struct stacktrace_ops *ops, void *data)
253{ 263{
254 const unsigned cpu = smp_processor_id(); 264 const unsigned cpu = get_cpu();
255 unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr; 265 unsigned long *irqstack_end = (unsigned long*)cpu_pda(cpu)->irqstackptr;
256 unsigned used = 0; 266 unsigned used = 0;
257 struct thread_info *tinfo; 267 struct thread_info *tinfo;
258 268
@@ -268,28 +278,30 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
268 if (unwind_init_frame_info(&info, tsk, regs) == 0) 278 if (unwind_init_frame_info(&info, tsk, regs) == 0)
269 unw_ret = dump_trace_unwind(&info, &oad); 279 unw_ret = dump_trace_unwind(&info, &oad);
270 } else if (tsk == current) 280 } else if (tsk == current)
271 unw_ret = unwind_init_running(&info, dump_trace_unwind, &oad); 281 unw_ret = unwind_init_running(&info, dump_trace_unwind,
282 &oad);
272 else { 283 else {
273 if (unwind_init_blocked(&info, tsk) == 0) 284 if (unwind_init_blocked(&info, tsk) == 0)
274 unw_ret = dump_trace_unwind(&info, &oad); 285 unw_ret = dump_trace_unwind(&info, &oad);
275 } 286 }
276 if (unw_ret > 0) { 287 if (unw_ret > 0) {
277 if (call_trace == 1 && !arch_unw_user_mode(&info)) { 288 if (call_trace == 1 && !arch_unw_user_mode(&info)) {
278 ops->warning_symbol(data, "DWARF2 unwinder stuck at %s\n", 289 ops->warning_symbol(data,
290 "DWARF2 unwinder stuck at %s",
279 UNW_PC(&info)); 291 UNW_PC(&info));
280 if ((long)UNW_SP(&info) < 0) { 292 if ((long)UNW_SP(&info) < 0) {
281 ops->warning(data, "Leftover inexact backtrace:\n"); 293 MSG("Leftover inexact backtrace:");
282 stack = (unsigned long *)UNW_SP(&info); 294 stack = (unsigned long *)UNW_SP(&info);
283 if (!stack) 295 if (!stack)
284 return; 296 goto out;
285 } else 297 } else
286 ops->warning(data, "Full inexact backtrace again:\n"); 298 MSG("Full inexact backtrace again:");
287 } else if (call_trace >= 1) 299 } else if (call_trace >= 1)
288 return; 300 goto out;
289 else 301 else
290 ops->warning(data, "Full inexact backtrace again:\n"); 302 MSG("Full inexact backtrace again:");
291 } else 303 } else
292 ops->warning(data, "Inexact backtrace:\n"); 304 MSG("Inexact backtrace:");
293 } 305 }
294 if (!stack) { 306 if (!stack) {
295 unsigned long dummy; 307 unsigned long dummy;
@@ -297,12 +309,6 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
297 if (tsk && tsk != current) 309 if (tsk && tsk != current)
298 stack = (unsigned long *)tsk->thread.rsp; 310 stack = (unsigned long *)tsk->thread.rsp;
299 } 311 }
300 /*
301 * Align the stack pointer on word boundary, later loops
302 * rely on that (and corruption / debug info bugs can cause
303 * unaligned values here):
304 */
305 stack = (unsigned long *)((unsigned long)stack & ~(sizeof(long)-1));
306 312
307 /* 313 /*
308 * Print function call entries within a stack. 'cond' is the 314 * Print function call entries within a stack. 'cond' is the
@@ -312,9 +318,9 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
312#define HANDLE_STACK(cond) \ 318#define HANDLE_STACK(cond) \
313 do while (cond) { \ 319 do while (cond) { \
314 unsigned long addr = *stack++; \ 320 unsigned long addr = *stack++; \
315 if (oops_in_progress ? \ 321 /* Use unlocked access here because except for NMIs \
316 __kernel_text_address(addr) : \ 322 we should be already protected against module unloads */ \
317 kernel_text_address(addr)) { \ 323 if (__kernel_text_address(addr)) { \
318 /* \ 324 /* \
319 * If the address is either in the text segment of the \ 325 * If the address is either in the text segment of the \
320 * kernel, or in the region which contains vmalloc'ed \ 326 * kernel, or in the region which contains vmalloc'ed \
@@ -380,6 +386,8 @@ void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
380 tinfo = current_thread_info(); 386 tinfo = current_thread_info();
381 HANDLE_STACK (valid_stack_ptr(tinfo, stack)); 387 HANDLE_STACK (valid_stack_ptr(tinfo, stack));
382#undef HANDLE_STACK 388#undef HANDLE_STACK
389out:
390 put_cpu();
383} 391}
384EXPORT_SYMBOL(dump_trace); 392EXPORT_SYMBOL(dump_trace);
385 393
@@ -786,8 +794,7 @@ mem_parity_error(unsigned char reason, struct pt_regs * regs)
786{ 794{
787 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n", 795 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
788 reason); 796 reason);
789 printk(KERN_EMERG "You probably have a hardware problem with your " 797 printk(KERN_EMERG "You have some hardware problem, likely on the PCI bus.\n");
790 "RAM chips\n");
791 798
792 if (panic_on_unrecovered_nmi) 799 if (panic_on_unrecovered_nmi)
793 panic("NMI: Not continuing"); 800 panic("NMI: Not continuing");
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index d9534e750d4f..6a1f8f491e5d 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -51,15 +51,6 @@ SECTIONS
51 51
52 RODATA 52 RODATA
53 53
54#ifdef CONFIG_STACK_UNWIND
55 . = ALIGN(8);
56 .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {
57 __start_unwind = .;
58 *(.eh_frame)
59 __end_unwind = .;
60 }
61#endif
62
63 . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */ 54 . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */
64 /* Data */ 55 /* Data */
65 .data : AT(ADDR(.data) - LOAD_OFFSET) { 56 .data : AT(ADDR(.data) - LOAD_OFFSET) {
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index 92546c1526f1..4a673f5397a0 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -42,6 +42,7 @@
42#include <asm/topology.h> 42#include <asm/topology.h>
43 43
44#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr))) 44#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
45#define __syscall_clobber "r11","rcx","memory"
45 46
46int __sysctl_vsyscall __section_sysctl_vsyscall = 1; 47int __sysctl_vsyscall __section_sysctl_vsyscall = 1;
47seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED; 48seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED;
@@ -274,7 +275,6 @@ static void __cpuinit cpu_vsyscall_init(void *arg)
274 vsyscall_set_cpu(raw_smp_processor_id()); 275 vsyscall_set_cpu(raw_smp_processor_id());
275} 276}
276 277
277#ifdef CONFIG_HOTPLUG_CPU
278static int __cpuinit 278static int __cpuinit
279cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg) 279cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
280{ 280{
@@ -283,13 +283,13 @@ cpu_vsyscall_notifier(struct notifier_block *n, unsigned long action, void *arg)
283 smp_call_function_single(cpu, cpu_vsyscall_init, NULL, 0, 1); 283 smp_call_function_single(cpu, cpu_vsyscall_init, NULL, 0, 1);
284 return NOTIFY_DONE; 284 return NOTIFY_DONE;
285} 285}
286#endif
287 286
288static void __init map_vsyscall(void) 287static void __init map_vsyscall(void)
289{ 288{
290 extern char __vsyscall_0; 289 extern char __vsyscall_0;
291 unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0); 290 unsigned long physaddr_page0 = __pa_symbol(&__vsyscall_0);
292 291
292 /* Note that VSYSCALL_MAPPED_PAGES must agree with the code below. */
293 __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL); 293 __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_page0, PAGE_KERNEL_VSYSCALL);
294} 294}
295 295
diff --git a/arch/x86_64/lib/csum-partial.c b/arch/x86_64/lib/csum-partial.c
index 06ae630de82b..bc503f506903 100644
--- a/arch/x86_64/lib/csum-partial.c
+++ b/arch/x86_64/lib/csum-partial.c
@@ -9,8 +9,6 @@
9#include <linux/module.h> 9#include <linux/module.h>
10#include <asm/checksum.h> 10#include <asm/checksum.h>
11 11
12#define __force_inline inline __attribute__((always_inline))
13
14static inline unsigned short from32to16(unsigned a) 12static inline unsigned short from32to16(unsigned a)
15{ 13{
16 unsigned short b = a >> 16; 14 unsigned short b = a >> 16;
@@ -33,7 +31,7 @@ static inline unsigned short from32to16(unsigned a)
33 * Unrolling to an 128 bytes inner loop. 31 * Unrolling to an 128 bytes inner loop.
34 * Using interleaving with more registers to break the carry chains. 32 * Using interleaving with more registers to break the carry chains.
35 */ 33 */
36static __force_inline unsigned do_csum(const unsigned char *buff, unsigned len) 34static unsigned do_csum(const unsigned char *buff, unsigned len)
37{ 35{
38 unsigned odd, count; 36 unsigned odd, count;
39 unsigned long result = 0; 37 unsigned long result = 0;
diff --git a/arch/x86_64/lib/delay.c b/arch/x86_64/lib/delay.c
index 50be90975d04..2dbebd308347 100644
--- a/arch/x86_64/lib/delay.c
+++ b/arch/x86_64/lib/delay.c
@@ -40,13 +40,13 @@ EXPORT_SYMBOL(__delay);
40 40
41inline void __const_udelay(unsigned long xloops) 41inline void __const_udelay(unsigned long xloops)
42{ 42{
43 __delay((xloops * HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32); 43 __delay(((xloops * HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32) + 1);
44} 44}
45EXPORT_SYMBOL(__const_udelay); 45EXPORT_SYMBOL(__const_udelay);
46 46
47void __udelay(unsigned long usecs) 47void __udelay(unsigned long usecs)
48{ 48{
49 __const_udelay(usecs * 0x000010c6); /* 2**32 / 1000000 */ 49 __const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
50} 50}
51EXPORT_SYMBOL(__udelay); 51EXPORT_SYMBOL(__udelay);
52 52
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 3751b4788e28..a65fc6f1dcaf 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -23,9 +23,9 @@
23#include <linux/compiler.h> 23#include <linux/compiler.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/kprobes.h> 25#include <linux/kprobes.h>
26#include <linux/uaccess.h>
26 27
27#include <asm/system.h> 28#include <asm/system.h>
28#include <asm/uaccess.h>
29#include <asm/pgalloc.h> 29#include <asm/pgalloc.h>
30#include <asm/smp.h> 30#include <asm/smp.h>
31#include <asm/tlbflush.h> 31#include <asm/tlbflush.h>
@@ -96,7 +96,7 @@ void bust_spinlocks(int yes)
96static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr, 96static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
97 unsigned long error_code) 97 unsigned long error_code)
98{ 98{
99 unsigned char __user *instr; 99 unsigned char *instr;
100 int scan_more = 1; 100 int scan_more = 1;
101 int prefetch = 0; 101 int prefetch = 0;
102 unsigned char *max_instr; 102 unsigned char *max_instr;
@@ -116,7 +116,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
116 unsigned char instr_hi; 116 unsigned char instr_hi;
117 unsigned char instr_lo; 117 unsigned char instr_lo;
118 118
119 if (__get_user(opcode, (char __user *)instr)) 119 if (probe_kernel_address(instr, opcode))
120 break; 120 break;
121 121
122 instr_hi = opcode & 0xf0; 122 instr_hi = opcode & 0xf0;
@@ -154,7 +154,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
154 case 0x00: 154 case 0x00:
155 /* Prefetch instruction is 0x0F0D or 0x0F18 */ 155 /* Prefetch instruction is 0x0F0D or 0x0F18 */
156 scan_more = 0; 156 scan_more = 0;
157 if (__get_user(opcode, (char __user *)instr)) 157 if (probe_kernel_address(instr, opcode))
158 break; 158 break;
159 prefetch = (instr_lo == 0xF) && 159 prefetch = (instr_lo == 0xF) &&
160 (opcode == 0x0D || opcode == 0x18); 160 (opcode == 0x0D || opcode == 0x18);
@@ -170,7 +170,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
170static int bad_address(void *p) 170static int bad_address(void *p)
171{ 171{
172 unsigned long dummy; 172 unsigned long dummy;
173 return __get_user(dummy, (unsigned long __user *)p); 173 return probe_kernel_address((unsigned long *)p, dummy);
174} 174}
175 175
176void dump_pagetable(unsigned long address) 176void dump_pagetable(unsigned long address)
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 4c0c00ef3ca7..2968b90ef8ad 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -730,14 +730,15 @@ static __init int x8664_sysctl_init(void)
730__initcall(x8664_sysctl_init); 730__initcall(x8664_sysctl_init);
731#endif 731#endif
732 732
733/* A pseudo VMAs to allow ptrace access for the vsyscall page. This only 733/* A pseudo VMA to allow ptrace access for the vsyscall page. This only
734 covers the 64bit vsyscall page now. 32bit has a real VMA now and does 734 covers the 64bit vsyscall page now. 32bit has a real VMA now and does
735 not need special handling anymore. */ 735 not need special handling anymore. */
736 736
737static struct vm_area_struct gate_vma = { 737static struct vm_area_struct gate_vma = {
738 .vm_start = VSYSCALL_START, 738 .vm_start = VSYSCALL_START,
739 .vm_end = VSYSCALL_END, 739 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES << PAGE_SHIFT),
740 .vm_page_prot = PAGE_READONLY 740 .vm_page_prot = PAGE_READONLY_EXEC,
741 .vm_flags = VM_READ | VM_EXEC
741}; 742};
742 743
743struct vm_area_struct *get_gate_vma(struct task_struct *tsk) 744struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
diff --git a/arch/x86_64/mm/pageattr.c b/arch/x86_64/mm/pageattr.c
index 3e231d762aaa..ccb91dd996a9 100644
--- a/arch/x86_64/mm/pageattr.c
+++ b/arch/x86_64/mm/pageattr.c
@@ -61,34 +61,40 @@ static struct page *split_large_page(unsigned long address, pgprot_t prot,
61 return base; 61 return base;
62} 62}
63 63
64 64static void cache_flush_page(void *adr)
65static void flush_kernel_map(void *address)
66{ 65{
67 if (0 && address && cpu_has_clflush) { 66 int i;
68 /* is this worth it? */ 67 for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
69 int i; 68 asm volatile("clflush (%0)" :: "r" (adr + i));
70 for (i = 0; i < PAGE_SIZE; i += boot_cpu_data.x86_clflush_size)
71 asm volatile("clflush (%0)" :: "r" (address + i));
72 } else
73 asm volatile("wbinvd":::"memory");
74 if (address)
75 __flush_tlb_one(address);
76 else
77 __flush_tlb_all();
78} 69}
79 70
71static void flush_kernel_map(void *arg)
72{
73 struct list_head *l = (struct list_head *)arg;
74 struct page *pg;
75
76 /* When clflush is available always use it because it is
77 much cheaper than WBINVD */
78 if (!cpu_has_clflush)
79 asm volatile("wbinvd" ::: "memory");
80 list_for_each_entry(pg, l, lru) {
81 void *adr = page_address(pg);
82 if (cpu_has_clflush)
83 cache_flush_page(adr);
84 __flush_tlb_one(adr);
85 }
86}
80 87
81static inline void flush_map(unsigned long address) 88static inline void flush_map(struct list_head *l)
82{ 89{
83 on_each_cpu(flush_kernel_map, (void *)address, 1, 1); 90 on_each_cpu(flush_kernel_map, l, 1, 1);
84} 91}
85 92
86static struct page *deferred_pages; /* protected by init_mm.mmap_sem */ 93static LIST_HEAD(deferred_pages); /* protected by init_mm.mmap_sem */
87 94
88static inline void save_page(struct page *fpage) 95static inline void save_page(struct page *fpage)
89{ 96{
90 fpage->lru.next = (struct list_head *)deferred_pages; 97 list_add(&fpage->lru, &deferred_pages);
91 deferred_pages = fpage;
92} 98}
93 99
94/* 100/*
@@ -207,18 +213,18 @@ int change_page_attr(struct page *page, int numpages, pgprot_t prot)
207 213
208void global_flush_tlb(void) 214void global_flush_tlb(void)
209{ 215{
210 struct page *dpage; 216 struct page *pg, *next;
217 struct list_head l;
211 218
212 down_read(&init_mm.mmap_sem); 219 down_read(&init_mm.mmap_sem);
213 dpage = xchg(&deferred_pages, NULL); 220 list_replace_init(&deferred_pages, &l);
214 up_read(&init_mm.mmap_sem); 221 up_read(&init_mm.mmap_sem);
215 222
216 flush_map((dpage && !dpage->lru.next) ? (unsigned long)page_address(dpage) : 0); 223 flush_map(&l);
217 while (dpage) { 224
218 struct page *tmp = dpage; 225 list_for_each_entry_safe(pg, next, &l, lru) {
219 dpage = (struct page *)dpage->lru.next; 226 ClearPagePrivate(pg);
220 ClearPagePrivate(tmp); 227 __free_page(pg);
221 __free_page(tmp);
222 } 228 }
223} 229}
224 230
diff --git a/block/blktrace.c b/block/blktrace.c
index 74e02c04b2da..d3679dd1d220 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -394,8 +394,7 @@ err:
394 if (bt) { 394 if (bt) {
395 if (bt->dropped_file) 395 if (bt->dropped_file)
396 debugfs_remove(bt->dropped_file); 396 debugfs_remove(bt->dropped_file);
397 if (bt->sequence) 397 free_percpu(bt->sequence);
398 free_percpu(bt->sequence);
399 if (bt->rchan) 398 if (bt->rchan)
400 relay_close(bt->rchan); 399 relay_close(bt->rchan);
401 kfree(bt); 400 kfree(bt);
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index 84e9be073180..78c6b312bd30 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -43,8 +43,8 @@ static int cfq_slice_idle = HZ / 125;
43#define RQ_CIC(rq) ((struct cfq_io_context*)(rq)->elevator_private) 43#define RQ_CIC(rq) ((struct cfq_io_context*)(rq)->elevator_private)
44#define RQ_CFQQ(rq) ((rq)->elevator_private2) 44#define RQ_CFQQ(rq) ((rq)->elevator_private2)
45 45
46static kmem_cache_t *cfq_pool; 46static struct kmem_cache *cfq_pool;
47static kmem_cache_t *cfq_ioc_pool; 47static struct kmem_cache *cfq_ioc_pool;
48 48
49static DEFINE_PER_CPU(unsigned long, ioc_count); 49static DEFINE_PER_CPU(unsigned long, ioc_count);
50static struct completion *ioc_gone; 50static struct completion *ioc_gone;
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index cc6e95f8e5d9..31512cd9f3ad 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -44,17 +44,17 @@ static struct io_context *current_io_context(gfp_t gfp_flags, int node);
44/* 44/*
45 * For the allocated request tables 45 * For the allocated request tables
46 */ 46 */
47static kmem_cache_t *request_cachep; 47static struct kmem_cache *request_cachep;
48 48
49/* 49/*
50 * For queue allocation 50 * For queue allocation
51 */ 51 */
52static kmem_cache_t *requestq_cachep; 52static struct kmem_cache *requestq_cachep;
53 53
54/* 54/*
55 * For io context allocations 55 * For io context allocations
56 */ 56 */
57static kmem_cache_t *iocontext_cachep; 57static struct kmem_cache *iocontext_cachep;
58 58
59/* 59/*
60 * Controlling structure to kblockd 60 * Controlling structure to kblockd
@@ -3459,8 +3459,6 @@ static void blk_done_softirq(struct softirq_action *h)
3459 } 3459 }
3460} 3460}
3461 3461
3462#ifdef CONFIG_HOTPLUG_CPU
3463
3464static int blk_cpu_notify(struct notifier_block *self, unsigned long action, 3462static int blk_cpu_notify(struct notifier_block *self, unsigned long action,
3465 void *hcpu) 3463 void *hcpu)
3466{ 3464{
@@ -3486,8 +3484,6 @@ static struct notifier_block __devinitdata blk_cpu_notifier = {
3486 .notifier_call = blk_cpu_notify, 3484 .notifier_call = blk_cpu_notify,
3487}; 3485};
3488 3486
3489#endif /* CONFIG_HOTPLUG_CPU */
3490
3491/** 3487/**
3492 * blk_complete_request - end I/O on a request 3488 * blk_complete_request - end I/O on a request
3493 * @req: the request being processed 3489 * @req: the request being processed
diff --git a/crypto/Kconfig b/crypto/Kconfig
index cbae8392ce11..92ba249f3a5b 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -39,6 +39,17 @@ config CRYPTO_HMAC
39 HMAC: Keyed-Hashing for Message Authentication (RFC2104). 39 HMAC: Keyed-Hashing for Message Authentication (RFC2104).
40 This is required for IPSec. 40 This is required for IPSec.
41 41
42config CRYPTO_XCBC
43 tristate "XCBC support"
44 depends on EXPERIMENTAL
45 select CRYPTO_HASH
46 select CRYPTO_MANAGER
47 help
48 XCBC: Keyed-Hashing with encryption algorithm
49 http://www.ietf.org/rfc/rfc3566.txt
50 http://csrc.nist.gov/encryption/modes/proposedmodes/
51 xcbc-mac/xcbc-mac-spec.pdf
52
42config CRYPTO_NULL 53config CRYPTO_NULL
43 tristate "Null algorithms" 54 tristate "Null algorithms"
44 select CRYPTO_ALGAPI 55 select CRYPTO_ALGAPI
@@ -128,6 +139,16 @@ config CRYPTO_TGR192
128 See also: 139 See also:
129 <http://www.cs.technion.ac.il/~biham/Reports/Tiger/>. 140 <http://www.cs.technion.ac.il/~biham/Reports/Tiger/>.
130 141
142config CRYPTO_GF128MUL
143 tristate "GF(2^128) multiplication functions (EXPERIMENTAL)"
144 depends on EXPERIMENTAL
145 help
146 Efficient table driven implementation of multiplications in the
147 field GF(2^128). This is needed by some cypher modes. This
148 option will be selected automatically if you select such a
149 cipher mode. Only select this option by hand if you expect to load
150 an external module that requires these functions.
151
131config CRYPTO_ECB 152config CRYPTO_ECB
132 tristate "ECB support" 153 tristate "ECB support"
133 select CRYPTO_BLKCIPHER 154 select CRYPTO_BLKCIPHER
@@ -147,6 +168,19 @@ config CRYPTO_CBC
147 CBC: Cipher Block Chaining mode 168 CBC: Cipher Block Chaining mode
148 This block cipher algorithm is required for IPSec. 169 This block cipher algorithm is required for IPSec.
149 170
171config CRYPTO_LRW
172 tristate "LRW support (EXPERIMENTAL)"
173 depends on EXPERIMENTAL
174 select CRYPTO_BLKCIPHER
175 select CRYPTO_MANAGER
176 select CRYPTO_GF128MUL
177 help
178 LRW: Liskov Rivest Wagner, a tweakable, non malleable, non movable
179 narrow block cipher mode for dm-crypt. Use it with cipher
180 specification string aes-lrw-benbi, the key must be 256, 320 or 384.
181 The first 128, 192 or 256 bits in the key are used for AES and the
182 rest is used to tie each cipher block to its logical position.
183
150config CRYPTO_DES 184config CRYPTO_DES
151 tristate "DES and Triple DES EDE cipher algorithms" 185 tristate "DES and Triple DES EDE cipher algorithms"
152 select CRYPTO_ALGAPI 186 select CRYPTO_ALGAPI
diff --git a/crypto/Makefile b/crypto/Makefile
index 72366208e291..60e3d24f61f5 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_CRYPTO_HASH) += crypto_hash.o
15 15
16obj-$(CONFIG_CRYPTO_MANAGER) += cryptomgr.o 16obj-$(CONFIG_CRYPTO_MANAGER) += cryptomgr.o
17obj-$(CONFIG_CRYPTO_HMAC) += hmac.o 17obj-$(CONFIG_CRYPTO_HMAC) += hmac.o
18obj-$(CONFIG_CRYPTO_XCBC) += xcbc.o
18obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o 19obj-$(CONFIG_CRYPTO_NULL) += crypto_null.o
19obj-$(CONFIG_CRYPTO_MD4) += md4.o 20obj-$(CONFIG_CRYPTO_MD4) += md4.o
20obj-$(CONFIG_CRYPTO_MD5) += md5.o 21obj-$(CONFIG_CRYPTO_MD5) += md5.o
@@ -23,8 +24,10 @@ obj-$(CONFIG_CRYPTO_SHA256) += sha256.o
23obj-$(CONFIG_CRYPTO_SHA512) += sha512.o 24obj-$(CONFIG_CRYPTO_SHA512) += sha512.o
24obj-$(CONFIG_CRYPTO_WP512) += wp512.o 25obj-$(CONFIG_CRYPTO_WP512) += wp512.o
25obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o 26obj-$(CONFIG_CRYPTO_TGR192) += tgr192.o
27obj-$(CONFIG_CRYPTO_GF128MUL) += gf128mul.o
26obj-$(CONFIG_CRYPTO_ECB) += ecb.o 28obj-$(CONFIG_CRYPTO_ECB) += ecb.o
27obj-$(CONFIG_CRYPTO_CBC) += cbc.o 29obj-$(CONFIG_CRYPTO_CBC) += cbc.o
30obj-$(CONFIG_CRYPTO_LRW) += lrw.o
28obj-$(CONFIG_CRYPTO_DES) += des.o 31obj-$(CONFIG_CRYPTO_DES) += des.o
29obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o 32obj-$(CONFIG_CRYPTO_BLOWFISH) += blowfish.o
30obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o 33obj-$(CONFIG_CRYPTO_TWOFISH) += twofish.o
diff --git a/crypto/api.c b/crypto/api.c
index 4fb7fa45cb0d..8c446871cd5b 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -466,23 +466,8 @@ void crypto_free_tfm(struct crypto_tfm *tfm)
466 kfree(tfm); 466 kfree(tfm);
467} 467}
468 468
469int crypto_alg_available(const char *name, u32 flags)
470{
471 int ret = 0;
472 struct crypto_alg *alg = crypto_alg_mod_lookup(name, 0,
473 CRYPTO_ALG_ASYNC);
474
475 if (!IS_ERR(alg)) {
476 crypto_mod_put(alg);
477 ret = 1;
478 }
479
480 return ret;
481}
482
483EXPORT_SYMBOL_GPL(crypto_alloc_tfm); 469EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
484EXPORT_SYMBOL_GPL(crypto_free_tfm); 470EXPORT_SYMBOL_GPL(crypto_free_tfm);
485EXPORT_SYMBOL_GPL(crypto_alg_available);
486 471
487int crypto_has_alg(const char *name, u32 type, u32 mask) 472int crypto_has_alg(const char *name, u32 type, u32 mask)
488{ 473{
diff --git a/crypto/digest.c b/crypto/digest.c
index 0155a94e4b15..8f4593268ce0 100644
--- a/crypto/digest.c
+++ b/crypto/digest.c
@@ -21,54 +21,6 @@
21#include "internal.h" 21#include "internal.h"
22#include "scatterwalk.h" 22#include "scatterwalk.h"
23 23
24void crypto_digest_init(struct crypto_tfm *tfm)
25{
26 struct crypto_hash *hash = crypto_hash_cast(tfm);
27 struct hash_desc desc = { .tfm = hash, .flags = tfm->crt_flags };
28
29 crypto_hash_init(&desc);
30}
31EXPORT_SYMBOL_GPL(crypto_digest_init);
32
33void crypto_digest_update(struct crypto_tfm *tfm,
34 struct scatterlist *sg, unsigned int nsg)
35{
36 struct crypto_hash *hash = crypto_hash_cast(tfm);
37 struct hash_desc desc = { .tfm = hash, .flags = tfm->crt_flags };
38 unsigned int nbytes = 0;
39 unsigned int i;
40
41 for (i = 0; i < nsg; i++)
42 nbytes += sg[i].length;
43
44 crypto_hash_update(&desc, sg, nbytes);
45}
46EXPORT_SYMBOL_GPL(crypto_digest_update);
47
48void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
49{
50 struct crypto_hash *hash = crypto_hash_cast(tfm);
51 struct hash_desc desc = { .tfm = hash, .flags = tfm->crt_flags };
52
53 crypto_hash_final(&desc, out);
54}
55EXPORT_SYMBOL_GPL(crypto_digest_final);
56
57void crypto_digest_digest(struct crypto_tfm *tfm,
58 struct scatterlist *sg, unsigned int nsg, u8 *out)
59{
60 struct crypto_hash *hash = crypto_hash_cast(tfm);
61 struct hash_desc desc = { .tfm = hash, .flags = tfm->crt_flags };
62 unsigned int nbytes = 0;
63 unsigned int i;
64
65 for (i = 0; i < nsg; i++)
66 nbytes += sg[i].length;
67
68 crypto_hash_digest(&desc, sg, nbytes, out);
69}
70EXPORT_SYMBOL_GPL(crypto_digest_digest);
71
72static int init(struct hash_desc *desc) 24static int init(struct hash_desc *desc)
73{ 25{
74 struct crypto_tfm *tfm = crypto_hash_tfm(desc->tfm); 26 struct crypto_tfm *tfm = crypto_hash_tfm(desc->tfm);
diff --git a/crypto/gf128mul.c b/crypto/gf128mul.c
new file mode 100644
index 000000000000..0a2aadfa1d85
--- /dev/null
+++ b/crypto/gf128mul.c
@@ -0,0 +1,466 @@
1/* gf128mul.c - GF(2^128) multiplication functions
2 *
3 * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.
4 * Copyright (c) 2006, Rik Snel <rsnel@cube.dyndns.org>
5 *
6 * Based on Dr Brian Gladman's (GPL'd) work published at
7 * http://fp.gladman.plus.com/cryptography_technology/index.htm
8 * See the original copyright notice below.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 */
15
16/*
17 ---------------------------------------------------------------------------
18 Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.
19
20 LICENSE TERMS
21
22 The free distribution and use of this software in both source and binary
23 form is allowed (with or without changes) provided that:
24
25 1. distributions of this source code include the above copyright
26 notice, this list of conditions and the following disclaimer;
27
28 2. distributions in binary form include the above copyright
29 notice, this list of conditions and the following disclaimer
30 in the documentation and/or other associated materials;
31
32 3. the copyright holder's name is not used to endorse products
33 built using this software without specific written permission.
34
35 ALTERNATIVELY, provided that this notice is retained in full, this product
36 may be distributed under the terms of the GNU General Public License (GPL),
37 in which case the provisions of the GPL apply INSTEAD OF those given above.
38
39 DISCLAIMER
40
41 This software is provided 'as is' with no explicit or implied warranties
42 in respect of its properties, including, but not limited to, correctness
43 and/or fitness for purpose.
44 ---------------------------------------------------------------------------
45 Issue 31/01/2006
46
47 This file provides fast multiplication in GF(128) as required by several
48 cryptographic authentication modes
49*/
50
51#include <crypto/gf128mul.h>
52#include <linux/kernel.h>
53#include <linux/module.h>
54#include <linux/slab.h>
55
56#define gf128mul_dat(q) { \
57 q(0x00), q(0x01), q(0x02), q(0x03), q(0x04), q(0x05), q(0x06), q(0x07),\
58 q(0x08), q(0x09), q(0x0a), q(0x0b), q(0x0c), q(0x0d), q(0x0e), q(0x0f),\
59 q(0x10), q(0x11), q(0x12), q(0x13), q(0x14), q(0x15), q(0x16), q(0x17),\
60 q(0x18), q(0x19), q(0x1a), q(0x1b), q(0x1c), q(0x1d), q(0x1e), q(0x1f),\
61 q(0x20), q(0x21), q(0x22), q(0x23), q(0x24), q(0x25), q(0x26), q(0x27),\
62 q(0x28), q(0x29), q(0x2a), q(0x2b), q(0x2c), q(0x2d), q(0x2e), q(0x2f),\
63 q(0x30), q(0x31), q(0x32), q(0x33), q(0x34), q(0x35), q(0x36), q(0x37),\
64 q(0x38), q(0x39), q(0x3a), q(0x3b), q(0x3c), q(0x3d), q(0x3e), q(0x3f),\
65 q(0x40), q(0x41), q(0x42), q(0x43), q(0x44), q(0x45), q(0x46), q(0x47),\
66 q(0x48), q(0x49), q(0x4a), q(0x4b), q(0x4c), q(0x4d), q(0x4e), q(0x4f),\
67 q(0x50), q(0x51), q(0x52), q(0x53), q(0x54), q(0x55), q(0x56), q(0x57),\
68 q(0x58), q(0x59), q(0x5a), q(0x5b), q(0x5c), q(0x5d), q(0x5e), q(0x5f),\
69 q(0x60), q(0x61), q(0x62), q(0x63), q(0x64), q(0x65), q(0x66), q(0x67),\
70 q(0x68), q(0x69), q(0x6a), q(0x6b), q(0x6c), q(0x6d), q(0x6e), q(0x6f),\
71 q(0x70), q(0x71), q(0x72), q(0x73), q(0x74), q(0x75), q(0x76), q(0x77),\
72 q(0x78), q(0x79), q(0x7a), q(0x7b), q(0x7c), q(0x7d), q(0x7e), q(0x7f),\
73 q(0x80), q(0x81), q(0x82), q(0x83), q(0x84), q(0x85), q(0x86), q(0x87),\
74 q(0x88), q(0x89), q(0x8a), q(0x8b), q(0x8c), q(0x8d), q(0x8e), q(0x8f),\
75 q(0x90), q(0x91), q(0x92), q(0x93), q(0x94), q(0x95), q(0x96), q(0x97),\
76 q(0x98), q(0x99), q(0x9a), q(0x9b), q(0x9c), q(0x9d), q(0x9e), q(0x9f),\
77 q(0xa0), q(0xa1), q(0xa2), q(0xa3), q(0xa4), q(0xa5), q(0xa6), q(0xa7),\
78 q(0xa8), q(0xa9), q(0xaa), q(0xab), q(0xac), q(0xad), q(0xae), q(0xaf),\
79 q(0xb0), q(0xb1), q(0xb2), q(0xb3), q(0xb4), q(0xb5), q(0xb6), q(0xb7),\
80 q(0xb8), q(0xb9), q(0xba), q(0xbb), q(0xbc), q(0xbd), q(0xbe), q(0xbf),\
81 q(0xc0), q(0xc1), q(0xc2), q(0xc3), q(0xc4), q(0xc5), q(0xc6), q(0xc7),\
82 q(0xc8), q(0xc9), q(0xca), q(0xcb), q(0xcc), q(0xcd), q(0xce), q(0xcf),\
83 q(0xd0), q(0xd1), q(0xd2), q(0xd3), q(0xd4), q(0xd5), q(0xd6), q(0xd7),\
84 q(0xd8), q(0xd9), q(0xda), q(0xdb), q(0xdc), q(0xdd), q(0xde), q(0xdf),\
85 q(0xe0), q(0xe1), q(0xe2), q(0xe3), q(0xe4), q(0xe5), q(0xe6), q(0xe7),\
86 q(0xe8), q(0xe9), q(0xea), q(0xeb), q(0xec), q(0xed), q(0xee), q(0xef),\
87 q(0xf0), q(0xf1), q(0xf2), q(0xf3), q(0xf4), q(0xf5), q(0xf6), q(0xf7),\
88 q(0xf8), q(0xf9), q(0xfa), q(0xfb), q(0xfc), q(0xfd), q(0xfe), q(0xff) \
89}
90
91/* Given the value i in 0..255 as the byte overflow when a field element
92 in GHASH is multipled by x^8, this function will return the values that
93 are generated in the lo 16-bit word of the field value by applying the
94 modular polynomial. The values lo_byte and hi_byte are returned via the
95 macro xp_fun(lo_byte, hi_byte) so that the values can be assembled into
96 memory as required by a suitable definition of this macro operating on
97 the table above
98*/
99
100#define xx(p, q) 0x##p##q
101
102#define xda_bbe(i) ( \
103 (i & 0x80 ? xx(43, 80) : 0) ^ (i & 0x40 ? xx(21, c0) : 0) ^ \
104 (i & 0x20 ? xx(10, e0) : 0) ^ (i & 0x10 ? xx(08, 70) : 0) ^ \
105 (i & 0x08 ? xx(04, 38) : 0) ^ (i & 0x04 ? xx(02, 1c) : 0) ^ \
106 (i & 0x02 ? xx(01, 0e) : 0) ^ (i & 0x01 ? xx(00, 87) : 0) \
107)
108
109#define xda_lle(i) ( \
110 (i & 0x80 ? xx(e1, 00) : 0) ^ (i & 0x40 ? xx(70, 80) : 0) ^ \
111 (i & 0x20 ? xx(38, 40) : 0) ^ (i & 0x10 ? xx(1c, 20) : 0) ^ \
112 (i & 0x08 ? xx(0e, 10) : 0) ^ (i & 0x04 ? xx(07, 08) : 0) ^ \
113 (i & 0x02 ? xx(03, 84) : 0) ^ (i & 0x01 ? xx(01, c2) : 0) \
114)
115
116static const u16 gf128mul_table_lle[256] = gf128mul_dat(xda_lle);
117static const u16 gf128mul_table_bbe[256] = gf128mul_dat(xda_bbe);
118
119/* These functions multiply a field element by x, by x^4 and by x^8
120 * in the polynomial field representation. It uses 32-bit word operations
121 * to gain speed but compensates for machine endianess and hence works
122 * correctly on both styles of machine.
123 */
124
125static void gf128mul_x_lle(be128 *r, const be128 *x)
126{
127 u64 a = be64_to_cpu(x->a);
128 u64 b = be64_to_cpu(x->b);
129 u64 _tt = gf128mul_table_lle[(b << 7) & 0xff];
130
131 r->b = cpu_to_be64((b >> 1) | (a << 63));
132 r->a = cpu_to_be64((a >> 1) ^ (_tt << 48));
133}
134
135static void gf128mul_x_bbe(be128 *r, const be128 *x)
136{
137 u64 a = be64_to_cpu(x->a);
138 u64 b = be64_to_cpu(x->b);
139 u64 _tt = gf128mul_table_bbe[a >> 63];
140
141 r->a = cpu_to_be64((a << 1) | (b >> 63));
142 r->b = cpu_to_be64((b << 1) ^ _tt);
143}
144
145static void gf128mul_x8_lle(be128 *x)
146{
147 u64 a = be64_to_cpu(x->a);
148 u64 b = be64_to_cpu(x->b);
149 u64 _tt = gf128mul_table_lle[b & 0xff];
150
151 x->b = cpu_to_be64((b >> 8) | (a << 56));
152 x->a = cpu_to_be64((a >> 8) ^ (_tt << 48));
153}
154
155static void gf128mul_x8_bbe(be128 *x)
156{
157 u64 a = be64_to_cpu(x->a);
158 u64 b = be64_to_cpu(x->b);
159 u64 _tt = gf128mul_table_bbe[a >> 56];
160
161 x->a = cpu_to_be64((a << 8) | (b >> 56));
162 x->b = cpu_to_be64((b << 8) ^ _tt);
163}
164
165void gf128mul_lle(be128 *r, const be128 *b)
166{
167 be128 p[8];
168 int i;
169
170 p[0] = *r;
171 for (i = 0; i < 7; ++i)
172 gf128mul_x_lle(&p[i + 1], &p[i]);
173
174 memset(r, 0, sizeof(r));
175 for (i = 0;;) {
176 u8 ch = ((u8 *)b)[15 - i];
177
178 if (ch & 0x80)
179 be128_xor(r, r, &p[0]);
180 if (ch & 0x40)
181 be128_xor(r, r, &p[1]);
182 if (ch & 0x20)
183 be128_xor(r, r, &p[2]);
184 if (ch & 0x10)
185 be128_xor(r, r, &p[3]);
186 if (ch & 0x08)
187 be128_xor(r, r, &p[4]);
188 if (ch & 0x04)
189 be128_xor(r, r, &p[5]);
190 if (ch & 0x02)
191 be128_xor(r, r, &p[6]);
192 if (ch & 0x01)
193 be128_xor(r, r, &p[7]);
194
195 if (++i >= 16)
196 break;
197
198 gf128mul_x8_lle(r);
199 }
200}
201EXPORT_SYMBOL(gf128mul_lle);
202
203void gf128mul_bbe(be128 *r, const be128 *b)
204{
205 be128 p[8];
206 int i;
207
208 p[0] = *r;
209 for (i = 0; i < 7; ++i)
210 gf128mul_x_bbe(&p[i + 1], &p[i]);
211
212 memset(r, 0, sizeof(r));
213 for (i = 0;;) {
214 u8 ch = ((u8 *)b)[i];
215
216 if (ch & 0x80)
217 be128_xor(r, r, &p[7]);
218 if (ch & 0x40)
219 be128_xor(r, r, &p[6]);
220 if (ch & 0x20)
221 be128_xor(r, r, &p[5]);
222 if (ch & 0x10)
223 be128_xor(r, r, &p[4]);
224 if (ch & 0x08)
225 be128_xor(r, r, &p[3]);
226 if (ch & 0x04)
227 be128_xor(r, r, &p[2]);
228 if (ch & 0x02)
229 be128_xor(r, r, &p[1]);
230 if (ch & 0x01)
231 be128_xor(r, r, &p[0]);
232
233 if (++i >= 16)
234 break;
235
236 gf128mul_x8_bbe(r);
237 }
238}
239EXPORT_SYMBOL(gf128mul_bbe);
240
241/* This version uses 64k bytes of table space.
242 A 16 byte buffer has to be multiplied by a 16 byte key
243 value in GF(128). If we consider a GF(128) value in
244 the buffer's lowest byte, we can construct a table of
245 the 256 16 byte values that result from the 256 values
246 of this byte. This requires 4096 bytes. But we also
247 need tables for each of the 16 higher bytes in the
248 buffer as well, which makes 64 kbytes in total.
249*/
250/* additional explanation
251 * t[0][BYTE] contains g*BYTE
252 * t[1][BYTE] contains g*x^8*BYTE
253 * ..
254 * t[15][BYTE] contains g*x^120*BYTE */
255struct gf128mul_64k *gf128mul_init_64k_lle(const be128 *g)
256{
257 struct gf128mul_64k *t;
258 int i, j, k;
259
260 t = kzalloc(sizeof(*t), GFP_KERNEL);
261 if (!t)
262 goto out;
263
264 for (i = 0; i < 16; i++) {
265 t->t[i] = kzalloc(sizeof(*t->t[i]), GFP_KERNEL);
266 if (!t->t[i]) {
267 gf128mul_free_64k(t);
268 t = NULL;
269 goto out;
270 }
271 }
272
273 t->t[0]->t[128] = *g;
274 for (j = 64; j > 0; j >>= 1)
275 gf128mul_x_lle(&t->t[0]->t[j], &t->t[0]->t[j + j]);
276
277 for (i = 0;;) {
278 for (j = 2; j < 256; j += j)
279 for (k = 1; k < j; ++k)
280 be128_xor(&t->t[i]->t[j + k],
281 &t->t[i]->t[j], &t->t[i]->t[k]);
282
283 if (++i >= 16)
284 break;
285
286 for (j = 128; j > 0; j >>= 1) {
287 t->t[i]->t[j] = t->t[i - 1]->t[j];
288 gf128mul_x8_lle(&t->t[i]->t[j]);
289 }
290 }
291
292out:
293 return t;
294}
295EXPORT_SYMBOL(gf128mul_init_64k_lle);
296
297struct gf128mul_64k *gf128mul_init_64k_bbe(const be128 *g)
298{
299 struct gf128mul_64k *t;
300 int i, j, k;
301
302 t = kzalloc(sizeof(*t), GFP_KERNEL);
303 if (!t)
304 goto out;
305
306 for (i = 0; i < 16; i++) {
307 t->t[i] = kzalloc(sizeof(*t->t[i]), GFP_KERNEL);
308 if (!t->t[i]) {
309 gf128mul_free_64k(t);
310 t = NULL;
311 goto out;
312 }
313 }
314
315 t->t[0]->t[1] = *g;
316 for (j = 1; j <= 64; j <<= 1)
317 gf128mul_x_bbe(&t->t[0]->t[j + j], &t->t[0]->t[j]);
318
319 for (i = 0;;) {
320 for (j = 2; j < 256; j += j)
321 for (k = 1; k < j; ++k)
322 be128_xor(&t->t[i]->t[j + k],
323 &t->t[i]->t[j], &t->t[i]->t[k]);
324
325 if (++i >= 16)
326 break;
327
328 for (j = 128; j > 0; j >>= 1) {
329 t->t[i]->t[j] = t->t[i - 1]->t[j];
330 gf128mul_x8_bbe(&t->t[i]->t[j]);
331 }
332 }
333
334out:
335 return t;
336}
337EXPORT_SYMBOL(gf128mul_init_64k_bbe);
338
339void gf128mul_free_64k(struct gf128mul_64k *t)
340{
341 int i;
342
343 for (i = 0; i < 16; i++)
344 kfree(t->t[i]);
345 kfree(t);
346}
347EXPORT_SYMBOL(gf128mul_free_64k);
348
349void gf128mul_64k_lle(be128 *a, struct gf128mul_64k *t)
350{
351 u8 *ap = (u8 *)a;
352 be128 r[1];
353 int i;
354
355 *r = t->t[0]->t[ap[0]];
356 for (i = 1; i < 16; ++i)
357 be128_xor(r, r, &t->t[i]->t[ap[i]]);
358 *a = *r;
359}
360EXPORT_SYMBOL(gf128mul_64k_lle);
361
362void gf128mul_64k_bbe(be128 *a, struct gf128mul_64k *t)
363{
364 u8 *ap = (u8 *)a;
365 be128 r[1];
366 int i;
367
368 *r = t->t[0]->t[ap[15]];
369 for (i = 1; i < 16; ++i)
370 be128_xor(r, r, &t->t[i]->t[ap[15 - i]]);
371 *a = *r;
372}
373EXPORT_SYMBOL(gf128mul_64k_bbe);
374
375/* This version uses 4k bytes of table space.
376 A 16 byte buffer has to be multiplied by a 16 byte key
377 value in GF(128). If we consider a GF(128) value in a
378 single byte, we can construct a table of the 256 16 byte
379 values that result from the 256 values of this byte.
380 This requires 4096 bytes. If we take the highest byte in
381 the buffer and use this table to get the result, we then
382 have to multiply by x^120 to get the final value. For the
383 next highest byte the result has to be multiplied by x^112
384 and so on. But we can do this by accumulating the result
385 in an accumulator starting with the result for the top
386 byte. We repeatedly multiply the accumulator value by
387 x^8 and then add in (i.e. xor) the 16 bytes of the next
388 lower byte in the buffer, stopping when we reach the
389 lowest byte. This requires a 4096 byte table.
390*/
391struct gf128mul_4k *gf128mul_init_4k_lle(const be128 *g)
392{
393 struct gf128mul_4k *t;
394 int j, k;
395
396 t = kzalloc(sizeof(*t), GFP_KERNEL);
397 if (!t)
398 goto out;
399
400 t->t[128] = *g;
401 for (j = 64; j > 0; j >>= 1)
402 gf128mul_x_lle(&t->t[j], &t->t[j+j]);
403
404 for (j = 2; j < 256; j += j)
405 for (k = 1; k < j; ++k)
406 be128_xor(&t->t[j + k], &t->t[j], &t->t[k]);
407
408out:
409 return t;
410}
411EXPORT_SYMBOL(gf128mul_init_4k_lle);
412
413struct gf128mul_4k *gf128mul_init_4k_bbe(const be128 *g)
414{
415 struct gf128mul_4k *t;
416 int j, k;
417
418 t = kzalloc(sizeof(*t), GFP_KERNEL);
419 if (!t)
420 goto out;
421
422 t->t[1] = *g;
423 for (j = 1; j <= 64; j <<= 1)
424 gf128mul_x_bbe(&t->t[j + j], &t->t[j]);
425
426 for (j = 2; j < 256; j += j)
427 for (k = 1; k < j; ++k)
428 be128_xor(&t->t[j + k], &t->t[j], &t->t[k]);
429
430out:
431 return t;
432}
433EXPORT_SYMBOL(gf128mul_init_4k_bbe);
434
435void gf128mul_4k_lle(be128 *a, struct gf128mul_4k *t)
436{
437 u8 *ap = (u8 *)a;
438 be128 r[1];
439 int i = 15;
440
441 *r = t->t[ap[15]];
442 while (i--) {
443 gf128mul_x8_lle(r);
444 be128_xor(r, r, &t->t[ap[i]]);
445 }
446 *a = *r;
447}
448EXPORT_SYMBOL(gf128mul_4k_lle);
449
450void gf128mul_4k_bbe(be128 *a, struct gf128mul_4k *t)
451{
452 u8 *ap = (u8 *)a;
453 be128 r[1];
454 int i = 0;
455
456 *r = t->t[ap[0]];
457 while (++i < 16) {
458 gf128mul_x8_bbe(r);
459 be128_xor(r, r, &t->t[ap[i]]);
460 }
461 *a = *r;
462}
463EXPORT_SYMBOL(gf128mul_4k_bbe);
464
465MODULE_LICENSE("GPL");
466MODULE_DESCRIPTION("Functions for multiplying elements of GF(2^128)");
diff --git a/crypto/lrw.c b/crypto/lrw.c
new file mode 100644
index 000000000000..56642586d84f
--- /dev/null
+++ b/crypto/lrw.c
@@ -0,0 +1,301 @@
1/* LRW: as defined by Cyril Guyot in
2 * http://grouper.ieee.org/groups/1619/email/pdf00017.pdf
3 *
4 * Copyright (c) 2006 Rik Snel <rsnel@cube.dyndns.org>
5 *
6 * Based om ecb.c
7 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14/* This implementation is checked against the test vectors in the above
15 * document and by a test vector provided by Ken Buchanan at
16 * http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html
17 *
18 * The test vectors are included in the testing module tcrypt.[ch] */
19#include <crypto/algapi.h>
20#include <linux/err.h>
21#include <linux/init.h>
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/scatterlist.h>
25#include <linux/slab.h>
26
27#include <crypto/b128ops.h>
28#include <crypto/gf128mul.h>
29
30struct priv {
31 struct crypto_cipher *child;
32 /* optimizes multiplying a random (non incrementing, as at the
33 * start of a new sector) value with key2, we could also have
34 * used 4k optimization tables or no optimization at all. In the
35 * latter case we would have to store key2 here */
36 struct gf128mul_64k *table;
37 /* stores:
38 * key2*{ 0,0,...0,0,0,0,1 }, key2*{ 0,0,...0,0,0,1,1 },
39 * key2*{ 0,0,...0,0,1,1,1 }, key2*{ 0,0,...0,1,1,1,1 }
40 * key2*{ 0,0,...1,1,1,1,1 }, etc
41 * needed for optimized multiplication of incrementing values
42 * with key2 */
43 be128 mulinc[128];
44};
45
46static inline void setbit128_bbe(void *b, int bit)
47{
48 __set_bit(bit ^ 0x78, b);
49}
50
51static int setkey(struct crypto_tfm *parent, const u8 *key,
52 unsigned int keylen)
53{
54 struct priv *ctx = crypto_tfm_ctx(parent);
55 struct crypto_cipher *child = ctx->child;
56 int err, i;
57 be128 tmp = { 0 };
58 int bsize = crypto_cipher_blocksize(child);
59
60 crypto_cipher_clear_flags(child, CRYPTO_TFM_REQ_MASK);
61 crypto_cipher_set_flags(child, crypto_tfm_get_flags(parent) &
62 CRYPTO_TFM_REQ_MASK);
63 if ((err = crypto_cipher_setkey(child, key, keylen - bsize)))
64 return err;
65 crypto_tfm_set_flags(parent, crypto_cipher_get_flags(child) &
66 CRYPTO_TFM_RES_MASK);
67
68 if (ctx->table)
69 gf128mul_free_64k(ctx->table);
70
71 /* initialize multiplication table for Key2 */
72 ctx->table = gf128mul_init_64k_bbe((be128 *)(key + keylen - bsize));
73 if (!ctx->table)
74 return -ENOMEM;
75
76 /* initialize optimization table */
77 for (i = 0; i < 128; i++) {
78 setbit128_bbe(&tmp, i);
79 ctx->mulinc[i] = tmp;
80 gf128mul_64k_bbe(&ctx->mulinc[i], ctx->table);
81 }
82
83 return 0;
84}
85
86struct sinfo {
87 be128 t;
88 struct crypto_tfm *tfm;
89 void (*fn)(struct crypto_tfm *, u8 *, const u8 *);
90};
91
92static inline void inc(be128 *iv)
93{
94 if (!(iv->b = cpu_to_be64(be64_to_cpu(iv->b) + 1)))
95 iv->a = cpu_to_be64(be64_to_cpu(iv->a) + 1);
96}
97
98static inline void lrw_round(struct sinfo *s, void *dst, const void *src)
99{
100 be128_xor(dst, &s->t, src); /* PP <- T xor P */
101 s->fn(s->tfm, dst, dst); /* CC <- E(Key2,PP) */
102 be128_xor(dst, dst, &s->t); /* C <- T xor CC */
103}
104
105/* this returns the number of consequative 1 bits starting
106 * from the right, get_index128(00 00 00 00 00 00 ... 00 00 10 FB) = 2 */
107static inline int get_index128(be128 *block)
108{
109 int x;
110 __be32 *p = (__be32 *) block;
111
112 for (p += 3, x = 0; x < 128; p--, x += 32) {
113 u32 val = be32_to_cpup(p);
114
115 if (!~val)
116 continue;
117
118 return x + ffz(val);
119 }
120
121 return x;
122}
123
124static int crypt(struct blkcipher_desc *d,
125 struct blkcipher_walk *w, struct priv *ctx,
126 void (*fn)(struct crypto_tfm *, u8 *, const u8 *))
127{
128 int err;
129 unsigned int avail;
130 const int bs = crypto_cipher_blocksize(ctx->child);
131 struct sinfo s = {
132 .tfm = crypto_cipher_tfm(ctx->child),
133 .fn = fn
134 };
135 be128 *iv;
136 u8 *wsrc;
137 u8 *wdst;
138
139 err = blkcipher_walk_virt(d, w);
140 if (!(avail = w->nbytes))
141 return err;
142
143 wsrc = w->src.virt.addr;
144 wdst = w->dst.virt.addr;
145
146 /* calculate first value of T */
147 iv = (be128 *)w->iv;
148 s.t = *iv;
149
150 /* T <- I*Key2 */
151 gf128mul_64k_bbe(&s.t, ctx->table);
152
153 goto first;
154
155 for (;;) {
156 do {
157 /* T <- I*Key2, using the optimization
158 * discussed in the specification */
159 be128_xor(&s.t, &s.t, &ctx->mulinc[get_index128(iv)]);
160 inc(iv);
161
162first:
163 lrw_round(&s, wdst, wsrc);
164
165 wsrc += bs;
166 wdst += bs;
167 } while ((avail -= bs) >= bs);
168
169 err = blkcipher_walk_done(d, w, avail);
170 if (!(avail = w->nbytes))
171 break;
172
173 wsrc = w->src.virt.addr;
174 wdst = w->dst.virt.addr;
175 }
176
177 return err;
178}
179
180static int encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
181 struct scatterlist *src, unsigned int nbytes)
182{
183 struct priv *ctx = crypto_blkcipher_ctx(desc->tfm);
184 struct blkcipher_walk w;
185
186 blkcipher_walk_init(&w, dst, src, nbytes);
187 return crypt(desc, &w, ctx,
188 crypto_cipher_alg(ctx->child)->cia_encrypt);
189}
190
191static int decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
192 struct scatterlist *src, unsigned int nbytes)
193{
194 struct priv *ctx = crypto_blkcipher_ctx(desc->tfm);
195 struct blkcipher_walk w;
196
197 blkcipher_walk_init(&w, dst, src, nbytes);
198 return crypt(desc, &w, ctx,
199 crypto_cipher_alg(ctx->child)->cia_decrypt);
200}
201
202static int init_tfm(struct crypto_tfm *tfm)
203{
204 struct crypto_instance *inst = (void *)tfm->__crt_alg;
205 struct crypto_spawn *spawn = crypto_instance_ctx(inst);
206 struct priv *ctx = crypto_tfm_ctx(tfm);
207 u32 *flags = &tfm->crt_flags;
208
209 tfm = crypto_spawn_tfm(spawn);
210 if (IS_ERR(tfm))
211 return PTR_ERR(tfm);
212
213 if (crypto_tfm_alg_blocksize(tfm) != 16) {
214 *flags |= CRYPTO_TFM_RES_BAD_BLOCK_LEN;
215 return -EINVAL;
216 }
217
218 ctx->child = crypto_cipher_cast(tfm);
219 return 0;
220}
221
222static void exit_tfm(struct crypto_tfm *tfm)
223{
224 struct priv *ctx = crypto_tfm_ctx(tfm);
225 if (ctx->table)
226 gf128mul_free_64k(ctx->table);
227 crypto_free_cipher(ctx->child);
228}
229
230static struct crypto_instance *alloc(void *param, unsigned int len)
231{
232 struct crypto_instance *inst;
233 struct crypto_alg *alg;
234
235 alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER,
236 CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC);
237 if (IS_ERR(alg))
238 return ERR_PTR(PTR_ERR(alg));
239
240 inst = crypto_alloc_instance("lrw", alg);
241 if (IS_ERR(inst))
242 goto out_put_alg;
243
244 inst->alg.cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER;
245 inst->alg.cra_priority = alg->cra_priority;
246 inst->alg.cra_blocksize = alg->cra_blocksize;
247
248 if (alg->cra_alignmask < 7) inst->alg.cra_alignmask = 7;
249 else inst->alg.cra_alignmask = alg->cra_alignmask;
250 inst->alg.cra_type = &crypto_blkcipher_type;
251
252 if (!(alg->cra_blocksize % 4))
253 inst->alg.cra_alignmask |= 3;
254 inst->alg.cra_blkcipher.ivsize = alg->cra_blocksize;
255 inst->alg.cra_blkcipher.min_keysize =
256 alg->cra_cipher.cia_min_keysize + alg->cra_blocksize;
257 inst->alg.cra_blkcipher.max_keysize =
258 alg->cra_cipher.cia_max_keysize + alg->cra_blocksize;
259
260 inst->alg.cra_ctxsize = sizeof(struct priv);
261
262 inst->alg.cra_init = init_tfm;
263 inst->alg.cra_exit = exit_tfm;
264
265 inst->alg.cra_blkcipher.setkey = setkey;
266 inst->alg.cra_blkcipher.encrypt = encrypt;
267 inst->alg.cra_blkcipher.decrypt = decrypt;
268
269out_put_alg:
270 crypto_mod_put(alg);
271 return inst;
272}
273
274static void free(struct crypto_instance *inst)
275{
276 crypto_drop_spawn(crypto_instance_ctx(inst));
277 kfree(inst);
278}
279
280static struct crypto_template crypto_tmpl = {
281 .name = "lrw",
282 .alloc = alloc,
283 .free = free,
284 .module = THIS_MODULE,
285};
286
287static int __init crypto_module_init(void)
288{
289 return crypto_register_template(&crypto_tmpl);
290}
291
292static void __exit crypto_module_exit(void)
293{
294 crypto_unregister_template(&crypto_tmpl);
295}
296
297module_init(crypto_module_init);
298module_exit(crypto_module_exit);
299
300MODULE_LICENSE("GPL");
301MODULE_DESCRIPTION("LRW block cipher mode");
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 83307420d31c..d671e8942b1f 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -906,6 +906,10 @@ static void do_test(void)
906 AES_CBC_ENC_TEST_VECTORS); 906 AES_CBC_ENC_TEST_VECTORS);
907 test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template, 907 test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template,
908 AES_CBC_DEC_TEST_VECTORS); 908 AES_CBC_DEC_TEST_VECTORS);
909 test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template,
910 AES_LRW_ENC_TEST_VECTORS);
911 test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
912 AES_LRW_DEC_TEST_VECTORS);
909 913
910 //CAST5 914 //CAST5
911 test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template, 915 test_cipher("ecb(cast5)", ENCRYPT, cast5_enc_tv_template,
@@ -977,6 +981,9 @@ static void do_test(void)
977 test_hash("hmac(sha256)", hmac_sha256_tv_template, 981 test_hash("hmac(sha256)", hmac_sha256_tv_template,
978 HMAC_SHA256_TEST_VECTORS); 982 HMAC_SHA256_TEST_VECTORS);
979 983
984 test_hash("xcbc(aes)", aes_xcbc128_tv_template,
985 XCBC_AES_TEST_VECTORS);
986
980 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS); 987 test_hash("michael_mic", michael_mic_tv_template, MICHAEL_MIC_TEST_VECTORS);
981 break; 988 break;
982 989
@@ -1052,6 +1059,10 @@ static void do_test(void)
1052 AES_CBC_ENC_TEST_VECTORS); 1059 AES_CBC_ENC_TEST_VECTORS);
1053 test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template, 1060 test_cipher("cbc(aes)", DECRYPT, aes_cbc_dec_tv_template,
1054 AES_CBC_DEC_TEST_VECTORS); 1061 AES_CBC_DEC_TEST_VECTORS);
1062 test_cipher("lrw(aes)", ENCRYPT, aes_lrw_enc_tv_template,
1063 AES_LRW_ENC_TEST_VECTORS);
1064 test_cipher("lrw(aes)", DECRYPT, aes_lrw_dec_tv_template,
1065 AES_LRW_DEC_TEST_VECTORS);
1055 break; 1066 break;
1056 1067
1057 case 11: 1068 case 11:
@@ -1191,6 +1202,10 @@ static void do_test(void)
1191 aes_speed_template); 1202 aes_speed_template);
1192 test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0, 1203 test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
1193 aes_speed_template); 1204 aes_speed_template);
1205 test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
1206 aes_lrw_speed_template);
1207 test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
1208 aes_lrw_speed_template);
1194 break; 1209 break;
1195 1210
1196 case 201: 1211 case 201:
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
index a40c4411729e..48a81362cb85 100644
--- a/crypto/tcrypt.h
+++ b/crypto/tcrypt.h
@@ -39,15 +39,15 @@ struct hash_testvec {
39struct cipher_testvec { 39struct cipher_testvec {
40 char key[MAX_KEYLEN] __attribute__ ((__aligned__(4))); 40 char key[MAX_KEYLEN] __attribute__ ((__aligned__(4)));
41 char iv[MAX_IVLEN]; 41 char iv[MAX_IVLEN];
42 char input[48]; 42 char input[512];
43 char result[48]; 43 char result[512];
44 unsigned char tap[MAX_TAP]; 44 unsigned char tap[MAX_TAP];
45 int np; 45 int np;
46 unsigned char fail; 46 unsigned char fail;
47 unsigned char wk; /* weak key flag */ 47 unsigned char wk; /* weak key flag */
48 unsigned char klen; 48 unsigned char klen;
49 unsigned char ilen; 49 unsigned short ilen;
50 unsigned char rlen; 50 unsigned short rlen;
51}; 51};
52 52
53struct cipher_speed { 53struct cipher_speed {
@@ -933,6 +933,74 @@ static struct hash_testvec hmac_sha256_tv_template[] = {
933 }, 933 },
934}; 934};
935 935
936#define XCBC_AES_TEST_VECTORS 6
937
938static struct hash_testvec aes_xcbc128_tv_template[] = {
939 {
940 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
941 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
942 .plaintext = { [0 ... 15] = 0 },
943 .digest = { 0x75, 0xf0, 0x25, 0x1d, 0x52, 0x8a, 0xc0, 0x1c,
944 0x45, 0x73, 0xdf, 0xd5, 0x84, 0xd7, 0x9f, 0x29 },
945 .psize = 0,
946 .ksize = 16,
947 }, {
948 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
949 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
950 .plaintext = { 0x00, 0x01, 0x02 },
951 .digest = { 0x5b, 0x37, 0x65, 0x80, 0xae, 0x2f, 0x19, 0xaf,
952 0xe7, 0x21, 0x9c, 0xee, 0xf1, 0x72, 0x75, 0x6f },
953 .psize = 3,
954 .ksize = 16,
955 } , {
956 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
957 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
958 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
959 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
960 .digest = { 0xd2, 0xa2, 0x46, 0xfa, 0x34, 0x9b, 0x68, 0xa7,
961 0x99, 0x98, 0xa4, 0x39, 0x4f, 0xf7, 0xa2, 0x63 },
962 .psize = 16,
963 .ksize = 16,
964 }, {
965 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
966 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
967 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
968 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
969 0x10, 0x11, 0x12, 0x13 },
970 .digest = { 0x47, 0xf5, 0x1b, 0x45, 0x64, 0x96, 0x62, 0x15,
971 0xb8, 0x98, 0x5c, 0x63, 0x05, 0x5e, 0xd3, 0x08 },
972 .tap = { 10, 10 },
973 .psize = 20,
974 .np = 2,
975 .ksize = 16,
976 }, {
977 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
978 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
979 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
980 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
981 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
982 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f },
983 .digest = { 0xf5, 0x4f, 0x0e, 0xc8, 0xd2, 0xb9, 0xf3, 0xd3,
984 0x68, 0x07, 0x73, 0x4b, 0xd5, 0x28, 0x3f, 0xd4 },
985 .psize = 32,
986 .ksize = 16,
987 }, {
988 .key = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
989 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
990 .plaintext = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
991 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
992 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
993 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
994 0x20, 0x21 },
995 .digest = { 0xbe, 0xcb, 0xb3, 0xbc, 0xcd, 0xb5, 0x18, 0xa3,
996 0x06, 0x77, 0xd5, 0x48, 0x1f, 0xb6, 0xb4, 0xd8 },
997 .tap = { 17, 17 },
998 .psize = 34,
999 .np = 2,
1000 .ksize = 16,
1001 }
1002};
1003
936/* 1004/*
937 * DES test vectors. 1005 * DES test vectors.
938 */ 1006 */
@@ -1831,6 +1899,8 @@ static struct cipher_testvec cast6_dec_tv_template[] = {
1831#define AES_DEC_TEST_VECTORS 3 1899#define AES_DEC_TEST_VECTORS 3
1832#define AES_CBC_ENC_TEST_VECTORS 2 1900#define AES_CBC_ENC_TEST_VECTORS 2
1833#define AES_CBC_DEC_TEST_VECTORS 2 1901#define AES_CBC_DEC_TEST_VECTORS 2
1902#define AES_LRW_ENC_TEST_VECTORS 8
1903#define AES_LRW_DEC_TEST_VECTORS 8
1834 1904
1835static struct cipher_testvec aes_enc_tv_template[] = { 1905static struct cipher_testvec aes_enc_tv_template[] = {
1836 { /* From FIPS-197 */ 1906 { /* From FIPS-197 */
@@ -1968,6 +2038,509 @@ static struct cipher_testvec aes_cbc_dec_tv_template[] = {
1968 }, 2038 },
1969}; 2039};
1970 2040
2041static struct cipher_testvec aes_lrw_enc_tv_template[] = {
2042 /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
2043 { /* LRW-32-AES 1 */
2044 .key = { 0x45, 0x62, 0xac, 0x25, 0xf8, 0x28, 0x17, 0x6d,
2045 0x4c, 0x26, 0x84, 0x14, 0xb5, 0x68, 0x01, 0x85,
2046 0x25, 0x8e, 0x2a, 0x05, 0xe7, 0x3e, 0x9d, 0x03,
2047 0xee, 0x5a, 0x83, 0x0c, 0xcc, 0x09, 0x4c, 0x87 },
2048 .klen = 32,
2049 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2050 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2051 .input = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2052 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2053 .ilen = 16,
2054 .result = { 0xf1, 0xb2, 0x73, 0xcd, 0x65, 0xa3, 0xdf, 0x5f,
2055 0xe9, 0x5d, 0x48, 0x92, 0x54, 0x63, 0x4e, 0xb8 },
2056 .rlen = 16,
2057 }, { /* LRW-32-AES 2 */
2058 .key = { 0x59, 0x70, 0x47, 0x14, 0xf5, 0x57, 0x47, 0x8c,
2059 0xd7, 0x79, 0xe8, 0x0f, 0x54, 0x88, 0x79, 0x44,
2060 0x0d, 0x48, 0xf0, 0xb7, 0xb1, 0x5a, 0x53, 0xea,
2061 0x1c, 0xaa, 0x6b, 0x29, 0xc2, 0xca, 0xfb, 0xaf
2062 },
2063 .klen = 32,
2064 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2065 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 },
2066 .input = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2067 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2068 .ilen = 16,
2069 .result = { 0x00, 0xc8, 0x2b, 0xae, 0x95, 0xbb, 0xcd, 0xe5,
2070 0x27, 0x4f, 0x07, 0x69, 0xb2, 0x60, 0xe1, 0x36 },
2071 .rlen = 16,
2072 }, { /* LRW-32-AES 3 */
2073 .key = { 0xd8, 0x2a, 0x91, 0x34, 0xb2, 0x6a, 0x56, 0x50,
2074 0x30, 0xfe, 0x69, 0xe2, 0x37, 0x7f, 0x98, 0x47,
2075 0xcd, 0xf9, 0x0b, 0x16, 0x0c, 0x64, 0x8f, 0xb6,
2076 0xb0, 0x0d, 0x0d, 0x1b, 0xae, 0x85, 0x87, 0x1f },
2077 .klen = 32,
2078 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2079 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2080 .input = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2081 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2082 .ilen = 16,
2083 .result = { 0x76, 0x32, 0x21, 0x83, 0xed, 0x8f, 0xf1, 0x82,
2084 0xf9, 0x59, 0x62, 0x03, 0x69, 0x0e, 0x5e, 0x01 },
2085 .rlen = 16,
2086 }, { /* LRW-32-AES 4 */
2087 .key = { 0x0f, 0x6a, 0xef, 0xf8, 0xd3, 0xd2, 0xbb, 0x15,
2088 0x25, 0x83, 0xf7, 0x3c, 0x1f, 0x01, 0x28, 0x74,
2089 0xca, 0xc6, 0xbc, 0x35, 0x4d, 0x4a, 0x65, 0x54,
2090 0x90, 0xae, 0x61, 0xcf, 0x7b, 0xae, 0xbd, 0xcc,
2091 0xad, 0xe4, 0x94, 0xc5, 0x4a, 0x29, 0xae, 0x70 },
2092 .klen = 40,
2093 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2094 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2095 .input = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2096 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2097 .ilen = 16,
2098 .result = { 0x9c, 0x0f, 0x15, 0x2f, 0x55, 0xa2, 0xd8, 0xf0,
2099 0xd6, 0x7b, 0x8f, 0x9e, 0x28, 0x22, 0xbc, 0x41 },
2100 .rlen = 16,
2101 }, { /* LRW-32-AES 5 */
2102 .key = { 0x8a, 0xd4, 0xee, 0x10, 0x2f, 0xbd, 0x81, 0xff,
2103 0xf8, 0x86, 0xce, 0xac, 0x93, 0xc5, 0xad, 0xc6,
2104 0xa0, 0x19, 0x07, 0xc0, 0x9d, 0xf7, 0xbb, 0xdd,
2105 0x52, 0x13, 0xb2, 0xb7, 0xf0, 0xff, 0x11, 0xd8,
2106 0xd6, 0x08, 0xd0, 0xcd, 0x2e, 0xb1, 0x17, 0x6f },
2107 .klen = 40,
2108 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2109 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2110 .input = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2111 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2112 .ilen = 16,
2113 .result = { 0xd4, 0x27, 0x6a, 0x7f, 0x14, 0x91, 0x3d, 0x65,
2114 0xc8, 0x60, 0x48, 0x02, 0x87, 0xe3, 0x34, 0x06 },
2115 .rlen = 16,
2116 }, { /* LRW-32-AES 6 */
2117 .key = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
2118 0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
2119 0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
2120 0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
2121 0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
2122 0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
2123 .klen = 48,
2124 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2126 .input = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2127 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2128 .ilen = 16,
2129 .result = { 0xbd, 0x06, 0xb8, 0xe1, 0xdb, 0x98, 0x89, 0x9e,
2130 0xc4, 0x98, 0xe4, 0x91, 0xcf, 0x1c, 0x70, 0x2b },
2131 .rlen = 16,
2132 }, { /* LRW-32-AES 7 */
2133 .key = { 0xfb, 0x76, 0x15, 0xb2, 0x3d, 0x80, 0x89, 0x1d,
2134 0xd4, 0x70, 0x98, 0x0b, 0xc7, 0x95, 0x84, 0xc8,
2135 0xb2, 0xfb, 0x64, 0xce, 0x60, 0x97, 0x87, 0x8d,
2136 0x17, 0xfc, 0xe4, 0x5a, 0x49, 0xe8, 0x30, 0xb7,
2137 0x6e, 0x78, 0x17, 0xe7, 0x2d, 0x5e, 0x12, 0xd4,
2138 0x60, 0x64, 0x04, 0x7a, 0xf1, 0x2f, 0x9e, 0x0c },
2139 .klen = 48,
2140 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2141 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2142 .input = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2143 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2144 .ilen = 16,
2145 .result = { 0x5b, 0x90, 0x8e, 0xc1, 0xab, 0xdd, 0x67, 0x5f,
2146 0x3d, 0x69, 0x8a, 0x95, 0x53, 0xc8, 0x9c, 0xe5 },
2147 .rlen = 16,
2148 }, {
2149/* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
2150 .key = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
2151 0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
2152 0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
2153 0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
2154 0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
2155 0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
2156 .klen = 48,
2157 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2159 .input = { 0x05, 0x11, 0xb7, 0x18, 0xab, 0xc6, 0x2d, 0xac,
2160 0x70, 0x5d, 0xf6, 0x22, 0x94, 0xcd, 0xe5, 0x6c,
2161 0x17, 0x6b, 0xf6, 0x1c, 0xf0, 0xf3, 0x6e, 0xf8,
2162 0x50, 0x38, 0x1f, 0x71, 0x49, 0xb6, 0x57, 0xd6,
2163 0x8f, 0xcb, 0x8d, 0x6b, 0xe3, 0xa6, 0x29, 0x90,
2164 0xfe, 0x2a, 0x62, 0x82, 0xae, 0x6d, 0x8b, 0xf6,
2165 0xad, 0x1e, 0x9e, 0x20, 0x5f, 0x38, 0xbe, 0x04,
2166 0xda, 0x10, 0x8e, 0xed, 0xa2, 0xa4, 0x87, 0xab,
2167 0xda, 0x6b, 0xb4, 0x0c, 0x75, 0xba, 0xd3, 0x7c,
2168 0xc9, 0xac, 0x42, 0x31, 0x95, 0x7c, 0xc9, 0x04,
2169 0xeb, 0xd5, 0x6e, 0x32, 0x69, 0x8a, 0xdb, 0xa6,
2170 0x15, 0xd7, 0x3f, 0x4f, 0x2f, 0x66, 0x69, 0x03,
2171 0x9c, 0x1f, 0x54, 0x0f, 0xde, 0x1f, 0xf3, 0x65,
2172 0x4c, 0x96, 0x12, 0xed, 0x7c, 0x92, 0x03, 0x01,
2173 0x6f, 0xbc, 0x35, 0x93, 0xac, 0xf1, 0x27, 0xf1,
2174 0xb4, 0x96, 0x82, 0x5a, 0x5f, 0xb0, 0xa0, 0x50,
2175 0x89, 0xa4, 0x8e, 0x66, 0x44, 0x85, 0xcc, 0xfd,
2176 0x33, 0x14, 0x70, 0xe3, 0x96, 0xb2, 0xc3, 0xd3,
2177 0xbb, 0x54, 0x5a, 0x1a, 0xf9, 0x74, 0xa2, 0xc5,
2178 0x2d, 0x64, 0x75, 0xdd, 0xb4, 0x54, 0xe6, 0x74,
2179 0x8c, 0xd3, 0x9d, 0x9e, 0x86, 0xab, 0x51, 0x53,
2180 0xb7, 0x93, 0x3e, 0x6f, 0xd0, 0x4e, 0x2c, 0x40,
2181 0xf6, 0xa8, 0x2e, 0x3e, 0x9d, 0xf4, 0x66, 0xa5,
2182 0x76, 0x12, 0x73, 0x44, 0x1a, 0x56, 0xd7, 0x72,
2183 0x88, 0xcd, 0x21, 0x8c, 0x4c, 0x0f, 0xfe, 0xda,
2184 0x95, 0xe0, 0x3a, 0xa6, 0xa5, 0x84, 0x46, 0xcd,
2185 0xd5, 0x3e, 0x9d, 0x3a, 0xe2, 0x67, 0xe6, 0x60,
2186 0x1a, 0xe2, 0x70, 0x85, 0x58, 0xc2, 0x1b, 0x09,
2187 0xe1, 0xd7, 0x2c, 0xca, 0xad, 0xa8, 0x8f, 0xf9,
2188 0xac, 0xb3, 0x0e, 0xdb, 0xca, 0x2e, 0xe2, 0xb8,
2189 0x51, 0x71, 0xd9, 0x3c, 0x6c, 0xf1, 0x56, 0xf8,
2190 0xea, 0x9c, 0xf1, 0xfb, 0x0c, 0xe6, 0xb7, 0x10,
2191 0x1c, 0xf8, 0xa9, 0x7c, 0xe8, 0x53, 0x35, 0xc1,
2192 0x90, 0x3e, 0x76, 0x4a, 0x74, 0xa4, 0x21, 0x2c,
2193 0xf6, 0x2c, 0x4e, 0x0f, 0x94, 0x3a, 0x88, 0x2e,
2194 0x41, 0x09, 0x6a, 0x33, 0x7d, 0xf6, 0xdd, 0x3f,
2195 0x8d, 0x23, 0x31, 0x74, 0x84, 0xeb, 0x88, 0x6e,
2196 0xcc, 0xb9, 0xbc, 0x22, 0x83, 0x19, 0x07, 0x22,
2197 0xa5, 0x2d, 0xdf, 0xa5, 0xf3, 0x80, 0x85, 0x78,
2198 0x84, 0x39, 0x6a, 0x6d, 0x6a, 0x99, 0x4f, 0xa5,
2199 0x15, 0xfe, 0x46, 0xb0, 0xe4, 0x6c, 0xa5, 0x41,
2200 0x3c, 0xce, 0x8f, 0x42, 0x60, 0x71, 0xa7, 0x75,
2201 0x08, 0x40, 0x65, 0x8a, 0x82, 0xbf, 0xf5, 0x43,
2202 0x71, 0x96, 0xa9, 0x4d, 0x44, 0x8a, 0x20, 0xbe,
2203 0xfa, 0x4d, 0xbb, 0xc0, 0x7d, 0x31, 0x96, 0x65,
2204 0xe7, 0x75, 0xe5, 0x3e, 0xfd, 0x92, 0x3b, 0xc9,
2205 0x55, 0xbb, 0x16, 0x7e, 0xf7, 0xc2, 0x8c, 0xa4,
2206 0x40, 0x1d, 0xe5, 0xef, 0x0e, 0xdf, 0xe4, 0x9a,
2207 0x62, 0x73, 0x65, 0xfd, 0x46, 0x63, 0x25, 0x3d,
2208 0x2b, 0xaf, 0xe5, 0x64, 0xfe, 0xa5, 0x5c, 0xcf,
2209 0x24, 0xf3, 0xb4, 0xac, 0x64, 0xba, 0xdf, 0x4b,
2210 0xc6, 0x96, 0x7d, 0x81, 0x2d, 0x8d, 0x97, 0xf7,
2211 0xc5, 0x68, 0x77, 0x84, 0x32, 0x2b, 0xcc, 0x85,
2212 0x74, 0x96, 0xf0, 0x12, 0x77, 0x61, 0xb9, 0xeb,
2213 0x71, 0xaa, 0x82, 0xcb, 0x1c, 0xdb, 0x89, 0xc8,
2214 0xc6, 0xb5, 0xe3, 0x5c, 0x7d, 0x39, 0x07, 0x24,
2215 0xda, 0x39, 0x87, 0x45, 0xc0, 0x2b, 0xbb, 0x01,
2216 0xac, 0xbc, 0x2a, 0x5c, 0x7f, 0xfc, 0xe8, 0xce,
2217 0x6d, 0x9c, 0x6f, 0xed, 0xd3, 0xc1, 0xa1, 0xd6,
2218 0xc5, 0x55, 0xa9, 0x66, 0x2f, 0xe1, 0xc8, 0x32,
2219 0xa6, 0x5d, 0xa4, 0x3a, 0x98, 0x73, 0xe8, 0x45,
2220 0xa4, 0xc7, 0xa8, 0xb4, 0xf6, 0x13, 0x03, 0xf6,
2221 0xe9, 0x2e, 0xc4, 0x29, 0x0f, 0x84, 0xdb, 0xc4,
2222 0x21, 0xc4, 0xc2, 0x75, 0x67, 0x89, 0x37, 0x0a },
2223 .ilen = 512,
2224 .result = { 0x1a, 0x1d, 0xa9, 0x30, 0xad, 0xf9, 0x2f, 0x9b,
2225 0xb6, 0x1d, 0xae, 0xef, 0xf0, 0x2f, 0xf8, 0x5a,
2226 0x39, 0x3c, 0xbf, 0x2a, 0xb2, 0x45, 0xb2, 0x23,
2227 0x1b, 0x63, 0x3c, 0xcf, 0xaa, 0xbe, 0xcf, 0x4e,
2228 0xfa, 0xe8, 0x29, 0xc2, 0x20, 0x68, 0x2b, 0x3c,
2229 0x2e, 0x8b, 0xf7, 0x6e, 0x25, 0xbd, 0xe3, 0x3d,
2230 0x66, 0x27, 0xd6, 0xaf, 0xd6, 0x64, 0x3e, 0xe3,
2231 0xe8, 0x58, 0x46, 0x97, 0x39, 0x51, 0x07, 0xde,
2232 0xcb, 0x37, 0xbc, 0xa9, 0xc0, 0x5f, 0x75, 0xc3,
2233 0x0e, 0x84, 0x23, 0x1d, 0x16, 0xd4, 0x1c, 0x59,
2234 0x9c, 0x1a, 0x02, 0x55, 0xab, 0x3a, 0x97, 0x1d,
2235 0xdf, 0xdd, 0xc7, 0x06, 0x51, 0xd7, 0x70, 0xae,
2236 0x23, 0xc6, 0x8c, 0xf5, 0x1e, 0xa0, 0xe5, 0x82,
2237 0xb8, 0xb2, 0xbf, 0x04, 0xa0, 0x32, 0x8e, 0x68,
2238 0xeb, 0xaf, 0x6e, 0x2d, 0x94, 0x22, 0x2f, 0xce,
2239 0x4c, 0xb5, 0x59, 0xe2, 0xa2, 0x2f, 0xa0, 0x98,
2240 0x1a, 0x97, 0xc6, 0xd4, 0xb5, 0x00, 0x59, 0xf2,
2241 0x84, 0x14, 0x72, 0xb1, 0x9a, 0x6e, 0xa3, 0x7f,
2242 0xea, 0x20, 0xe7, 0xcb, 0x65, 0x77, 0x3a, 0xdf,
2243 0xc8, 0x97, 0x67, 0x15, 0xc2, 0x2a, 0x27, 0xcc,
2244 0x18, 0x55, 0xa1, 0x24, 0x0b, 0x24, 0x24, 0xaf,
2245 0x5b, 0xec, 0x68, 0xb8, 0xc8, 0xf5, 0xba, 0x63,
2246 0xff, 0xed, 0x89, 0xce, 0xd5, 0x3d, 0x88, 0xf3,
2247 0x25, 0xef, 0x05, 0x7c, 0x3a, 0xef, 0xeb, 0xd8,
2248 0x7a, 0x32, 0x0d, 0xd1, 0x1e, 0x58, 0x59, 0x99,
2249 0x90, 0x25, 0xb5, 0x26, 0xb0, 0xe3, 0x2b, 0x6c,
2250 0x4c, 0xa9, 0x8b, 0x84, 0x4f, 0x5e, 0x01, 0x50,
2251 0x41, 0x30, 0x58, 0xc5, 0x62, 0x74, 0x52, 0x1d,
2252 0x45, 0x24, 0x6a, 0x42, 0x64, 0x4f, 0x97, 0x1c,
2253 0xa8, 0x66, 0xb5, 0x6d, 0x79, 0xd4, 0x0d, 0x48,
2254 0xc5, 0x5f, 0xf3, 0x90, 0x32, 0xdd, 0xdd, 0xe1,
2255 0xe4, 0xa9, 0x9f, 0xfc, 0xc3, 0x52, 0x5a, 0x46,
2256 0xe4, 0x81, 0x84, 0x95, 0x36, 0x59, 0x7a, 0x6b,
2257 0xaa, 0xb3, 0x60, 0xad, 0xce, 0x9f, 0x9f, 0x28,
2258 0xe0, 0x01, 0x75, 0x22, 0xc4, 0x4e, 0xa9, 0x62,
2259 0x5c, 0x62, 0x0d, 0x00, 0xcb, 0x13, 0xe8, 0x43,
2260 0x72, 0xd4, 0x2d, 0x53, 0x46, 0xb5, 0xd1, 0x16,
2261 0x22, 0x18, 0xdf, 0x34, 0x33, 0xf5, 0xd6, 0x1c,
2262 0xb8, 0x79, 0x78, 0x97, 0x94, 0xff, 0x72, 0x13,
2263 0x4c, 0x27, 0xfc, 0xcb, 0xbf, 0x01, 0x53, 0xa6,
2264 0xb4, 0x50, 0x6e, 0xde, 0xdf, 0xb5, 0x43, 0xa4,
2265 0x59, 0xdf, 0x52, 0xf9, 0x7c, 0xe0, 0x11, 0x6f,
2266 0x2d, 0x14, 0x8e, 0x24, 0x61, 0x2c, 0xe1, 0x17,
2267 0xcc, 0xce, 0x51, 0x0c, 0x19, 0x8a, 0x82, 0x30,
2268 0x94, 0xd5, 0x3d, 0x6a, 0x53, 0x06, 0x5e, 0xbd,
2269 0xb7, 0xeb, 0xfa, 0xfd, 0x27, 0x51, 0xde, 0x85,
2270 0x1e, 0x86, 0x53, 0x11, 0x53, 0x94, 0x00, 0xee,
2271 0x2b, 0x8c, 0x08, 0x2a, 0xbf, 0xdd, 0xae, 0x11,
2272 0xcb, 0x1e, 0xa2, 0x07, 0x9a, 0x80, 0xcf, 0x62,
2273 0x9b, 0x09, 0xdc, 0x95, 0x3c, 0x96, 0x8e, 0xb1,
2274 0x09, 0xbd, 0xe4, 0xeb, 0xdb, 0xca, 0x70, 0x7a,
2275 0x9e, 0xfa, 0x31, 0x18, 0x45, 0x3c, 0x21, 0x33,
2276 0xb0, 0xb3, 0x2b, 0xea, 0xf3, 0x71, 0x2d, 0xe1,
2277 0x03, 0xad, 0x1b, 0x48, 0xd4, 0x67, 0x27, 0xf0,
2278 0x62, 0xe4, 0x3d, 0xfb, 0x9b, 0x08, 0x76, 0xe7,
2279 0xdd, 0x2b, 0x01, 0x39, 0x04, 0x5a, 0x58, 0x7a,
2280 0xf7, 0x11, 0x90, 0xec, 0xbd, 0x51, 0x5c, 0x32,
2281 0x6b, 0xd7, 0x35, 0x39, 0x02, 0x6b, 0xf2, 0xa6,
2282 0xd0, 0x0d, 0x07, 0xe1, 0x06, 0xc4, 0x5b, 0x7d,
2283 0xe4, 0x6a, 0xd7, 0xee, 0x15, 0x1f, 0x83, 0xb4,
2284 0xa3, 0xa7, 0x5e, 0xc3, 0x90, 0xb7, 0xef, 0xd3,
2285 0xb7, 0x4f, 0xf8, 0x92, 0x4c, 0xb7, 0x3c, 0x29,
2286 0xcd, 0x7e, 0x2b, 0x5d, 0x43, 0xea, 0x42, 0xe7,
2287 0x74, 0x3f, 0x7d, 0x58, 0x88, 0x75, 0xde, 0x3e },
2288 .rlen = 512,
2289 }
2290};
2291
2292static struct cipher_testvec aes_lrw_dec_tv_template[] = {
2293 /* from http://grouper.ieee.org/groups/1619/email/pdf00017.pdf */
2294 /* same as enc vectors with input and result reversed */
2295 { /* LRW-32-AES 1 */
2296 .key = { 0x45, 0x62, 0xac, 0x25, 0xf8, 0x28, 0x17, 0x6d,
2297 0x4c, 0x26, 0x84, 0x14, 0xb5, 0x68, 0x01, 0x85,
2298 0x25, 0x8e, 0x2a, 0x05, 0xe7, 0x3e, 0x9d, 0x03,
2299 0xee, 0x5a, 0x83, 0x0c, 0xcc, 0x09, 0x4c, 0x87 },
2300 .klen = 32,
2301 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2302 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2303 .input = { 0xf1, 0xb2, 0x73, 0xcd, 0x65, 0xa3, 0xdf, 0x5f,
2304 0xe9, 0x5d, 0x48, 0x92, 0x54, 0x63, 0x4e, 0xb8 },
2305 .ilen = 16,
2306 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2307 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2308 .rlen = 16,
2309 }, { /* LRW-32-AES 2 */
2310 .key = { 0x59, 0x70, 0x47, 0x14, 0xf5, 0x57, 0x47, 0x8c,
2311 0xd7, 0x79, 0xe8, 0x0f, 0x54, 0x88, 0x79, 0x44,
2312 0x0d, 0x48, 0xf0, 0xb7, 0xb1, 0x5a, 0x53, 0xea,
2313 0x1c, 0xaa, 0x6b, 0x29, 0xc2, 0xca, 0xfb, 0xaf
2314 },
2315 .klen = 32,
2316 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2317 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 },
2318 .input = { 0x00, 0xc8, 0x2b, 0xae, 0x95, 0xbb, 0xcd, 0xe5,
2319 0x27, 0x4f, 0x07, 0x69, 0xb2, 0x60, 0xe1, 0x36 },
2320 .ilen = 16,
2321 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2322 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2323 .rlen = 16,
2324 }, { /* LRW-32-AES 3 */
2325 .key = { 0xd8, 0x2a, 0x91, 0x34, 0xb2, 0x6a, 0x56, 0x50,
2326 0x30, 0xfe, 0x69, 0xe2, 0x37, 0x7f, 0x98, 0x47,
2327 0xcd, 0xf9, 0x0b, 0x16, 0x0c, 0x64, 0x8f, 0xb6,
2328 0xb0, 0x0d, 0x0d, 0x1b, 0xae, 0x85, 0x87, 0x1f },
2329 .klen = 32,
2330 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2331 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2332 .input = { 0x76, 0x32, 0x21, 0x83, 0xed, 0x8f, 0xf1, 0x82,
2333 0xf9, 0x59, 0x62, 0x03, 0x69, 0x0e, 0x5e, 0x01 },
2334 .ilen = 16,
2335 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2336 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2337 .rlen = 16,
2338 }, { /* LRW-32-AES 4 */
2339 .key = { 0x0f, 0x6a, 0xef, 0xf8, 0xd3, 0xd2, 0xbb, 0x15,
2340 0x25, 0x83, 0xf7, 0x3c, 0x1f, 0x01, 0x28, 0x74,
2341 0xca, 0xc6, 0xbc, 0x35, 0x4d, 0x4a, 0x65, 0x54,
2342 0x90, 0xae, 0x61, 0xcf, 0x7b, 0xae, 0xbd, 0xcc,
2343 0xad, 0xe4, 0x94, 0xc5, 0x4a, 0x29, 0xae, 0x70 },
2344 .klen = 40,
2345 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2346 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2347 .input = { 0x9c, 0x0f, 0x15, 0x2f, 0x55, 0xa2, 0xd8, 0xf0,
2348 0xd6, 0x7b, 0x8f, 0x9e, 0x28, 0x22, 0xbc, 0x41 },
2349 .ilen = 16,
2350 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2351 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2352 .rlen = 16,
2353 }, { /* LRW-32-AES 5 */
2354 .key = { 0x8a, 0xd4, 0xee, 0x10, 0x2f, 0xbd, 0x81, 0xff,
2355 0xf8, 0x86, 0xce, 0xac, 0x93, 0xc5, 0xad, 0xc6,
2356 0xa0, 0x19, 0x07, 0xc0, 0x9d, 0xf7, 0xbb, 0xdd,
2357 0x52, 0x13, 0xb2, 0xb7, 0xf0, 0xff, 0x11, 0xd8,
2358 0xd6, 0x08, 0xd0, 0xcd, 0x2e, 0xb1, 0x17, 0x6f },
2359 .klen = 40,
2360 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2361 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2362 .input = { 0xd4, 0x27, 0x6a, 0x7f, 0x14, 0x91, 0x3d, 0x65,
2363 0xc8, 0x60, 0x48, 0x02, 0x87, 0xe3, 0x34, 0x06 },
2364 .ilen = 16,
2365 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2366 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2367 .rlen = 16,
2368 }, { /* LRW-32-AES 6 */
2369 .key = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
2370 0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
2371 0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
2372 0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
2373 0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
2374 0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
2375 .klen = 48,
2376 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2377 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2378 .input = { 0xbd, 0x06, 0xb8, 0xe1, 0xdb, 0x98, 0x89, 0x9e,
2379 0xc4, 0x98, 0xe4, 0x91, 0xcf, 0x1c, 0x70, 0x2b },
2380 .ilen = 16,
2381 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2382 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2383 .rlen = 16,
2384 }, { /* LRW-32-AES 7 */
2385 .key = { 0xfb, 0x76, 0x15, 0xb2, 0x3d, 0x80, 0x89, 0x1d,
2386 0xd4, 0x70, 0x98, 0x0b, 0xc7, 0x95, 0x84, 0xc8,
2387 0xb2, 0xfb, 0x64, 0xce, 0x60, 0x97, 0x87, 0x8d,
2388 0x17, 0xfc, 0xe4, 0x5a, 0x49, 0xe8, 0x30, 0xb7,
2389 0x6e, 0x78, 0x17, 0xe7, 0x2d, 0x5e, 0x12, 0xd4,
2390 0x60, 0x64, 0x04, 0x7a, 0xf1, 0x2f, 0x9e, 0x0c },
2391 .klen = 48,
2392 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2393 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00 },
2394 .input = { 0x5b, 0x90, 0x8e, 0xc1, 0xab, 0xdd, 0x67, 0x5f,
2395 0x3d, 0x69, 0x8a, 0x95, 0x53, 0xc8, 0x9c, 0xe5 },
2396 .ilen = 16,
2397 .result = { 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
2398 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 },
2399 .rlen = 16,
2400 }, {
2401/* http://www.mail-archive.com/stds-p1619@listserv.ieee.org/msg00173.html */
2402 .key = { 0xf8, 0xd4, 0x76, 0xff, 0xd6, 0x46, 0xee, 0x6c,
2403 0x23, 0x84, 0xcb, 0x1c, 0x77, 0xd6, 0x19, 0x5d,
2404 0xfe, 0xf1, 0xa9, 0xf3, 0x7b, 0xbc, 0x8d, 0x21,
2405 0xa7, 0x9c, 0x21, 0xf8, 0xcb, 0x90, 0x02, 0x89,
2406 0xa8, 0x45, 0x34, 0x8e, 0xc8, 0xc5, 0xb5, 0xf1,
2407 0x26, 0xf5, 0x0e, 0x76, 0xfe, 0xfd, 0x1b, 0x1e },
2408 .klen = 48,
2409 .iv = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2410 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 },
2411 .input = { 0x1a, 0x1d, 0xa9, 0x30, 0xad, 0xf9, 0x2f, 0x9b,
2412 0xb6, 0x1d, 0xae, 0xef, 0xf0, 0x2f, 0xf8, 0x5a,
2413 0x39, 0x3c, 0xbf, 0x2a, 0xb2, 0x45, 0xb2, 0x23,
2414 0x1b, 0x63, 0x3c, 0xcf, 0xaa, 0xbe, 0xcf, 0x4e,
2415 0xfa, 0xe8, 0x29, 0xc2, 0x20, 0x68, 0x2b, 0x3c,
2416 0x2e, 0x8b, 0xf7, 0x6e, 0x25, 0xbd, 0xe3, 0x3d,
2417 0x66, 0x27, 0xd6, 0xaf, 0xd6, 0x64, 0x3e, 0xe3,
2418 0xe8, 0x58, 0x46, 0x97, 0x39, 0x51, 0x07, 0xde,
2419 0xcb, 0x37, 0xbc, 0xa9, 0xc0, 0x5f, 0x75, 0xc3,
2420 0x0e, 0x84, 0x23, 0x1d, 0x16, 0xd4, 0x1c, 0x59,
2421 0x9c, 0x1a, 0x02, 0x55, 0xab, 0x3a, 0x97, 0x1d,
2422 0xdf, 0xdd, 0xc7, 0x06, 0x51, 0xd7, 0x70, 0xae,
2423 0x23, 0xc6, 0x8c, 0xf5, 0x1e, 0xa0, 0xe5, 0x82,
2424 0xb8, 0xb2, 0xbf, 0x04, 0xa0, 0x32, 0x8e, 0x68,
2425 0xeb, 0xaf, 0x6e, 0x2d, 0x94, 0x22, 0x2f, 0xce,
2426 0x4c, 0xb5, 0x59, 0xe2, 0xa2, 0x2f, 0xa0, 0x98,
2427 0x1a, 0x97, 0xc6, 0xd4, 0xb5, 0x00, 0x59, 0xf2,
2428 0x84, 0x14, 0x72, 0xb1, 0x9a, 0x6e, 0xa3, 0x7f,
2429 0xea, 0x20, 0xe7, 0xcb, 0x65, 0x77, 0x3a, 0xdf,
2430 0xc8, 0x97, 0x67, 0x15, 0xc2, 0x2a, 0x27, 0xcc,
2431 0x18, 0x55, 0xa1, 0x24, 0x0b, 0x24, 0x24, 0xaf,
2432 0x5b, 0xec, 0x68, 0xb8, 0xc8, 0xf5, 0xba, 0x63,
2433 0xff, 0xed, 0x89, 0xce, 0xd5, 0x3d, 0x88, 0xf3,
2434 0x25, 0xef, 0x05, 0x7c, 0x3a, 0xef, 0xeb, 0xd8,
2435 0x7a, 0x32, 0x0d, 0xd1, 0x1e, 0x58, 0x59, 0x99,
2436 0x90, 0x25, 0xb5, 0x26, 0xb0, 0xe3, 0x2b, 0x6c,
2437 0x4c, 0xa9, 0x8b, 0x84, 0x4f, 0x5e, 0x01, 0x50,
2438 0x41, 0x30, 0x58, 0xc5, 0x62, 0x74, 0x52, 0x1d,
2439 0x45, 0x24, 0x6a, 0x42, 0x64, 0x4f, 0x97, 0x1c,
2440 0xa8, 0x66, 0xb5, 0x6d, 0x79, 0xd4, 0x0d, 0x48,
2441 0xc5, 0x5f, 0xf3, 0x90, 0x32, 0xdd, 0xdd, 0xe1,
2442 0xe4, 0xa9, 0x9f, 0xfc, 0xc3, 0x52, 0x5a, 0x46,
2443 0xe4, 0x81, 0x84, 0x95, 0x36, 0x59, 0x7a, 0x6b,
2444 0xaa, 0xb3, 0x60, 0xad, 0xce, 0x9f, 0x9f, 0x28,
2445 0xe0, 0x01, 0x75, 0x22, 0xc4, 0x4e, 0xa9, 0x62,
2446 0x5c, 0x62, 0x0d, 0x00, 0xcb, 0x13, 0xe8, 0x43,
2447 0x72, 0xd4, 0x2d, 0x53, 0x46, 0xb5, 0xd1, 0x16,
2448 0x22, 0x18, 0xdf, 0x34, 0x33, 0xf5, 0xd6, 0x1c,
2449 0xb8, 0x79, 0x78, 0x97, 0x94, 0xff, 0x72, 0x13,
2450 0x4c, 0x27, 0xfc, 0xcb, 0xbf, 0x01, 0x53, 0xa6,
2451 0xb4, 0x50, 0x6e, 0xde, 0xdf, 0xb5, 0x43, 0xa4,
2452 0x59, 0xdf, 0x52, 0xf9, 0x7c, 0xe0, 0x11, 0x6f,
2453 0x2d, 0x14, 0x8e, 0x24, 0x61, 0x2c, 0xe1, 0x17,
2454 0xcc, 0xce, 0x51, 0x0c, 0x19, 0x8a, 0x82, 0x30,
2455 0x94, 0xd5, 0x3d, 0x6a, 0x53, 0x06, 0x5e, 0xbd,
2456 0xb7, 0xeb, 0xfa, 0xfd, 0x27, 0x51, 0xde, 0x85,
2457 0x1e, 0x86, 0x53, 0x11, 0x53, 0x94, 0x00, 0xee,
2458 0x2b, 0x8c, 0x08, 0x2a, 0xbf, 0xdd, 0xae, 0x11,
2459 0xcb, 0x1e, 0xa2, 0x07, 0x9a, 0x80, 0xcf, 0x62,
2460 0x9b, 0x09, 0xdc, 0x95, 0x3c, 0x96, 0x8e, 0xb1,
2461 0x09, 0xbd, 0xe4, 0xeb, 0xdb, 0xca, 0x70, 0x7a,
2462 0x9e, 0xfa, 0x31, 0x18, 0x45, 0x3c, 0x21, 0x33,
2463 0xb0, 0xb3, 0x2b, 0xea, 0xf3, 0x71, 0x2d, 0xe1,
2464 0x03, 0xad, 0x1b, 0x48, 0xd4, 0x67, 0x27, 0xf0,
2465 0x62, 0xe4, 0x3d, 0xfb, 0x9b, 0x08, 0x76, 0xe7,
2466 0xdd, 0x2b, 0x01, 0x39, 0x04, 0x5a, 0x58, 0x7a,
2467 0xf7, 0x11, 0x90, 0xec, 0xbd, 0x51, 0x5c, 0x32,
2468 0x6b, 0xd7, 0x35, 0x39, 0x02, 0x6b, 0xf2, 0xa6,
2469 0xd0, 0x0d, 0x07, 0xe1, 0x06, 0xc4, 0x5b, 0x7d,
2470 0xe4, 0x6a, 0xd7, 0xee, 0x15, 0x1f, 0x83, 0xb4,
2471 0xa3, 0xa7, 0x5e, 0xc3, 0x90, 0xb7, 0xef, 0xd3,
2472 0xb7, 0x4f, 0xf8, 0x92, 0x4c, 0xb7, 0x3c, 0x29,
2473 0xcd, 0x7e, 0x2b, 0x5d, 0x43, 0xea, 0x42, 0xe7,
2474 0x74, 0x3f, 0x7d, 0x58, 0x88, 0x75, 0xde, 0x3e },
2475 .ilen = 512,
2476 .result = { 0x05, 0x11, 0xb7, 0x18, 0xab, 0xc6, 0x2d, 0xac,
2477 0x70, 0x5d, 0xf6, 0x22, 0x94, 0xcd, 0xe5, 0x6c,
2478 0x17, 0x6b, 0xf6, 0x1c, 0xf0, 0xf3, 0x6e, 0xf8,
2479 0x50, 0x38, 0x1f, 0x71, 0x49, 0xb6, 0x57, 0xd6,
2480 0x8f, 0xcb, 0x8d, 0x6b, 0xe3, 0xa6, 0x29, 0x90,
2481 0xfe, 0x2a, 0x62, 0x82, 0xae, 0x6d, 0x8b, 0xf6,
2482 0xad, 0x1e, 0x9e, 0x20, 0x5f, 0x38, 0xbe, 0x04,
2483 0xda, 0x10, 0x8e, 0xed, 0xa2, 0xa4, 0x87, 0xab,
2484 0xda, 0x6b, 0xb4, 0x0c, 0x75, 0xba, 0xd3, 0x7c,
2485 0xc9, 0xac, 0x42, 0x31, 0x95, 0x7c, 0xc9, 0x04,
2486 0xeb, 0xd5, 0x6e, 0x32, 0x69, 0x8a, 0xdb, 0xa6,
2487 0x15, 0xd7, 0x3f, 0x4f, 0x2f, 0x66, 0x69, 0x03,
2488 0x9c, 0x1f, 0x54, 0x0f, 0xde, 0x1f, 0xf3, 0x65,
2489 0x4c, 0x96, 0x12, 0xed, 0x7c, 0x92, 0x03, 0x01,
2490 0x6f, 0xbc, 0x35, 0x93, 0xac, 0xf1, 0x27, 0xf1,
2491 0xb4, 0x96, 0x82, 0x5a, 0x5f, 0xb0, 0xa0, 0x50,
2492 0x89, 0xa4, 0x8e, 0x66, 0x44, 0x85, 0xcc, 0xfd,
2493 0x33, 0x14, 0x70, 0xe3, 0x96, 0xb2, 0xc3, 0xd3,
2494 0xbb, 0x54, 0x5a, 0x1a, 0xf9, 0x74, 0xa2, 0xc5,
2495 0x2d, 0x64, 0x75, 0xdd, 0xb4, 0x54, 0xe6, 0x74,
2496 0x8c, 0xd3, 0x9d, 0x9e, 0x86, 0xab, 0x51, 0x53,
2497 0xb7, 0x93, 0x3e, 0x6f, 0xd0, 0x4e, 0x2c, 0x40,
2498 0xf6, 0xa8, 0x2e, 0x3e, 0x9d, 0xf4, 0x66, 0xa5,
2499 0x76, 0x12, 0x73, 0x44, 0x1a, 0x56, 0xd7, 0x72,
2500 0x88, 0xcd, 0x21, 0x8c, 0x4c, 0x0f, 0xfe, 0xda,
2501 0x95, 0xe0, 0x3a, 0xa6, 0xa5, 0x84, 0x46, 0xcd,
2502 0xd5, 0x3e, 0x9d, 0x3a, 0xe2, 0x67, 0xe6, 0x60,
2503 0x1a, 0xe2, 0x70, 0x85, 0x58, 0xc2, 0x1b, 0x09,
2504 0xe1, 0xd7, 0x2c, 0xca, 0xad, 0xa8, 0x8f, 0xf9,
2505 0xac, 0xb3, 0x0e, 0xdb, 0xca, 0x2e, 0xe2, 0xb8,
2506 0x51, 0x71, 0xd9, 0x3c, 0x6c, 0xf1, 0x56, 0xf8,
2507 0xea, 0x9c, 0xf1, 0xfb, 0x0c, 0xe6, 0xb7, 0x10,
2508 0x1c, 0xf8, 0xa9, 0x7c, 0xe8, 0x53, 0x35, 0xc1,
2509 0x90, 0x3e, 0x76, 0x4a, 0x74, 0xa4, 0x21, 0x2c,
2510 0xf6, 0x2c, 0x4e, 0x0f, 0x94, 0x3a, 0x88, 0x2e,
2511 0x41, 0x09, 0x6a, 0x33, 0x7d, 0xf6, 0xdd, 0x3f,
2512 0x8d, 0x23, 0x31, 0x74, 0x84, 0xeb, 0x88, 0x6e,
2513 0xcc, 0xb9, 0xbc, 0x22, 0x83, 0x19, 0x07, 0x22,
2514 0xa5, 0x2d, 0xdf, 0xa5, 0xf3, 0x80, 0x85, 0x78,
2515 0x84, 0x39, 0x6a, 0x6d, 0x6a, 0x99, 0x4f, 0xa5,
2516 0x15, 0xfe, 0x46, 0xb0, 0xe4, 0x6c, 0xa5, 0x41,
2517 0x3c, 0xce, 0x8f, 0x42, 0x60, 0x71, 0xa7, 0x75,
2518 0x08, 0x40, 0x65, 0x8a, 0x82, 0xbf, 0xf5, 0x43,
2519 0x71, 0x96, 0xa9, 0x4d, 0x44, 0x8a, 0x20, 0xbe,
2520 0xfa, 0x4d, 0xbb, 0xc0, 0x7d, 0x31, 0x96, 0x65,
2521 0xe7, 0x75, 0xe5, 0x3e, 0xfd, 0x92, 0x3b, 0xc9,
2522 0x55, 0xbb, 0x16, 0x7e, 0xf7, 0xc2, 0x8c, 0xa4,
2523 0x40, 0x1d, 0xe5, 0xef, 0x0e, 0xdf, 0xe4, 0x9a,
2524 0x62, 0x73, 0x65, 0xfd, 0x46, 0x63, 0x25, 0x3d,
2525 0x2b, 0xaf, 0xe5, 0x64, 0xfe, 0xa5, 0x5c, 0xcf,
2526 0x24, 0xf3, 0xb4, 0xac, 0x64, 0xba, 0xdf, 0x4b,
2527 0xc6, 0x96, 0x7d, 0x81, 0x2d, 0x8d, 0x97, 0xf7,
2528 0xc5, 0x68, 0x77, 0x84, 0x32, 0x2b, 0xcc, 0x85,
2529 0x74, 0x96, 0xf0, 0x12, 0x77, 0x61, 0xb9, 0xeb,
2530 0x71, 0xaa, 0x82, 0xcb, 0x1c, 0xdb, 0x89, 0xc8,
2531 0xc6, 0xb5, 0xe3, 0x5c, 0x7d, 0x39, 0x07, 0x24,
2532 0xda, 0x39, 0x87, 0x45, 0xc0, 0x2b, 0xbb, 0x01,
2533 0xac, 0xbc, 0x2a, 0x5c, 0x7f, 0xfc, 0xe8, 0xce,
2534 0x6d, 0x9c, 0x6f, 0xed, 0xd3, 0xc1, 0xa1, 0xd6,
2535 0xc5, 0x55, 0xa9, 0x66, 0x2f, 0xe1, 0xc8, 0x32,
2536 0xa6, 0x5d, 0xa4, 0x3a, 0x98, 0x73, 0xe8, 0x45,
2537 0xa4, 0xc7, 0xa8, 0xb4, 0xf6, 0x13, 0x03, 0xf6,
2538 0xe9, 0x2e, 0xc4, 0x29, 0x0f, 0x84, 0xdb, 0xc4,
2539 0x21, 0xc4, 0xc2, 0x75, 0x67, 0x89, 0x37, 0x0a },
2540 .rlen = 512,
2541 }
2542};
2543
1971/* Cast5 test vectors from RFC 2144 */ 2544/* Cast5 test vectors from RFC 2144 */
1972#define CAST5_ENC_TEST_VECTORS 3 2545#define CAST5_ENC_TEST_VECTORS 3
1973#define CAST5_DEC_TEST_VECTORS 3 2546#define CAST5_DEC_TEST_VECTORS 3
@@ -3084,6 +3657,27 @@ static struct cipher_speed aes_speed_template[] = {
3084 { .klen = 0, .blen = 0, } 3657 { .klen = 0, .blen = 0, }
3085}; 3658};
3086 3659
3660static struct cipher_speed aes_lrw_speed_template[] = {
3661 { .klen = 32, .blen = 16, },
3662 { .klen = 32, .blen = 64, },
3663 { .klen = 32, .blen = 256, },
3664 { .klen = 32, .blen = 1024, },
3665 { .klen = 32, .blen = 8192, },
3666 { .klen = 40, .blen = 16, },
3667 { .klen = 40, .blen = 64, },
3668 { .klen = 40, .blen = 256, },
3669 { .klen = 40, .blen = 1024, },
3670 { .klen = 40, .blen = 8192, },
3671 { .klen = 48, .blen = 16, },
3672 { .klen = 48, .blen = 64, },
3673 { .klen = 48, .blen = 256, },
3674 { .klen = 48, .blen = 1024, },
3675 { .klen = 48, .blen = 8192, },
3676
3677 /* End marker */
3678 { .klen = 0, .blen = 0, }
3679};
3680
3087static struct cipher_speed des3_ede_speed_template[] = { 3681static struct cipher_speed des3_ede_speed_template[] = {
3088 { .klen = 24, .blen = 16, }, 3682 { .klen = 24, .blen = 16, },
3089 { .klen = 24, .blen = 64, }, 3683 { .klen = 24, .blen = 64, },
diff --git a/crypto/xcbc.c b/crypto/xcbc.c
new file mode 100644
index 000000000000..9347eb6bcf69
--- /dev/null
+++ b/crypto/xcbc.c
@@ -0,0 +1,348 @@
1/*
2 * Copyright (C)2006 USAGI/WIDE Project
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author:
19 * Kazunori Miyazawa <miyazawa@linux-ipv6.org>
20 */
21
22#include <linux/crypto.h>
23#include <linux/err.h>
24#include <linux/kernel.h>
25#include <linux/mm.h>
26#include <linux/rtnetlink.h>
27#include <linux/slab.h>
28#include <linux/scatterlist.h>
29#include "internal.h"
30
31static u_int32_t ks[12] = {0x01010101, 0x01010101, 0x01010101, 0x01010101,
32 0x02020202, 0x02020202, 0x02020202, 0x02020202,
33 0x03030303, 0x03030303, 0x03030303, 0x03030303};
34/*
35 * +------------------------
36 * | <parent tfm>
37 * +------------------------
38 * | crypto_xcbc_ctx
39 * +------------------------
40 * | odds (block size)
41 * +------------------------
42 * | prev (block size)
43 * +------------------------
44 * | key (block size)
45 * +------------------------
46 * | consts (block size * 3)
47 * +------------------------
48 */
49struct crypto_xcbc_ctx {
50 struct crypto_tfm *child;
51 u8 *odds;
52 u8 *prev;
53 u8 *key;
54 u8 *consts;
55 void (*xor)(u8 *a, const u8 *b, unsigned int bs);
56 unsigned int keylen;
57 unsigned int len;
58};
59
60static void xor_128(u8 *a, const u8 *b, unsigned int bs)
61{
62 ((u32 *)a)[0] ^= ((u32 *)b)[0];
63 ((u32 *)a)[1] ^= ((u32 *)b)[1];
64 ((u32 *)a)[2] ^= ((u32 *)b)[2];
65 ((u32 *)a)[3] ^= ((u32 *)b)[3];
66}
67
68static int _crypto_xcbc_digest_setkey(struct crypto_hash *parent,
69 struct crypto_xcbc_ctx *ctx)
70{
71 int bs = crypto_hash_blocksize(parent);
72 int err = 0;
73 u8 key1[bs];
74
75 if ((err = crypto_cipher_setkey(ctx->child, ctx->key, ctx->keylen)))
76 return err;
77
78 ctx->child->__crt_alg->cra_cipher.cia_encrypt(ctx->child, key1,
79 ctx->consts);
80
81 return crypto_cipher_setkey(ctx->child, key1, bs);
82}
83
84static int crypto_xcbc_digest_setkey(struct crypto_hash *parent,
85 const u8 *inkey, unsigned int keylen)
86{
87 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
88
89 if (keylen != crypto_tfm_alg_blocksize(ctx->child))
90 return -EINVAL;
91
92 ctx->keylen = keylen;
93 memcpy(ctx->key, inkey, keylen);
94 ctx->consts = (u8*)ks;
95
96 return _crypto_xcbc_digest_setkey(parent, ctx);
97}
98
99static int crypto_xcbc_digest_init(struct hash_desc *pdesc)
100{
101 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(pdesc->tfm);
102 int bs = crypto_hash_blocksize(pdesc->tfm);
103
104 ctx->len = 0;
105 memset(ctx->odds, 0, bs);
106 memset(ctx->prev, 0, bs);
107
108 return 0;
109}
110
111static int crypto_xcbc_digest_update(struct hash_desc *pdesc,
112 struct scatterlist *sg,
113 unsigned int nbytes)
114{
115 struct crypto_hash *parent = pdesc->tfm;
116 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
117 struct crypto_tfm *tfm = ctx->child;
118 int bs = crypto_hash_blocksize(parent);
119 unsigned int i = 0;
120
121 do {
122
123 struct page *pg = sg[i].page;
124 unsigned int offset = sg[i].offset;
125 unsigned int slen = sg[i].length;
126
127 while (slen > 0) {
128 unsigned int len = min(slen, ((unsigned int)(PAGE_SIZE)) - offset);
129 char *p = crypto_kmap(pg, 0) + offset;
130
131 /* checking the data can fill the block */
132 if ((ctx->len + len) <= bs) {
133 memcpy(ctx->odds + ctx->len, p, len);
134 ctx->len += len;
135 slen -= len;
136
137 /* checking the rest of the page */
138 if (len + offset >= PAGE_SIZE) {
139 offset = 0;
140 pg++;
141 } else
142 offset += len;
143
144 crypto_kunmap(p, 0);
145 crypto_yield(tfm->crt_flags);
146 continue;
147 }
148
149 /* filling odds with new data and encrypting it */
150 memcpy(ctx->odds + ctx->len, p, bs - ctx->len);
151 len -= bs - ctx->len;
152 p += bs - ctx->len;
153
154 ctx->xor(ctx->prev, ctx->odds, bs);
155 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, ctx->prev, ctx->prev);
156
157 /* clearing the length */
158 ctx->len = 0;
159
160 /* encrypting the rest of data */
161 while (len > bs) {
162 ctx->xor(ctx->prev, p, bs);
163 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, ctx->prev, ctx->prev);
164 p += bs;
165 len -= bs;
166 }
167
168 /* keeping the surplus of blocksize */
169 if (len) {
170 memcpy(ctx->odds, p, len);
171 ctx->len = len;
172 }
173 crypto_kunmap(p, 0);
174 crypto_yield(tfm->crt_flags);
175 slen -= min(slen, ((unsigned int)(PAGE_SIZE)) - offset);
176 offset = 0;
177 pg++;
178 }
179 nbytes-=sg[i].length;
180 i++;
181 } while (nbytes>0);
182
183 return 0;
184}
185
186static int crypto_xcbc_digest_final(struct hash_desc *pdesc, u8 *out)
187{
188 struct crypto_hash *parent = pdesc->tfm;
189 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(parent);
190 struct crypto_tfm *tfm = ctx->child;
191 int bs = crypto_hash_blocksize(parent);
192 int err = 0;
193
194 if (ctx->len == bs) {
195 u8 key2[bs];
196
197 if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0)
198 return err;
199
200 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, key2, (const u8*)(ctx->consts+bs));
201
202 ctx->xor(ctx->prev, ctx->odds, bs);
203 ctx->xor(ctx->prev, key2, bs);
204 _crypto_xcbc_digest_setkey(parent, ctx);
205
206 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, out, ctx->prev);
207 } else {
208 u8 key3[bs];
209 unsigned int rlen;
210 u8 *p = ctx->odds + ctx->len;
211 *p = 0x80;
212 p++;
213
214 rlen = bs - ctx->len -1;
215 if (rlen)
216 memset(p, 0, rlen);
217
218 if ((err = crypto_cipher_setkey(tfm, ctx->key, ctx->keylen)) != 0)
219 return err;
220
221 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, key3, (const u8*)(ctx->consts+bs*2));
222
223 ctx->xor(ctx->prev, ctx->odds, bs);
224 ctx->xor(ctx->prev, key3, bs);
225
226 _crypto_xcbc_digest_setkey(parent, ctx);
227
228 tfm->__crt_alg->cra_cipher.cia_encrypt(tfm, out, ctx->prev);
229 }
230
231 return 0;
232}
233
234static int crypto_xcbc_digest(struct hash_desc *pdesc,
235 struct scatterlist *sg, unsigned int nbytes, u8 *out)
236{
237 crypto_xcbc_digest_init(pdesc);
238 crypto_xcbc_digest_update(pdesc, sg, nbytes);
239 return crypto_xcbc_digest_final(pdesc, out);
240}
241
242static int xcbc_init_tfm(struct crypto_tfm *tfm)
243{
244 struct crypto_instance *inst = (void *)tfm->__crt_alg;
245 struct crypto_spawn *spawn = crypto_instance_ctx(inst);
246 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(__crypto_hash_cast(tfm));
247 int bs = crypto_hash_blocksize(__crypto_hash_cast(tfm));
248
249 tfm = crypto_spawn_tfm(spawn);
250 if (IS_ERR(tfm))
251 return PTR_ERR(tfm);
252
253 switch(bs) {
254 case 16:
255 ctx->xor = xor_128;
256 break;
257 default:
258 return -EINVAL;
259 }
260
261 ctx->child = crypto_cipher_cast(tfm);
262 ctx->odds = (u8*)(ctx+1);
263 ctx->prev = ctx->odds + bs;
264 ctx->key = ctx->prev + bs;
265
266 return 0;
267};
268
269static void xcbc_exit_tfm(struct crypto_tfm *tfm)
270{
271 struct crypto_xcbc_ctx *ctx = crypto_hash_ctx_aligned(__crypto_hash_cast(tfm));
272 crypto_free_cipher(ctx->child);
273}
274
275static struct crypto_instance *xcbc_alloc(void *param, unsigned int len)
276{
277 struct crypto_instance *inst;
278 struct crypto_alg *alg;
279 alg = crypto_get_attr_alg(param, len, CRYPTO_ALG_TYPE_CIPHER,
280 CRYPTO_ALG_TYPE_HASH_MASK | CRYPTO_ALG_ASYNC);
281 if (IS_ERR(alg))
282 return ERR_PTR(PTR_ERR(alg));
283
284 switch(alg->cra_blocksize) {
285 case 16:
286 break;
287 default:
288 return ERR_PTR(PTR_ERR(alg));
289 }
290
291 inst = crypto_alloc_instance("xcbc", alg);
292 if (IS_ERR(inst))
293 goto out_put_alg;
294
295 inst->alg.cra_flags = CRYPTO_ALG_TYPE_HASH;
296 inst->alg.cra_priority = alg->cra_priority;
297 inst->alg.cra_blocksize = alg->cra_blocksize;
298 inst->alg.cra_alignmask = alg->cra_alignmask;
299 inst->alg.cra_type = &crypto_hash_type;
300
301 inst->alg.cra_hash.digestsize =
302 (alg->cra_flags & CRYPTO_ALG_TYPE_MASK) ==
303 CRYPTO_ALG_TYPE_HASH ? alg->cra_hash.digestsize :
304 alg->cra_blocksize;
305 inst->alg.cra_ctxsize = sizeof(struct crypto_xcbc_ctx) +
306 ALIGN(inst->alg.cra_blocksize * 3, sizeof(void *));
307 inst->alg.cra_init = xcbc_init_tfm;
308 inst->alg.cra_exit = xcbc_exit_tfm;
309
310 inst->alg.cra_hash.init = crypto_xcbc_digest_init;
311 inst->alg.cra_hash.update = crypto_xcbc_digest_update;
312 inst->alg.cra_hash.final = crypto_xcbc_digest_final;
313 inst->alg.cra_hash.digest = crypto_xcbc_digest;
314 inst->alg.cra_hash.setkey = crypto_xcbc_digest_setkey;
315
316out_put_alg:
317 crypto_mod_put(alg);
318 return inst;
319}
320
321static void xcbc_free(struct crypto_instance *inst)
322{
323 crypto_drop_spawn(crypto_instance_ctx(inst));
324 kfree(inst);
325}
326
327static struct crypto_template crypto_xcbc_tmpl = {
328 .name = "xcbc",
329 .alloc = xcbc_alloc,
330 .free = xcbc_free,
331 .module = THIS_MODULE,
332};
333
334static int __init crypto_xcbc_module_init(void)
335{
336 return crypto_register_template(&crypto_xcbc_tmpl);
337}
338
339static void __exit crypto_xcbc_module_exit(void)
340{
341 crypto_unregister_template(&crypto_xcbc_tmpl);
342}
343
344module_init(crypto_xcbc_module_init);
345module_exit(crypto_xcbc_module_exit);
346
347MODULE_LICENSE("GPL");
348MODULE_DESCRIPTION("XCBC keyed hash algorithm");
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 8816e30fb7a4..011c0a8a2dcc 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2303,7 +2303,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
2303 * DMA cycle timing is slower/equal than the fastest PIO timing. 2303 * DMA cycle timing is slower/equal than the fastest PIO timing.
2304 */ 2304 */
2305 2305
2306 if (speed > XFER_PIO_4) { 2306 if (speed > XFER_PIO_6) {
2307 ata_timing_compute(adev, adev->pio_mode, &p, T, UT); 2307 ata_timing_compute(adev, adev->pio_mode, &p, T, UT);
2308 ata_timing_merge(&p, t, t, ATA_TIMING_ALL); 2308 ata_timing_merge(&p, t, t, ATA_TIMING_ALL);
2309 } 2309 }
@@ -4960,6 +4960,7 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
4960 if (ap->flags & ATA_FLAG_PIO_POLLING) { 4960 if (ap->flags & ATA_FLAG_PIO_POLLING) {
4961 switch (qc->tf.protocol) { 4961 switch (qc->tf.protocol) {
4962 case ATA_PROT_PIO: 4962 case ATA_PROT_PIO:
4963 case ATA_PROT_NODATA:
4963 case ATA_PROT_ATAPI: 4964 case ATA_PROT_ATAPI:
4964 case ATA_PROT_ATAPI_NODATA: 4965 case ATA_PROT_ATAPI_NODATA:
4965 qc->tf.flags |= ATA_TFLAG_POLLING; 4966 qc->tf.flags |= ATA_TFLAG_POLLING;
diff --git a/drivers/ata/sata_promise.c b/drivers/ata/sata_promise.c
index a2778cf016bc..f055874a6ec5 100644
--- a/drivers/ata/sata_promise.c
+++ b/drivers/ata/sata_promise.c
@@ -66,15 +66,17 @@ enum {
66 board_2037x = 0, /* FastTrak S150 TX2plus */ 66 board_2037x = 0, /* FastTrak S150 TX2plus */
67 board_20319 = 1, /* FastTrak S150 TX4 */ 67 board_20319 = 1, /* FastTrak S150 TX4 */
68 board_20619 = 2, /* FastTrak TX4000 */ 68 board_20619 = 2, /* FastTrak TX4000 */
69 board_20771 = 3, /* FastTrak TX2300 */ 69 board_2057x = 3, /* SATAII150 Tx2plus */
70 board_2057x = 4, /* SATAII150 Tx2plus */ 70 board_40518 = 4, /* SATAII150 Tx4 */
71 board_40518 = 5, /* SATAII150 Tx4 */
72 71
73 PDC_HAS_PATA = (1 << 1), /* PDC20375/20575 has PATA */ 72 PDC_HAS_PATA = (1 << 1), /* PDC20375/20575 has PATA */
74 73
74 /* PDC_CTLSTAT bit definitions */
75 PDC_DMA_ENABLE = (1 << 7),
76 PDC_IRQ_DISABLE = (1 << 10),
75 PDC_RESET = (1 << 11), /* HDMA reset */ 77 PDC_RESET = (1 << 11), /* HDMA reset */
76 78
77 PDC_COMMON_FLAGS = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST | 79 PDC_COMMON_FLAGS = ATA_FLAG_NO_LEGACY |
78 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI | 80 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI |
79 ATA_FLAG_PIO_POLLING, 81 ATA_FLAG_PIO_POLLING,
80 82
@@ -90,7 +92,6 @@ struct pdc_port_priv {
90 92
91struct pdc_host_priv { 93struct pdc_host_priv {
92 unsigned long flags; 94 unsigned long flags;
93 int hotplug_offset;
94}; 95};
95 96
96static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg); 97static u32 pdc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg);
@@ -101,13 +102,16 @@ static void pdc_eng_timeout(struct ata_port *ap);
101static int pdc_port_start(struct ata_port *ap); 102static int pdc_port_start(struct ata_port *ap);
102static void pdc_port_stop(struct ata_port *ap); 103static void pdc_port_stop(struct ata_port *ap);
103static void pdc_pata_phy_reset(struct ata_port *ap); 104static void pdc_pata_phy_reset(struct ata_port *ap);
104static void pdc_sata_phy_reset(struct ata_port *ap);
105static void pdc_qc_prep(struct ata_queued_cmd *qc); 105static void pdc_qc_prep(struct ata_queued_cmd *qc);
106static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 106static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
107static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf); 107static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf);
108static void pdc_irq_clear(struct ata_port *ap); 108static void pdc_irq_clear(struct ata_port *ap);
109static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc); 109static unsigned int pdc_qc_issue_prot(struct ata_queued_cmd *qc);
110static void pdc_host_stop(struct ata_host *host); 110static void pdc_host_stop(struct ata_host *host);
111static void pdc_freeze(struct ata_port *ap);
112static void pdc_thaw(struct ata_port *ap);
113static void pdc_error_handler(struct ata_port *ap);
114static void pdc_post_internal_cmd(struct ata_queued_cmd *qc);
111 115
112 116
113static struct scsi_host_template pdc_ata_sht = { 117static struct scsi_host_template pdc_ata_sht = {
@@ -136,11 +140,12 @@ static const struct ata_port_operations pdc_sata_ops = {
136 .exec_command = pdc_exec_command_mmio, 140 .exec_command = pdc_exec_command_mmio,
137 .dev_select = ata_std_dev_select, 141 .dev_select = ata_std_dev_select,
138 142
139 .phy_reset = pdc_sata_phy_reset,
140
141 .qc_prep = pdc_qc_prep, 143 .qc_prep = pdc_qc_prep,
142 .qc_issue = pdc_qc_issue_prot, 144 .qc_issue = pdc_qc_issue_prot,
143 .eng_timeout = pdc_eng_timeout, 145 .freeze = pdc_freeze,
146 .thaw = pdc_thaw,
147 .error_handler = pdc_error_handler,
148 .post_internal_cmd = pdc_post_internal_cmd,
144 .data_xfer = ata_mmio_data_xfer, 149 .data_xfer = ata_mmio_data_xfer,
145 .irq_handler = pdc_interrupt, 150 .irq_handler = pdc_interrupt,
146 .irq_clear = pdc_irq_clear, 151 .irq_clear = pdc_irq_clear,
@@ -198,23 +203,13 @@ static const struct ata_port_info pdc_port_info[] = {
198 /* board_20619 */ 203 /* board_20619 */
199 { 204 {
200 .sht = &pdc_ata_sht, 205 .sht = &pdc_ata_sht,
201 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS, 206 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SRST | ATA_FLAG_SLAVE_POSS,
202 .pio_mask = 0x1f, /* pio0-4 */ 207 .pio_mask = 0x1f, /* pio0-4 */
203 .mwdma_mask = 0x07, /* mwdma0-2 */ 208 .mwdma_mask = 0x07, /* mwdma0-2 */
204 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 209 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
205 .port_ops = &pdc_pata_ops, 210 .port_ops = &pdc_pata_ops,
206 }, 211 },
207 212
208 /* board_20771 */
209 {
210 .sht = &pdc_ata_sht,
211 .flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
212 .pio_mask = 0x1f, /* pio0-4 */
213 .mwdma_mask = 0x07, /* mwdma0-2 */
214 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
215 .port_ops = &pdc_sata_ops,
216 },
217
218 /* board_2057x */ 213 /* board_2057x */
219 { 214 {
220 .sht = &pdc_ata_sht, 215 .sht = &pdc_ata_sht,
@@ -244,6 +239,7 @@ static const struct pci_device_id pdc_ata_pci_tbl[] = {
244 { PCI_VDEVICE(PROMISE, 0x3570), board_2057x }, 239 { PCI_VDEVICE(PROMISE, 0x3570), board_2057x },
245 { PCI_VDEVICE(PROMISE, 0x3571), board_2057x }, 240 { PCI_VDEVICE(PROMISE, 0x3571), board_2057x },
246 { PCI_VDEVICE(PROMISE, 0x3574), board_2057x }, 241 { PCI_VDEVICE(PROMISE, 0x3574), board_2057x },
242 { PCI_VDEVICE(PROMISE, 0x3577), board_2057x },
247 { PCI_VDEVICE(PROMISE, 0x3d73), board_2057x }, 243 { PCI_VDEVICE(PROMISE, 0x3d73), board_2057x },
248 { PCI_VDEVICE(PROMISE, 0x3d75), board_2057x }, 244 { PCI_VDEVICE(PROMISE, 0x3d75), board_2057x },
249 245
@@ -256,15 +252,6 @@ static const struct pci_device_id pdc_ata_pci_tbl[] = {
256 252
257 { PCI_VDEVICE(PROMISE, 0x6629), board_20619 }, 253 { PCI_VDEVICE(PROMISE, 0x6629), board_20619 },
258 254
259/* TODO: remove all associated board_20771 code, as it completely
260 * duplicates board_2037x code, unless reason for separation can be
261 * divined.
262 */
263#if 0
264 { PCI_VDEVICE(PROMISE, 0x3570), board_20771 },
265#endif
266 { PCI_VDEVICE(PROMISE, 0x3577), board_20771 },
267
268 { } /* terminate list */ 255 { } /* terminate list */
269}; 256};
270 257
@@ -366,12 +353,6 @@ static void pdc_reset_port(struct ata_port *ap)
366 readl(mmio); /* flush */ 353 readl(mmio); /* flush */
367} 354}
368 355
369static void pdc_sata_phy_reset(struct ata_port *ap)
370{
371 pdc_reset_port(ap);
372 sata_phy_reset(ap);
373}
374
375static void pdc_pata_cbl_detect(struct ata_port *ap) 356static void pdc_pata_cbl_detect(struct ata_port *ap)
376{ 357{
377 u8 tmp; 358 u8 tmp;
@@ -439,6 +420,61 @@ static void pdc_qc_prep(struct ata_queued_cmd *qc)
439 } 420 }
440} 421}
441 422
423static void pdc_freeze(struct ata_port *ap)
424{
425 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
426 u32 tmp;
427
428 tmp = readl(mmio + PDC_CTLSTAT);
429 tmp |= PDC_IRQ_DISABLE;
430 tmp &= ~PDC_DMA_ENABLE;
431 writel(tmp, mmio + PDC_CTLSTAT);
432 readl(mmio + PDC_CTLSTAT); /* flush */
433}
434
435static void pdc_thaw(struct ata_port *ap)
436{
437 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr;
438 u32 tmp;
439
440 /* clear IRQ */
441 readl(mmio + PDC_INT_SEQMASK);
442
443 /* turn IRQ back on */
444 tmp = readl(mmio + PDC_CTLSTAT);
445 tmp &= ~PDC_IRQ_DISABLE;
446 writel(tmp, mmio + PDC_CTLSTAT);
447 readl(mmio + PDC_CTLSTAT); /* flush */
448}
449
450static void pdc_error_handler(struct ata_port *ap)
451{
452 ata_reset_fn_t hardreset;
453
454 if (!(ap->pflags & ATA_PFLAG_FROZEN))
455 pdc_reset_port(ap);
456
457 hardreset = NULL;
458 if (sata_scr_valid(ap))
459 hardreset = sata_std_hardreset;
460
461 /* perform recovery */
462 ata_do_eh(ap, ata_std_prereset, ata_std_softreset, hardreset,
463 ata_std_postreset);
464}
465
466static void pdc_post_internal_cmd(struct ata_queued_cmd *qc)
467{
468 struct ata_port *ap = qc->ap;
469
470 if (qc->flags & ATA_QCFLAG_FAILED)
471 qc->err_mask |= AC_ERR_OTHER;
472
473 /* make DMA engine forget about the failed command */
474 if (qc->err_mask)
475 pdc_reset_port(ap);
476}
477
442static void pdc_eng_timeout(struct ata_port *ap) 478static void pdc_eng_timeout(struct ata_port *ap)
443{ 479{
444 struct ata_host *host = ap->host; 480 struct ata_host *host = ap->host;
@@ -645,9 +681,14 @@ static void pdc_host_init(unsigned int chip_id, struct ata_probe_ent *pe)
645{ 681{
646 void __iomem *mmio = pe->mmio_base; 682 void __iomem *mmio = pe->mmio_base;
647 struct pdc_host_priv *hp = pe->private_data; 683 struct pdc_host_priv *hp = pe->private_data;
648 int hotplug_offset = hp->hotplug_offset; 684 int hotplug_offset;
649 u32 tmp; 685 u32 tmp;
650 686
687 if (hp->flags & PDC_FLAG_GEN_II)
688 hotplug_offset = PDC2_SATA_PLUG_CSR;
689 else
690 hotplug_offset = PDC_SATA_PLUG_CSR;
691
651 /* 692 /*
652 * Except for the hotplug stuff, this is voodoo from the 693 * Except for the hotplug stuff, this is voodoo from the
653 * Promise driver. Label this entire section 694 * Promise driver. Label this entire section
@@ -742,8 +783,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
742 goto err_out_free_ent; 783 goto err_out_free_ent;
743 } 784 }
744 785
745 /* Set default hotplug offset */
746 hp->hotplug_offset = PDC_SATA_PLUG_CSR;
747 probe_ent->private_data = hp; 786 probe_ent->private_data = hp;
748 787
749 probe_ent->sht = pdc_port_info[board_idx].sht; 788 probe_ent->sht = pdc_port_info[board_idx].sht;
@@ -767,8 +806,6 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
767 switch (board_idx) { 806 switch (board_idx) {
768 case board_40518: 807 case board_40518:
769 hp->flags |= PDC_FLAG_GEN_II; 808 hp->flags |= PDC_FLAG_GEN_II;
770 /* Override hotplug offset for SATAII150 */
771 hp->hotplug_offset = PDC2_SATA_PLUG_CSR;
772 /* Fall through */ 809 /* Fall through */
773 case board_20319: 810 case board_20319:
774 probe_ent->n_ports = 4; 811 probe_ent->n_ports = 4;
@@ -780,10 +817,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
780 probe_ent->port[3].scr_addr = base + 0x700; 817 probe_ent->port[3].scr_addr = base + 0x700;
781 break; 818 break;
782 case board_2057x: 819 case board_2057x:
783 case board_20771:
784 hp->flags |= PDC_FLAG_GEN_II; 820 hp->flags |= PDC_FLAG_GEN_II;
785 /* Override hotplug offset for SATAII150 */
786 hp->hotplug_offset = PDC2_SATA_PLUG_CSR;
787 /* Fall through */ 821 /* Fall through */
788 case board_2037x: 822 case board_2037x:
789 probe_ent->n_ports = 2; 823 probe_ent->n_ports = 2;
diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile
index b5077ce8cb40..1b16f8166b09 100644
--- a/drivers/atm/Makefile
+++ b/drivers/atm/Makefile
@@ -41,7 +41,7 @@ ifeq ($(CONFIG_ATM_FORE200E_PCA),y)
41 # guess the target endianess to choose the right PCA-200E firmware image 41 # guess the target endianess to choose the right PCA-200E firmware image
42 ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y) 42 ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y)
43 byteorder.h := include$(if $(patsubst $(srctree),,$(objtree)),2)/asm/byteorder.h 43 byteorder.h := include$(if $(patsubst $(srctree),,$(objtree)),2)/asm/byteorder.h
44 CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2) 44 CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) $(CPPFLAGS) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2)
45 endif 45 endif
46endif 46endif
47 47
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index c7314a79da0f..7d9b4e52f0bf 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -820,7 +820,7 @@ he_init_group(struct he_dev *he_dev, int group)
820 void *cpuaddr; 820 void *cpuaddr;
821 821
822#ifdef USE_RBPS_POOL 822#ifdef USE_RBPS_POOL
823 cpuaddr = pci_pool_alloc(he_dev->rbps_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle); 823 cpuaddr = pci_pool_alloc(he_dev->rbps_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
824 if (cpuaddr == NULL) 824 if (cpuaddr == NULL)
825 return -ENOMEM; 825 return -ENOMEM;
826#else 826#else
@@ -884,7 +884,7 @@ he_init_group(struct he_dev *he_dev, int group)
884 void *cpuaddr; 884 void *cpuaddr;
885 885
886#ifdef USE_RBPL_POOL 886#ifdef USE_RBPL_POOL
887 cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, SLAB_KERNEL|SLAB_DMA, &dma_handle); 887 cpuaddr = pci_pool_alloc(he_dev->rbpl_pool, GFP_KERNEL|GFP_DMA, &dma_handle);
888 if (cpuaddr == NULL) 888 if (cpuaddr == NULL)
889 return -ENOMEM; 889 return -ENOMEM;
890#else 890#else
@@ -1724,7 +1724,7 @@ __alloc_tpd(struct he_dev *he_dev)
1724 struct he_tpd *tpd; 1724 struct he_tpd *tpd;
1725 dma_addr_t dma_handle; 1725 dma_addr_t dma_handle;
1726 1726
1727 tpd = pci_pool_alloc(he_dev->tpd_pool, SLAB_ATOMIC|SLAB_DMA, &dma_handle); 1727 tpd = pci_pool_alloc(he_dev->tpd_pool, GFP_ATOMIC|GFP_DMA, &dma_handle);
1728 if (tpd == NULL) 1728 if (tpd == NULL)
1729 return NULL; 1729 return NULL;
1730 1730
diff --git a/drivers/base/core.c b/drivers/base/core.c
index e4b530ef757d..67b79a7592a9 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -386,6 +386,7 @@ void device_initialize(struct device *dev)
386 INIT_LIST_HEAD(&dev->node); 386 INIT_LIST_HEAD(&dev->node);
387 init_MUTEX(&dev->sem); 387 init_MUTEX(&dev->sem);
388 device_init_wakeup(dev, 0); 388 device_init_wakeup(dev, 0);
389 set_dev_node(dev, -1);
389} 390}
390 391
391#ifdef CONFIG_SYSFS_DEPRECATED 392#ifdef CONFIG_SYSFS_DEPRECATED
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 1f745f12f94e..7fd095efaebd 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -104,8 +104,8 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
104 104
105/* 105/*
106 * register_cpu - Setup a driverfs device for a CPU. 106 * register_cpu - Setup a driverfs device for a CPU.
107 * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to 107 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
108 * generate a control file in sysfs for this CPU. 108 * sysfs for this CPU.
109 * @num - CPU number to use when creating the device. 109 * @num - CPU number to use when creating the device.
110 * 110 *
111 * Initialize and register the CPU device. 111 * Initialize and register the CPU device.
@@ -119,7 +119,7 @@ int __devinit register_cpu(struct cpu *cpu, int num)
119 119
120 error = sysdev_register(&cpu->sysdev); 120 error = sysdev_register(&cpu->sysdev);
121 121
122 if (!error && !cpu->no_control) 122 if (!error && cpu->hotpluggable)
123 register_cpu_control(cpu); 123 register_cpu_control(cpu);
124 if (!error) 124 if (!error)
125 cpu_sys_devices[num] = &cpu->sysdev; 125 cpu_sys_devices[num] = &cpu->sysdev;
diff --git a/drivers/base/dmapool.c b/drivers/base/dmapool.c
index b2efbd4cf710..dbe0735f8c9e 100644
--- a/drivers/base/dmapool.c
+++ b/drivers/base/dmapool.c
@@ -126,7 +126,7 @@ dma_pool_create (const char *name, struct device *dev,
126 } else if (allocation < size) 126 } else if (allocation < size)
127 return NULL; 127 return NULL;
128 128
129 if (!(retval = kmalloc (sizeof *retval, SLAB_KERNEL))) 129 if (!(retval = kmalloc (sizeof *retval, GFP_KERNEL)))
130 return retval; 130 return retval;
131 131
132 strlcpy (retval->name, name, sizeof retval->name); 132 strlcpy (retval->name, name, sizeof retval->name);
@@ -297,7 +297,7 @@ restart:
297 } 297 }
298 } 298 }
299 } 299 }
300 if (!(page = pool_alloc_page (pool, SLAB_ATOMIC))) { 300 if (!(page = pool_alloc_page (pool, GFP_ATOMIC))) {
301 if (mem_flags & __GFP_WAIT) { 301 if (mem_flags & __GFP_WAIT) {
302 DECLARE_WAITQUEUE (wait, current); 302 DECLARE_WAITQUEUE (wait, current);
303 303
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index c6b7d9c4b651..74b96795d2f5 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -290,9 +290,8 @@ static CLASS_ATTR(block_size_bytes, 0444, print_block_size, NULL);
290 290
291static int block_size_init(void) 291static int block_size_init(void)
292{ 292{
293 sysfs_create_file(&memory_sysdev_class.kset.kobj, 293 return sysfs_create_file(&memory_sysdev_class.kset.kobj,
294 &class_attr_block_size_bytes.attr); 294 &class_attr_block_size_bytes.attr);
295 return 0;
296} 295}
297 296
298/* 297/*
@@ -323,12 +322,14 @@ static CLASS_ATTR(probe, 0700, NULL, memory_probe_store);
323 322
324static int memory_probe_init(void) 323static int memory_probe_init(void)
325{ 324{
326 sysfs_create_file(&memory_sysdev_class.kset.kobj, 325 return sysfs_create_file(&memory_sysdev_class.kset.kobj,
327 &class_attr_probe.attr); 326 &class_attr_probe.attr);
328 return 0;
329} 327}
330#else 328#else
331#define memory_probe_init(...) do {} while (0) 329static inline int memory_probe_init(void)
330{
331 return 0;
332}
332#endif 333#endif
333 334
334/* 335/*
@@ -431,9 +432,12 @@ int __init memory_dev_init(void)
431{ 432{
432 unsigned int i; 433 unsigned int i;
433 int ret; 434 int ret;
435 int err;
434 436
435 memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops; 437 memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops;
436 ret = sysdev_class_register(&memory_sysdev_class); 438 ret = sysdev_class_register(&memory_sysdev_class);
439 if (ret)
440 goto out;
437 441
438 /* 442 /*
439 * Create entries for memory sections that were found 443 * Create entries for memory sections that were found
@@ -442,11 +446,19 @@ int __init memory_dev_init(void)
442 for (i = 0; i < NR_MEM_SECTIONS; i++) { 446 for (i = 0; i < NR_MEM_SECTIONS; i++) {
443 if (!valid_section_nr(i)) 447 if (!valid_section_nr(i))
444 continue; 448 continue;
445 add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0); 449 err = add_memory_block(0, __nr_to_section(i), MEM_ONLINE, 0);
450 if (!ret)
451 ret = err;
446 } 452 }
447 453
448 memory_probe_init(); 454 err = memory_probe_init();
449 block_size_init(); 455 if (!ret)
450 456 ret = err;
457 err = block_size_init();
458 if (!ret)
459 ret = err;
460out:
461 if (ret)
462 printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret);
451 return ret; 463 return ret;
452} 464}
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index 3d12b85b0962..067a9e8bc377 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -108,7 +108,6 @@ static int __cpuinit topology_add_dev(unsigned int cpu)
108 return rc; 108 return rc;
109} 109}
110 110
111#ifdef CONFIG_HOTPLUG_CPU
112static void __cpuinit topology_remove_dev(unsigned int cpu) 111static void __cpuinit topology_remove_dev(unsigned int cpu)
113{ 112{
114 struct sys_device *sys_dev = get_cpu_sysdev(cpu); 113 struct sys_device *sys_dev = get_cpu_sysdev(cpu);
@@ -136,7 +135,6 @@ static int __cpuinit topology_cpu_callback(struct notifier_block *nfb,
136 } 135 }
137 return rc ? NOTIFY_BAD : NOTIFY_OK; 136 return rc ? NOTIFY_BAD : NOTIFY_OK;
138} 137}
139#endif
140 138
141static int __cpuinit topology_sysfs_init(void) 139static int __cpuinit topology_sysfs_init(void)
142{ 140{
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 742d07403101..8d81a3a64c07 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -324,13 +324,13 @@ static boolean DAC960_CreateAuxiliaryStructures(DAC960_Controller_T *Controller)
324 Command->Next = Controller->FreeCommands; 324 Command->Next = Controller->FreeCommands;
325 Controller->FreeCommands = Command; 325 Controller->FreeCommands = Command;
326 Controller->Commands[CommandIdentifier-1] = Command; 326 Controller->Commands[CommandIdentifier-1] = Command;
327 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, SLAB_ATOMIC, 327 ScatterGatherCPU = pci_pool_alloc(ScatterGatherPool, GFP_ATOMIC,
328 &ScatterGatherDMA); 328 &ScatterGatherDMA);
329 if (ScatterGatherCPU == NULL) 329 if (ScatterGatherCPU == NULL)
330 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION"); 330 return DAC960_Failure(Controller, "AUXILIARY STRUCTURE CREATION");
331 331
332 if (RequestSensePool != NULL) { 332 if (RequestSensePool != NULL) {
333 RequestSenseCPU = pci_pool_alloc(RequestSensePool, SLAB_ATOMIC, 333 RequestSenseCPU = pci_pool_alloc(RequestSensePool, GFP_ATOMIC,
334 &RequestSenseDMA); 334 &RequestSenseDMA);
335 if (RequestSenseCPU == NULL) { 335 if (RequestSenseCPU == NULL) {
336 pci_pool_free(ScatterGatherPool, ScatterGatherCPU, 336 pci_pool_free(ScatterGatherPool, ScatterGatherCPU,
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 17dc22282e14..85072446d772 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -168,7 +168,8 @@ config BLK_CPQ_CISS_DA
168 168
169config CISS_SCSI_TAPE 169config CISS_SCSI_TAPE
170 bool "SCSI tape drive support for Smart Array 5xxx" 170 bool "SCSI tape drive support for Smart Array 5xxx"
171 depends on BLK_CPQ_CISS_DA && SCSI && PROC_FS 171 depends on BLK_CPQ_CISS_DA && PROC_FS
172 depends on SCSI=y || SCSI=BLK_CPQ_CISS_DA
172 help 173 help
173 When enabled (Y), this option allows SCSI tape drives and SCSI medium 174 When enabled (Y), this option allows SCSI tape drives and SCSI medium
174 changers (tape robots) to be accessed via a Compaq 5xxx array 175 changers (tape robots) to be accessed via a Compaq 5xxx array
@@ -305,6 +306,7 @@ config BLK_DEV_LOOP
305config BLK_DEV_CRYPTOLOOP 306config BLK_DEV_CRYPTOLOOP
306 tristate "Cryptoloop Support" 307 tristate "Cryptoloop Support"
307 select CRYPTO 308 select CRYPTO
309 select CRYPTO_CBC
308 depends on BLK_DEV_LOOP 310 depends on BLK_DEV_LOOP
309 ---help--- 311 ---help---
310 Say Y here if you want to be able to use the ciphers that are 312 Say Y here if you want to be able to use the ciphers that are
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c
index aa25f8b09fe3..478489c568a4 100644
--- a/drivers/block/aoe/aoeblk.c
+++ b/drivers/block/aoe/aoeblk.c
@@ -12,7 +12,7 @@
12#include <linux/netdevice.h> 12#include <linux/netdevice.h>
13#include "aoe.h" 13#include "aoe.h"
14 14
15static kmem_cache_t *buf_pool_cache; 15static struct kmem_cache *buf_pool_cache;
16 16
17static ssize_t aoedisk_show_state(struct gendisk * disk, char *page) 17static ssize_t aoedisk_show_state(struct gendisk * disk, char *page)
18{ 18{
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 4105c3bf3476..892e092afe9a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -47,14 +47,15 @@
47#include <linux/completion.h> 47#include <linux/completion.h>
48 48
49#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) 49#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
50#define DRIVER_NAME "HP CISS Driver (v 3.6.10)" 50#define DRIVER_NAME "HP CISS Driver (v 3.6.14)"
51#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,10) 51#define DRIVER_VERSION CCISS_DRIVER_VERSION(3,6,14)
52 52
53/* Embedded module documentation macros - see modules.h */ 53/* Embedded module documentation macros - see modules.h */
54MODULE_AUTHOR("Hewlett-Packard Company"); 54MODULE_AUTHOR("Hewlett-Packard Company");
55MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.10"); 55MODULE_DESCRIPTION("Driver for HP Controller SA5xxx SA6xxx version 3.6.14");
56MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400" 56MODULE_SUPPORTED_DEVICE("HP SA5i SA5i+ SA532 SA5300 SA5312 SA641 SA642 SA6400"
57 " SA6i P600 P800 P400 P400i E200 E200i E500"); 57 " SA6i P600 P800 P400 P400i E200 E200i E500");
58MODULE_VERSION("3.6.14");
58MODULE_LICENSE("GPL"); 59MODULE_LICENSE("GPL");
59 60
60#include "cciss_cmd.h" 61#include "cciss_cmd.h"
@@ -81,7 +82,9 @@ static const struct pci_device_id cciss_pci_device_id[] = {
81 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3213}, 82 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3213},
82 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3214}, 83 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3214},
83 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3215}, 84 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSD, 0x103C, 0x3215},
84 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3233}, 85 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSC, 0x103C, 0x3237},
86 {PCI_VENDOR_ID_HP, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
87 PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0},
85 {0,} 88 {0,}
86}; 89};
87 90
@@ -90,27 +93,29 @@ MODULE_DEVICE_TABLE(pci, cciss_pci_device_id);
90/* board_id = Subsystem Device ID & Vendor ID 93/* board_id = Subsystem Device ID & Vendor ID
91 * product = Marketing Name for the board 94 * product = Marketing Name for the board
92 * access = Address of the struct of function pointers 95 * access = Address of the struct of function pointers
96 * nr_cmds = Number of commands supported by controller
93 */ 97 */
94static struct board_type products[] = { 98static struct board_type products[] = {
95 {0x40700E11, "Smart Array 5300", &SA5_access}, 99 {0x40700E11, "Smart Array 5300", &SA5_access, 512},
96 {0x40800E11, "Smart Array 5i", &SA5B_access}, 100 {0x40800E11, "Smart Array 5i", &SA5B_access, 512},
97 {0x40820E11, "Smart Array 532", &SA5B_access}, 101 {0x40820E11, "Smart Array 532", &SA5B_access, 512},
98 {0x40830E11, "Smart Array 5312", &SA5B_access}, 102 {0x40830E11, "Smart Array 5312", &SA5B_access, 512},
99 {0x409A0E11, "Smart Array 641", &SA5_access}, 103 {0x409A0E11, "Smart Array 641", &SA5_access, 512},
100 {0x409B0E11, "Smart Array 642", &SA5_access}, 104 {0x409B0E11, "Smart Array 642", &SA5_access, 512},
101 {0x409C0E11, "Smart Array 6400", &SA5_access}, 105 {0x409C0E11, "Smart Array 6400", &SA5_access, 512},
102 {0x409D0E11, "Smart Array 6400 EM", &SA5_access}, 106 {0x409D0E11, "Smart Array 6400 EM", &SA5_access, 512},
103 {0x40910E11, "Smart Array 6i", &SA5_access}, 107 {0x40910E11, "Smart Array 6i", &SA5_access, 512},
104 {0x3225103C, "Smart Array P600", &SA5_access}, 108 {0x3225103C, "Smart Array P600", &SA5_access, 512},
105 {0x3223103C, "Smart Array P800", &SA5_access}, 109 {0x3223103C, "Smart Array P800", &SA5_access, 512},
106 {0x3234103C, "Smart Array P400", &SA5_access}, 110 {0x3234103C, "Smart Array P400", &SA5_access, 512},
107 {0x3235103C, "Smart Array P400i", &SA5_access}, 111 {0x3235103C, "Smart Array P400i", &SA5_access, 512},
108 {0x3211103C, "Smart Array E200i", &SA5_access}, 112 {0x3211103C, "Smart Array E200i", &SA5_access, 120},
109 {0x3212103C, "Smart Array E200", &SA5_access}, 113 {0x3212103C, "Smart Array E200", &SA5_access, 120},
110 {0x3213103C, "Smart Array E200i", &SA5_access}, 114 {0x3213103C, "Smart Array E200i", &SA5_access, 120},
111 {0x3214103C, "Smart Array E200i", &SA5_access}, 115 {0x3214103C, "Smart Array E200i", &SA5_access, 120},
112 {0x3215103C, "Smart Array E200i", &SA5_access}, 116 {0x3215103C, "Smart Array E200i", &SA5_access, 120},
113 {0x3233103C, "Smart Array E500", &SA5_access}, 117 {0x3237103C, "Smart Array E500", &SA5_access, 512},
118 {0xFFFF103C, "Unknown Smart Array", &SA5_access, 120},
114}; 119};
115 120
116/* How long to wait (in milliseconds) for board to go into simple mode */ 121/* How long to wait (in milliseconds) for board to go into simple mode */
@@ -121,7 +126,6 @@ static struct board_type products[] = {
121#define MAX_CMD_RETRIES 3 126#define MAX_CMD_RETRIES 3
122 127
123#define READ_AHEAD 1024 128#define READ_AHEAD 1024
124#define NR_CMDS 384 /* #commands that can be outstanding */
125#define MAX_CTLR 32 129#define MAX_CTLR 32
126 130
127/* Originally cciss driver only supports 8 major numbers */ 131/* Originally cciss driver only supports 8 major numbers */
@@ -137,7 +141,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
137 unsigned int cmd, unsigned long arg); 141 unsigned int cmd, unsigned long arg);
138static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo); 142static int cciss_getgeo(struct block_device *bdev, struct hd_geometry *geo);
139 143
140static int revalidate_allvol(ctlr_info_t *host);
141static int cciss_revalidate(struct gendisk *disk); 144static int cciss_revalidate(struct gendisk *disk);
142static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk); 145static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk);
143static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, 146static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
@@ -265,6 +268,7 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
265 "Firmware Version: %c%c%c%c\n" 268 "Firmware Version: %c%c%c%c\n"
266 "IRQ: %d\n" 269 "IRQ: %d\n"
267 "Logical drives: %d\n" 270 "Logical drives: %d\n"
271 "Max sectors: %d\n"
268 "Current Q depth: %d\n" 272 "Current Q depth: %d\n"
269 "Current # commands on controller: %d\n" 273 "Current # commands on controller: %d\n"
270 "Max Q depth since init: %d\n" 274 "Max Q depth since init: %d\n"
@@ -275,7 +279,9 @@ static int cciss_proc_get_info(char *buffer, char **start, off_t offset,
275 (unsigned long)h->board_id, 279 (unsigned long)h->board_id,
276 h->firm_ver[0], h->firm_ver[1], h->firm_ver[2], 280 h->firm_ver[0], h->firm_ver[1], h->firm_ver[2],
277 h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT], 281 h->firm_ver[3], (unsigned int)h->intr[SIMPLE_MODE_INT],
278 h->num_luns, h->Qdepth, h->commands_outstanding, 282 h->num_luns,
283 h->cciss_max_sectors,
284 h->Qdepth, h->commands_outstanding,
279 h->maxQsinceinit, h->max_outstanding, h->maxSG); 285 h->maxQsinceinit, h->max_outstanding, h->maxSG);
280 286
281 pos += size; 287 pos += size;
@@ -400,8 +406,8 @@ static CommandList_struct *cmd_alloc(ctlr_info_t *h, int get_from_pool)
400 } else { /* get it out of the controllers pool */ 406 } else { /* get it out of the controllers pool */
401 407
402 do { 408 do {
403 i = find_first_zero_bit(h->cmd_pool_bits, NR_CMDS); 409 i = find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds);
404 if (i == NR_CMDS) 410 if (i == h->nr_cmds)
405 return NULL; 411 return NULL;
406 } while (test_and_set_bit 412 } while (test_and_set_bit
407 (i & (BITS_PER_LONG - 1), 413 (i & (BITS_PER_LONG - 1),
@@ -487,7 +493,7 @@ static int cciss_open(struct inode *inode, struct file *filep)
487 * but I'm already using way to many device nodes to claim another one 493 * but I'm already using way to many device nodes to claim another one
488 * for "raw controller". 494 * for "raw controller".
489 */ 495 */
490 if (drv->nr_blocks == 0) { 496 if (drv->heads == 0) {
491 if (iminor(inode) != 0) { /* not node 0? */ 497 if (iminor(inode) != 0) { /* not node 0? */
492 /* if not node 0 make sure it is a partition = 0 */ 498 /* if not node 0 make sure it is a partition = 0 */
493 if (iminor(inode) & 0x0f) { 499 if (iminor(inode) & 0x0f) {
@@ -850,9 +856,7 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
850 } 856 }
851 857
852 case CCISS_REVALIDVOLS: 858 case CCISS_REVALIDVOLS:
853 if (bdev != bdev->bd_contains || drv != host->drv) 859 return rebuild_lun_table(host, NULL);
854 return -ENXIO;
855 return revalidate_allvol(host);
856 860
857 case CCISS_GETLUNINFO:{ 861 case CCISS_GETLUNINFO:{
858 LogvolInfo_struct luninfo; 862 LogvolInfo_struct luninfo;
@@ -1152,75 +1156,6 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
1152 } 1156 }
1153} 1157}
1154 1158
1155/*
1156 * revalidate_allvol is for online array config utilities. After a
1157 * utility reconfigures the drives in the array, it can use this function
1158 * (through an ioctl) to make the driver zap any previous disk structs for
1159 * that controller and get new ones.
1160 *
1161 * Right now I'm using the getgeometry() function to do this, but this
1162 * function should probably be finer grained and allow you to revalidate one
1163 * particular logical volume (instead of all of them on a particular
1164 * controller).
1165 */
1166static int revalidate_allvol(ctlr_info_t *host)
1167{
1168 int ctlr = host->ctlr, i;
1169 unsigned long flags;
1170
1171 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1172 if (host->usage_count > 1) {
1173 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1174 printk(KERN_WARNING "cciss: Device busy for volume"
1175 " revalidation (usage=%d)\n", host->usage_count);
1176 return -EBUSY;
1177 }
1178 host->usage_count++;
1179 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1180
1181 for (i = 0; i < NWD; i++) {
1182 struct gendisk *disk = host->gendisk[i];
1183 if (disk) {
1184 request_queue_t *q = disk->queue;
1185
1186 if (disk->flags & GENHD_FL_UP)
1187 del_gendisk(disk);
1188 if (q)
1189 blk_cleanup_queue(q);
1190 }
1191 }
1192
1193 /*
1194 * Set the partition and block size structures for all volumes
1195 * on this controller to zero. We will reread all of this data
1196 */
1197 memset(host->drv, 0, sizeof(drive_info_struct)
1198 * CISS_MAX_LUN);
1199 /*
1200 * Tell the array controller not to give us any interrupts while
1201 * we check the new geometry. Then turn interrupts back on when
1202 * we're done.
1203 */
1204 host->access.set_intr_mask(host, CCISS_INTR_OFF);
1205 cciss_getgeometry(ctlr);
1206 host->access.set_intr_mask(host, CCISS_INTR_ON);
1207
1208 /* Loop through each real device */
1209 for (i = 0; i < NWD; i++) {
1210 struct gendisk *disk = host->gendisk[i];
1211 drive_info_struct *drv = &(host->drv[i]);
1212 /* we must register the controller even if no disks exist */
1213 /* this is for the online array utilities */
1214 if (!drv->heads && i)
1215 continue;
1216 blk_queue_hardsect_size(drv->queue, drv->block_size);
1217 set_capacity(disk, drv->nr_blocks);
1218 add_disk(disk);
1219 }
1220 host->usage_count--;
1221 return 0;
1222}
1223
1224static inline void complete_buffers(struct bio *bio, int status) 1159static inline void complete_buffers(struct bio *bio, int status)
1225{ 1160{
1226 while (bio) { 1161 while (bio) {
@@ -1243,7 +1178,7 @@ static void cciss_check_queues(ctlr_info_t *h)
1243 * in case the interrupt we serviced was from an ioctl and did not 1178 * in case the interrupt we serviced was from an ioctl and did not
1244 * free any new commands. 1179 * free any new commands.
1245 */ 1180 */
1246 if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) 1181 if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds)
1247 return; 1182 return;
1248 1183
1249 /* We have room on the queue for more commands. Now we need to queue 1184 /* We have room on the queue for more commands. Now we need to queue
@@ -1262,7 +1197,7 @@ static void cciss_check_queues(ctlr_info_t *h)
1262 /* check to see if we have maxed out the number of commands 1197 /* check to see if we have maxed out the number of commands
1263 * that can be placed on the queue. 1198 * that can be placed on the queue.
1264 */ 1199 */
1265 if ((find_first_zero_bit(h->cmd_pool_bits, NR_CMDS)) == NR_CMDS) { 1200 if ((find_first_zero_bit(h->cmd_pool_bits, h->nr_cmds)) == h->nr_cmds) {
1266 if (curr_queue == start_queue) { 1201 if (curr_queue == start_queue) {
1267 h->next_to_run = 1202 h->next_to_run =
1268 (start_queue + 1) % (h->highest_lun + 1); 1203 (start_queue + 1) % (h->highest_lun + 1);
@@ -1380,6 +1315,11 @@ static void cciss_update_drive_info(int ctlr, int drv_index)
1380 /* if it's the controller it's already added */ 1315 /* if it's the controller it's already added */
1381 if (drv_index) { 1316 if (drv_index) {
1382 disk->queue = blk_init_queue(do_cciss_request, &h->lock); 1317 disk->queue = blk_init_queue(do_cciss_request, &h->lock);
1318 sprintf(disk->disk_name, "cciss/c%dd%d", ctlr, drv_index);
1319 disk->major = h->major;
1320 disk->first_minor = drv_index << NWD_SHIFT;
1321 disk->fops = &cciss_fops;
1322 disk->private_data = &h->drv[drv_index];
1383 1323
1384 /* Set up queue information */ 1324 /* Set up queue information */
1385 disk->queue->backing_dev_info.ra_pages = READ_AHEAD; 1325 disk->queue->backing_dev_info.ra_pages = READ_AHEAD;
@@ -1391,7 +1331,7 @@ static void cciss_update_drive_info(int ctlr, int drv_index)
1391 /* This is a limit in the driver and could be eliminated. */ 1331 /* This is a limit in the driver and could be eliminated. */
1392 blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES); 1332 blk_queue_max_phys_segments(disk->queue, MAXSGENTRIES);
1393 1333
1394 blk_queue_max_sectors(disk->queue, 512); 1334 blk_queue_max_sectors(disk->queue, h->cciss_max_sectors);
1395 1335
1396 blk_queue_softirq_done(disk->queue, cciss_softirq_done); 1336 blk_queue_softirq_done(disk->queue, cciss_softirq_done);
1397 1337
@@ -1458,11 +1398,6 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1458 1398
1459 /* Set busy_configuring flag for this operation */ 1399 /* Set busy_configuring flag for this operation */
1460 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); 1400 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
1461 if (h->num_luns >= CISS_MAX_LUN) {
1462 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1463 return -EINVAL;
1464 }
1465
1466 if (h->busy_configuring) { 1401 if (h->busy_configuring) {
1467 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); 1402 spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
1468 return -EBUSY; 1403 return -EBUSY;
@@ -1495,17 +1430,8 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1495 0, 0, TYPE_CMD); 1430 0, 0, TYPE_CMD);
1496 1431
1497 if (return_code == IO_OK) { 1432 if (return_code == IO_OK) {
1498 listlength |= 1433 listlength =
1499 (0xff & (unsigned int)(ld_buff->LUNListLength[0])) 1434 be32_to_cpu(*(__u32 *) ld_buff->LUNListLength);
1500 << 24;
1501 listlength |=
1502 (0xff & (unsigned int)(ld_buff->LUNListLength[1]))
1503 << 16;
1504 listlength |=
1505 (0xff & (unsigned int)(ld_buff->LUNListLength[2]))
1506 << 8;
1507 listlength |=
1508 0xff & (unsigned int)(ld_buff->LUNListLength[3]);
1509 } else { /* reading number of logical volumes failed */ 1435 } else { /* reading number of logical volumes failed */
1510 printk(KERN_WARNING "cciss: report logical volume" 1436 printk(KERN_WARNING "cciss: report logical volume"
1511 " command failed\n"); 1437 " command failed\n");
@@ -1556,6 +1482,14 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1556 if (drv_index == -1) 1482 if (drv_index == -1)
1557 goto freeret; 1483 goto freeret;
1558 1484
1485 /*Check if the gendisk needs to be allocated */
1486 if (!h->gendisk[drv_index]){
1487 h->gendisk[drv_index] = alloc_disk(1 << NWD_SHIFT);
1488 if (!h->gendisk[drv_index]){
1489 printk(KERN_ERR "cciss: could not allocate new disk %d\n", drv_index);
1490 goto mem_msg;
1491 }
1492 }
1559 } 1493 }
1560 h->drv[drv_index].LunID = lunid; 1494 h->drv[drv_index].LunID = lunid;
1561 cciss_update_drive_info(ctlr, drv_index); 1495 cciss_update_drive_info(ctlr, drv_index);
@@ -1593,6 +1527,7 @@ static int rebuild_lun_table(ctlr_info_t *h, struct gendisk *del_disk)
1593static int deregister_disk(struct gendisk *disk, drive_info_struct *drv, 1527static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1594 int clear_all) 1528 int clear_all)
1595{ 1529{
1530 int i;
1596 ctlr_info_t *h = get_host(disk); 1531 ctlr_info_t *h = get_host(disk);
1597 1532
1598 if (!capable(CAP_SYS_RAWIO)) 1533 if (!capable(CAP_SYS_RAWIO))
@@ -1616,9 +1551,35 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1616 del_gendisk(disk); 1551 del_gendisk(disk);
1617 if (q) { 1552 if (q) {
1618 blk_cleanup_queue(q); 1553 blk_cleanup_queue(q);
1554 /* Set drv->queue to NULL so that we do not try
1555 * to call blk_start_queue on this queue in the
1556 * interrupt handler
1557 */
1619 drv->queue = NULL; 1558 drv->queue = NULL;
1620 } 1559 }
1560 /* If clear_all is set then we are deleting the logical
1561 * drive, not just refreshing its info. For drives
1562 * other than disk 0 we will call put_disk. We do not
1563 * do this for disk 0 as we need it to be able to
1564 * configure the controller.
1565 */
1566 if (clear_all){
1567 /* This isn't pretty, but we need to find the
1568 * disk in our array and NULL our the pointer.
1569 * This is so that we will call alloc_disk if
1570 * this index is used again later.
1571 */
1572 for (i=0; i < CISS_MAX_LUN; i++){
1573 if(h->gendisk[i] == disk){
1574 h->gendisk[i] = NULL;
1575 break;
1576 }
1577 }
1578 put_disk(disk);
1579 }
1621 } 1580 }
1581 } else {
1582 set_capacity(disk, 0);
1622 } 1583 }
1623 1584
1624 --h->num_luns; 1585 --h->num_luns;
@@ -2136,7 +2097,7 @@ static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete)
2136 2097
2137 /* We've sent down an abort or reset, but something else 2098 /* We've sent down an abort or reset, but something else
2138 has completed */ 2099 has completed */
2139 if (srl->ncompletions >= (NR_CMDS + 2)) { 2100 if (srl->ncompletions >= (hba[ctlr]->nr_cmds + 2)) {
2140 /* Uh oh. No room to save it for later... */ 2101 /* Uh oh. No room to save it for later... */
2141 printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, " 2102 printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, "
2142 "reject list overflow, command lost!\n", ctlr); 2103 "reject list overflow, command lost!\n", ctlr);
@@ -2673,7 +2634,7 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id)
2673 a1 = a; 2634 a1 = a;
2674 if ((a & 0x04)) { 2635 if ((a & 0x04)) {
2675 a2 = (a >> 3); 2636 a2 = (a >> 3);
2676 if (a2 >= NR_CMDS) { 2637 if (a2 >= h->nr_cmds) {
2677 printk(KERN_WARNING 2638 printk(KERN_WARNING
2678 "cciss: controller cciss%d failed, stopping.\n", 2639 "cciss: controller cciss%d failed, stopping.\n",
2679 h->ctlr); 2640 h->ctlr);
@@ -2827,23 +2788,21 @@ static void __devinit cciss_interrupt_mode(ctlr_info_t *c,
2827 if (err > 0) { 2788 if (err > 0) {
2828 printk(KERN_WARNING "cciss: only %d MSI-X vectors " 2789 printk(KERN_WARNING "cciss: only %d MSI-X vectors "
2829 "available\n", err); 2790 "available\n", err);
2791 goto default_int_mode;
2830 } else { 2792 } else {
2831 printk(KERN_WARNING "cciss: MSI-X init failed %d\n", 2793 printk(KERN_WARNING "cciss: MSI-X init failed %d\n",
2832 err); 2794 err);
2795 goto default_int_mode;
2833 } 2796 }
2834 } 2797 }
2835 if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) { 2798 if (pci_find_capability(pdev, PCI_CAP_ID_MSI)) {
2836 if (!pci_enable_msi(pdev)) { 2799 if (!pci_enable_msi(pdev)) {
2837 c->intr[SIMPLE_MODE_INT] = pdev->irq;
2838 c->msi_vector = 1; 2800 c->msi_vector = 1;
2839 return;
2840 } else { 2801 } else {
2841 printk(KERN_WARNING "cciss: MSI init failed\n"); 2802 printk(KERN_WARNING "cciss: MSI init failed\n");
2842 c->intr[SIMPLE_MODE_INT] = pdev->irq;
2843 return;
2844 } 2803 }
2845 } 2804 }
2846 default_int_mode: 2805default_int_mode:
2847#endif /* CONFIG_PCI_MSI */ 2806#endif /* CONFIG_PCI_MSI */
2848 /* if we get here we're going to use the default interrupt mode */ 2807 /* if we get here we're going to use the default interrupt mode */
2849 c->intr[SIMPLE_MODE_INT] = pdev->irq; 2808 c->intr[SIMPLE_MODE_INT] = pdev->irq;
@@ -2956,16 +2915,10 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2956 if (board_id == products[i].board_id) { 2915 if (board_id == products[i].board_id) {
2957 c->product_name = products[i].product_name; 2916 c->product_name = products[i].product_name;
2958 c->access = *(products[i].access); 2917 c->access = *(products[i].access);
2918 c->nr_cmds = products[i].nr_cmds;
2959 break; 2919 break;
2960 } 2920 }
2961 } 2921 }
2962 if (i == ARRAY_SIZE(products)) {
2963 printk(KERN_WARNING "cciss: Sorry, I don't know how"
2964 " to access the Smart Array controller %08lx\n",
2965 (unsigned long)board_id);
2966 err = -ENODEV;
2967 goto err_out_free_res;
2968 }
2969 if ((readb(&c->cfgtable->Signature[0]) != 'C') || 2922 if ((readb(&c->cfgtable->Signature[0]) != 'C') ||
2970 (readb(&c->cfgtable->Signature[1]) != 'I') || 2923 (readb(&c->cfgtable->Signature[1]) != 'I') ||
2971 (readb(&c->cfgtable->Signature[2]) != 'S') || 2924 (readb(&c->cfgtable->Signature[2]) != 'S') ||
@@ -2974,6 +2927,27 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2974 err = -ENODEV; 2927 err = -ENODEV;
2975 goto err_out_free_res; 2928 goto err_out_free_res;
2976 } 2929 }
2930 /* We didn't find the controller in our list. We know the
2931 * signature is valid. If it's an HP device let's try to
2932 * bind to the device and fire it up. Otherwise we bail.
2933 */
2934 if (i == ARRAY_SIZE(products)) {
2935 if (subsystem_vendor_id == PCI_VENDOR_ID_HP) {
2936 c->product_name = products[i-1].product_name;
2937 c->access = *(products[i-1].access);
2938 c->nr_cmds = products[i-1].nr_cmds;
2939 printk(KERN_WARNING "cciss: This is an unknown "
2940 "Smart Array controller.\n"
2941 "cciss: Please update to the latest driver "
2942 "available from www.hp.com.\n");
2943 } else {
2944 printk(KERN_WARNING "cciss: Sorry, I don't know how"
2945 " to access the Smart Array controller %08lx\n"
2946 , (unsigned long)board_id);
2947 err = -ENODEV;
2948 goto err_out_free_res;
2949 }
2950 }
2977#ifdef CONFIG_X86 2951#ifdef CONFIG_X86
2978 { 2952 {
2979 /* Need to enable prefetch in the SCSI core for 6400 in x86 */ 2953 /* Need to enable prefetch in the SCSI core for 6400 in x86 */
@@ -2984,6 +2958,17 @@ static int cciss_pci_init(ctlr_info_t *c, struct pci_dev *pdev)
2984 } 2958 }
2985#endif 2959#endif
2986 2960
2961 /* Disabling DMA prefetch for the P600
2962 * An ASIC bug may result in a prefetch beyond
2963 * physical memory.
2964 */
2965 if(board_id == 0x3225103C) {
2966 __u32 dma_prefetch;
2967 dma_prefetch = readl(c->vaddr + I2O_DMA1_CFG);
2968 dma_prefetch |= 0x8000;
2969 writel(dma_prefetch, c->vaddr + I2O_DMA1_CFG);
2970 }
2971
2987#ifdef CCISS_DEBUG 2972#ifdef CCISS_DEBUG
2988 printk("Trying to put board into Simple mode\n"); 2973 printk("Trying to put board into Simple mode\n");
2989#endif /* CCISS_DEBUG */ 2974#endif /* CCISS_DEBUG */
@@ -3158,13 +3143,7 @@ geo_inq:
3158/* Returns -1 if no free entries are left. */ 3143/* Returns -1 if no free entries are left. */
3159static int alloc_cciss_hba(void) 3144static int alloc_cciss_hba(void)
3160{ 3145{
3161 struct gendisk *disk[NWD]; 3146 int i;
3162 int i, n;
3163 for (n = 0; n < NWD; n++) {
3164 disk[n] = alloc_disk(1 << NWD_SHIFT);
3165 if (!disk[n])
3166 goto out;
3167 }
3168 3147
3169 for (i = 0; i < MAX_CTLR; i++) { 3148 for (i = 0; i < MAX_CTLR; i++) {
3170 if (!hba[i]) { 3149 if (!hba[i]) {
@@ -3172,20 +3151,18 @@ static int alloc_cciss_hba(void)
3172 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL); 3151 p = kzalloc(sizeof(ctlr_info_t), GFP_KERNEL);
3173 if (!p) 3152 if (!p)
3174 goto Enomem; 3153 goto Enomem;
3175 for (n = 0; n < NWD; n++) 3154 p->gendisk[0] = alloc_disk(1 << NWD_SHIFT);
3176 p->gendisk[n] = disk[n]; 3155 if (!p->gendisk[0])
3156 goto Enomem;
3177 hba[i] = p; 3157 hba[i] = p;
3178 return i; 3158 return i;
3179 } 3159 }
3180 } 3160 }
3181 printk(KERN_WARNING "cciss: This driver supports a maximum" 3161 printk(KERN_WARNING "cciss: This driver supports a maximum"
3182 " of %d controllers.\n", MAX_CTLR); 3162 " of %d controllers.\n", MAX_CTLR);
3183 goto out; 3163 return -1;
3184 Enomem: 3164Enomem:
3185 printk(KERN_ERR "cciss: out of memory.\n"); 3165 printk(KERN_ERR "cciss: out of memory.\n");
3186 out:
3187 while (n--)
3188 put_disk(disk[n]);
3189 return -1; 3166 return -1;
3190} 3167}
3191 3168
@@ -3195,7 +3172,7 @@ static void free_hba(int i)
3195 int n; 3172 int n;
3196 3173
3197 hba[i] = NULL; 3174 hba[i] = NULL;
3198 for (n = 0; n < NWD; n++) 3175 for (n = 0; n < CISS_MAX_LUN; n++)
3199 put_disk(p->gendisk[n]); 3176 put_disk(p->gendisk[n]);
3200 kfree(p); 3177 kfree(p);
3201} 3178}
@@ -3208,9 +3185,8 @@ static void free_hba(int i)
3208static int __devinit cciss_init_one(struct pci_dev *pdev, 3185static int __devinit cciss_init_one(struct pci_dev *pdev,
3209 const struct pci_device_id *ent) 3186 const struct pci_device_id *ent)
3210{ 3187{
3211 request_queue_t *q;
3212 int i; 3188 int i;
3213 int j; 3189 int j = 0;
3214 int rc; 3190 int rc;
3215 int dac; 3191 int dac;
3216 3192
@@ -3269,15 +3245,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3269 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); 3245 hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not");
3270 3246
3271 hba[i]->cmd_pool_bits = 3247 hba[i]->cmd_pool_bits =
3272 kmalloc(((NR_CMDS + BITS_PER_LONG - 3248 kmalloc(((hba[i]->nr_cmds + BITS_PER_LONG -
3273 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL); 3249 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL);
3274 hba[i]->cmd_pool = (CommandList_struct *) 3250 hba[i]->cmd_pool = (CommandList_struct *)
3275 pci_alloc_consistent(hba[i]->pdev, 3251 pci_alloc_consistent(hba[i]->pdev,
3276 NR_CMDS * sizeof(CommandList_struct), 3252 hba[i]->nr_cmds * sizeof(CommandList_struct),
3277 &(hba[i]->cmd_pool_dhandle)); 3253 &(hba[i]->cmd_pool_dhandle));
3278 hba[i]->errinfo_pool = (ErrorInfo_struct *) 3254 hba[i]->errinfo_pool = (ErrorInfo_struct *)
3279 pci_alloc_consistent(hba[i]->pdev, 3255 pci_alloc_consistent(hba[i]->pdev,
3280 NR_CMDS * sizeof(ErrorInfo_struct), 3256 hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
3281 &(hba[i]->errinfo_pool_dhandle)); 3257 &(hba[i]->errinfo_pool_dhandle));
3282 if ((hba[i]->cmd_pool_bits == NULL) 3258 if ((hba[i]->cmd_pool_bits == NULL)
3283 || (hba[i]->cmd_pool == NULL) 3259 || (hba[i]->cmd_pool == NULL)
@@ -3288,7 +3264,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3288#ifdef CONFIG_CISS_SCSI_TAPE 3264#ifdef CONFIG_CISS_SCSI_TAPE
3289 hba[i]->scsi_rejects.complete = 3265 hba[i]->scsi_rejects.complete =
3290 kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) * 3266 kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) *
3291 (NR_CMDS + 5), GFP_KERNEL); 3267 (hba[i]->nr_cmds + 5), GFP_KERNEL);
3292 if (hba[i]->scsi_rejects.complete == NULL) { 3268 if (hba[i]->scsi_rejects.complete == NULL) {
3293 printk(KERN_ERR "cciss: out of memory"); 3269 printk(KERN_ERR "cciss: out of memory");
3294 goto clean4; 3270 goto clean4;
@@ -3302,7 +3278,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3302 /* command and error info recs zeroed out before 3278 /* command and error info recs zeroed out before
3303 they are used */ 3279 they are used */
3304 memset(hba[i]->cmd_pool_bits, 0, 3280 memset(hba[i]->cmd_pool_bits, 0,
3305 ((NR_CMDS + BITS_PER_LONG - 3281 ((hba[i]->nr_cmds + BITS_PER_LONG -
3306 1) / BITS_PER_LONG) * sizeof(unsigned long)); 3282 1) / BITS_PER_LONG) * sizeof(unsigned long));
3307 3283
3308#ifdef CCISS_DEBUG 3284#ifdef CCISS_DEBUG
@@ -3317,18 +3293,34 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3317 hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON); 3293 hba[i]->access.set_intr_mask(hba[i], CCISS_INTR_ON);
3318 3294
3319 cciss_procinit(i); 3295 cciss_procinit(i);
3296
3297 hba[i]->cciss_max_sectors = 2048;
3298
3320 hba[i]->busy_initializing = 0; 3299 hba[i]->busy_initializing = 0;
3321 3300
3322 for (j = 0; j < NWD; j++) { /* mfm */ 3301 do {
3323 drive_info_struct *drv = &(hba[i]->drv[j]); 3302 drive_info_struct *drv = &(hba[i]->drv[j]);
3324 struct gendisk *disk = hba[i]->gendisk[j]; 3303 struct gendisk *disk = hba[i]->gendisk[j];
3304 request_queue_t *q;
3305
3306 /* Check if the disk was allocated already */
3307 if (!disk){
3308 hba[i]->gendisk[j] = alloc_disk(1 << NWD_SHIFT);
3309 disk = hba[i]->gendisk[j];
3310 }
3311
3312 /* Check that the disk was able to be allocated */
3313 if (!disk) {
3314 printk(KERN_ERR "cciss: unable to allocate memory for disk %d\n", j);
3315 goto clean4;
3316 }
3325 3317
3326 q = blk_init_queue(do_cciss_request, &hba[i]->lock); 3318 q = blk_init_queue(do_cciss_request, &hba[i]->lock);
3327 if (!q) { 3319 if (!q) {
3328 printk(KERN_ERR 3320 printk(KERN_ERR
3329 "cciss: unable to allocate queue for disk %d\n", 3321 "cciss: unable to allocate queue for disk %d\n",
3330 j); 3322 j);
3331 break; 3323 goto clean4;
3332 } 3324 }
3333 drv->queue = q; 3325 drv->queue = q;
3334 3326
@@ -3341,7 +3333,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3341 /* This is a limit in the driver and could be eliminated. */ 3333 /* This is a limit in the driver and could be eliminated. */
3342 blk_queue_max_phys_segments(q, MAXSGENTRIES); 3334 blk_queue_max_phys_segments(q, MAXSGENTRIES);
3343 3335
3344 blk_queue_max_sectors(q, 512); 3336 blk_queue_max_sectors(q, hba[i]->cciss_max_sectors);
3345 3337
3346 blk_queue_softirq_done(q, cciss_softirq_done); 3338 blk_queue_softirq_done(q, cciss_softirq_done);
3347 3339
@@ -3360,7 +3352,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3360 blk_queue_hardsect_size(q, drv->block_size); 3352 blk_queue_hardsect_size(q, drv->block_size);
3361 set_capacity(disk, drv->nr_blocks); 3353 set_capacity(disk, drv->nr_blocks);
3362 add_disk(disk); 3354 add_disk(disk);
3363 } 3355 j++;
3356 } while (j <= hba[i]->highest_lun);
3364 3357
3365 return 1; 3358 return 1;
3366 3359
@@ -3371,11 +3364,11 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3371 kfree(hba[i]->cmd_pool_bits); 3364 kfree(hba[i]->cmd_pool_bits);
3372 if (hba[i]->cmd_pool) 3365 if (hba[i]->cmd_pool)
3373 pci_free_consistent(hba[i]->pdev, 3366 pci_free_consistent(hba[i]->pdev,
3374 NR_CMDS * sizeof(CommandList_struct), 3367 hba[i]->nr_cmds * sizeof(CommandList_struct),
3375 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); 3368 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
3376 if (hba[i]->errinfo_pool) 3369 if (hba[i]->errinfo_pool)
3377 pci_free_consistent(hba[i]->pdev, 3370 pci_free_consistent(hba[i]->pdev,
3378 NR_CMDS * sizeof(ErrorInfo_struct), 3371 hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
3379 hba[i]->errinfo_pool, 3372 hba[i]->errinfo_pool,
3380 hba[i]->errinfo_pool_dhandle); 3373 hba[i]->errinfo_pool_dhandle);
3381 free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]); 3374 free_irq(hba[i]->intr[SIMPLE_MODE_INT], hba[i]);
@@ -3383,6 +3376,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3383 unregister_blkdev(hba[i]->major, hba[i]->devname); 3376 unregister_blkdev(hba[i]->major, hba[i]->devname);
3384 clean1: 3377 clean1:
3385 hba[i]->busy_initializing = 0; 3378 hba[i]->busy_initializing = 0;
3379 /* cleanup any queues that may have been initialized */
3380 for (j=0; j <= hba[i]->highest_lun; j++){
3381 drive_info_struct *drv = &(hba[i]->drv[j]);
3382 if (drv->queue)
3383 blk_cleanup_queue(drv->queue);
3384 }
3385 pci_release_regions(pdev);
3386 pci_disable_device(pdev);
3387 pci_set_drvdata(pdev, NULL);
3386 free_hba(i); 3388 free_hba(i);
3387 return -1; 3389 return -1;
3388} 3390}
@@ -3430,7 +3432,7 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
3430 remove_proc_entry(hba[i]->devname, proc_cciss); 3432 remove_proc_entry(hba[i]->devname, proc_cciss);
3431 3433
3432 /* remove it from the disk list */ 3434 /* remove it from the disk list */
3433 for (j = 0; j < NWD; j++) { 3435 for (j = 0; j < CISS_MAX_LUN; j++) {
3434 struct gendisk *disk = hba[i]->gendisk[j]; 3436 struct gendisk *disk = hba[i]->gendisk[j];
3435 if (disk) { 3437 if (disk) {
3436 request_queue_t *q = disk->queue; 3438 request_queue_t *q = disk->queue;
@@ -3442,9 +3444,9 @@ static void __devexit cciss_remove_one(struct pci_dev *pdev)
3442 } 3444 }
3443 } 3445 }
3444 3446
3445 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(CommandList_struct), 3447 pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(CommandList_struct),
3446 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle); 3448 hba[i]->cmd_pool, hba[i]->cmd_pool_dhandle);
3447 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof(ErrorInfo_struct), 3449 pci_free_consistent(hba[i]->pdev, hba[i]->nr_cmds * sizeof(ErrorInfo_struct),
3448 hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); 3450 hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle);
3449 kfree(hba[i]->cmd_pool_bits); 3451 kfree(hba[i]->cmd_pool_bits);
3450#ifdef CONFIG_CISS_SCSI_TAPE 3452#ifdef CONFIG_CISS_SCSI_TAPE
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index 562235c1445a..b70988dd33ec 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -6,7 +6,6 @@
6#include "cciss_cmd.h" 6#include "cciss_cmd.h"
7 7
8 8
9#define NWD 16
10#define NWD_SHIFT 4 9#define NWD_SHIFT 4
11#define MAX_PART (1 << NWD_SHIFT) 10#define MAX_PART (1 << NWD_SHIFT)
12 11
@@ -60,6 +59,7 @@ struct ctlr_info
60 __u32 board_id; 59 __u32 board_id;
61 void __iomem *vaddr; 60 void __iomem *vaddr;
62 unsigned long paddr; 61 unsigned long paddr;
62 int nr_cmds; /* Number of commands allowed on this controller */
63 CfgTable_struct __iomem *cfgtable; 63 CfgTable_struct __iomem *cfgtable;
64 int interrupts_enabled; 64 int interrupts_enabled;
65 int major; 65 int major;
@@ -76,6 +76,7 @@ struct ctlr_info
76 unsigned int intr[4]; 76 unsigned int intr[4];
77 unsigned int msix_vector; 77 unsigned int msix_vector;
78 unsigned int msi_vector; 78 unsigned int msi_vector;
79 int cciss_max_sectors;
79 BYTE cciss_read; 80 BYTE cciss_read;
80 BYTE cciss_write; 81 BYTE cciss_write;
81 BYTE cciss_read_capacity; 82 BYTE cciss_read_capacity;
@@ -110,7 +111,7 @@ struct ctlr_info
110 int next_to_run; 111 int next_to_run;
111 112
112 // Disk structures we need to pass back 113 // Disk structures we need to pass back
113 struct gendisk *gendisk[NWD]; 114 struct gendisk *gendisk[CISS_MAX_LUN];
114#ifdef CONFIG_CISS_SCSI_TAPE 115#ifdef CONFIG_CISS_SCSI_TAPE
115 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ 116 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
116 /* list of block side commands the scsi error handling sucked up */ 117 /* list of block side commands the scsi error handling sucked up */
@@ -282,6 +283,7 @@ struct board_type {
282 __u32 board_id; 283 __u32 board_id;
283 char *product_name; 284 char *product_name;
284 struct access_method *access; 285 struct access_method *access;
286 int nr_cmds; /* Max cmds this kind of ctlr can handle. */
285}; 287};
286 288
287#define CCISS_LOCK(i) (&hba[i]->lock) 289#define CCISS_LOCK(i) (&hba[i]->lock)
diff --git a/drivers/block/cciss_cmd.h b/drivers/block/cciss_cmd.h
index 4af7c4c0c7af..43bf5593b59b 100644
--- a/drivers/block/cciss_cmd.h
+++ b/drivers/block/cciss_cmd.h
@@ -55,6 +55,7 @@
55#define I2O_INT_MASK 0x34 55#define I2O_INT_MASK 0x34
56#define I2O_IBPOST_Q 0x40 56#define I2O_IBPOST_Q 0x40
57#define I2O_OBPOST_Q 0x44 57#define I2O_OBPOST_Q 0x44
58#define I2O_DMA1_CFG 0x214
58 59
59//Configuration Table 60//Configuration Table
60#define CFGTBL_ChangeReq 0x00000001l 61#define CFGTBL_ChangeReq 0x00000001l
@@ -88,7 +89,7 @@ typedef union _u64bit
88//########################################################################### 89//###########################################################################
89//STRUCTURES 90//STRUCTURES
90//########################################################################### 91//###########################################################################
91#define CISS_MAX_LUN 16 92#define CISS_MAX_LUN 1024
92#define CISS_MAX_PHYS_LUN 1024 93#define CISS_MAX_PHYS_LUN 1024
93// SCSI-3 Cmmands 94// SCSI-3 Cmmands
94 95
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9d1035e8d9d8..7bf2cfbd6285 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -355,14 +355,30 @@ harderror:
355 return NULL; 355 return NULL;
356} 356}
357 357
358static ssize_t pid_show(struct gendisk *disk, char *page)
359{
360 return sprintf(page, "%ld\n",
361 (long) ((struct nbd_device *)disk->private_data)->pid);
362}
363
364static struct disk_attribute pid_attr = {
365 .attr = { .name = "pid", .mode = S_IRUGO },
366 .show = pid_show,
367};
368
358static void nbd_do_it(struct nbd_device *lo) 369static void nbd_do_it(struct nbd_device *lo)
359{ 370{
360 struct request *req; 371 struct request *req;
361 372
362 BUG_ON(lo->magic != LO_MAGIC); 373 BUG_ON(lo->magic != LO_MAGIC);
363 374
375 lo->pid = current->pid;
376 sysfs_create_file(&lo->disk->kobj, &pid_attr.attr);
377
364 while ((req = nbd_read_stat(lo)) != NULL) 378 while ((req = nbd_read_stat(lo)) != NULL)
365 nbd_end_request(req); 379 nbd_end_request(req);
380
381 sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr);
366 return; 382 return;
367} 383}
368 384
diff --git a/drivers/block/paride/aten.c b/drivers/block/paride/aten.c
index c4d696d43dc1..2695465568ad 100644
--- a/drivers/block/paride/aten.c
+++ b/drivers/block/paride/aten.c
@@ -149,12 +149,12 @@ static struct pi_protocol aten = {
149 149
150static int __init aten_init(void) 150static int __init aten_init(void)
151{ 151{
152 return pi_register(&aten)-1; 152 return paride_register(&aten);
153} 153}
154 154
155static void __exit aten_exit(void) 155static void __exit aten_exit(void)
156{ 156{
157 pi_unregister( &aten ); 157 paride_unregister( &aten );
158} 158}
159 159
160MODULE_LICENSE("GPL"); 160MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/bpck.c b/drivers/block/paride/bpck.c
index d462ff6b139d..4f27e7392e38 100644
--- a/drivers/block/paride/bpck.c
+++ b/drivers/block/paride/bpck.c
@@ -464,12 +464,12 @@ static struct pi_protocol bpck = {
464 464
465static int __init bpck_init(void) 465static int __init bpck_init(void)
466{ 466{
467 return pi_register(&bpck)-1; 467 return paride_register(&bpck);
468} 468}
469 469
470static void __exit bpck_exit(void) 470static void __exit bpck_exit(void)
471{ 471{
472 pi_unregister(&bpck); 472 paride_unregister(&bpck);
473} 473}
474 474
475MODULE_LICENSE("GPL"); 475MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/bpck6.c b/drivers/block/paride/bpck6.c
index 41a237c5957d..ad124525ac23 100644
--- a/drivers/block/paride/bpck6.c
+++ b/drivers/block/paride/bpck6.c
@@ -31,10 +31,7 @@ static int verbose; /* set this to 1 to see debugging messages and whatnot */
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <asm/io.h> 33#include <asm/io.h>
34
35#if defined(CONFIG_PARPORT_MODULE)||defined(CONFIG_PARPORT)
36#include <linux/parport.h> 34#include <linux/parport.h>
37#endif
38 35
39#include "ppc6lnx.c" 36#include "ppc6lnx.c"
40#include "paride.h" 37#include "paride.h"
@@ -139,11 +136,6 @@ static int bpck6_test_port ( PIA *pi ) /* check for 8-bit port */
139 PPCSTRUCT(pi)->ppc_id=pi->unit; 136 PPCSTRUCT(pi)->ppc_id=pi->unit;
140 PPCSTRUCT(pi)->lpt_addr=pi->port; 137 PPCSTRUCT(pi)->lpt_addr=pi->port;
141 138
142#ifdef CONFIG_PARPORT_PC_MODULE
143#define CONFIG_PARPORT_PC
144#endif
145
146#ifdef CONFIG_PARPORT_PC
147 /* look at the parport device to see if what modes we can use */ 139 /* look at the parport device to see if what modes we can use */
148 if(((struct pardevice *)(pi->pardev))->port->modes & 140 if(((struct pardevice *)(pi->pardev))->port->modes &
149 (PARPORT_MODE_EPP) 141 (PARPORT_MODE_EPP)
@@ -161,11 +153,6 @@ static int bpck6_test_port ( PIA *pi ) /* check for 8-bit port */
161 { 153 {
162 return 1; 154 return 1;
163 } 155 }
164#else
165 /* there is no way of knowing what kind of port we have
166 default to the highest mode possible */
167 return 5;
168#endif
169} 156}
170 157
171static int bpck6_probe_unit ( PIA *pi ) 158static int bpck6_probe_unit ( PIA *pi )
@@ -265,12 +252,12 @@ static int __init bpck6_init(void)
265 printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n"); 252 printk(KERN_INFO "bpck6: Copyright 2001 by Micro Solutions, Inc., DeKalb IL. USA\n");
266 if(verbose) 253 if(verbose)
267 printk(KERN_DEBUG "bpck6: verbose debug enabled.\n"); 254 printk(KERN_DEBUG "bpck6: verbose debug enabled.\n");
268 return pi_register(&bpck6) - 1; 255 return paride_register(&bpck6);
269} 256}
270 257
271static void __exit bpck6_exit(void) 258static void __exit bpck6_exit(void)
272{ 259{
273 pi_unregister(&bpck6); 260 paride_unregister(&bpck6);
274} 261}
275 262
276MODULE_LICENSE("GPL"); 263MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/comm.c b/drivers/block/paride/comm.c
index 43d61359d8ec..9bcd35495323 100644
--- a/drivers/block/paride/comm.c
+++ b/drivers/block/paride/comm.c
@@ -205,12 +205,12 @@ static struct pi_protocol comm = {
205 205
206static int __init comm_init(void) 206static int __init comm_init(void)
207{ 207{
208 return pi_register(&comm)-1; 208 return paride_register(&comm);
209} 209}
210 210
211static void __exit comm_exit(void) 211static void __exit comm_exit(void)
212{ 212{
213 pi_unregister(&comm); 213 paride_unregister(&comm);
214} 214}
215 215
216MODULE_LICENSE("GPL"); 216MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/dstr.c b/drivers/block/paride/dstr.c
index 04d53bf58e8c..accc5c777cbb 100644
--- a/drivers/block/paride/dstr.c
+++ b/drivers/block/paride/dstr.c
@@ -220,12 +220,12 @@ static struct pi_protocol dstr = {
220 220
221static int __init dstr_init(void) 221static int __init dstr_init(void)
222{ 222{
223 return pi_register(&dstr)-1; 223 return paride_register(&dstr);
224} 224}
225 225
226static void __exit dstr_exit(void) 226static void __exit dstr_exit(void)
227{ 227{
228 pi_unregister(&dstr); 228 paride_unregister(&dstr);
229} 229}
230 230
231MODULE_LICENSE("GPL"); 231MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/epat.c b/drivers/block/paride/epat.c
index 55d1c0a1fb90..1bcdff77322e 100644
--- a/drivers/block/paride/epat.c
+++ b/drivers/block/paride/epat.c
@@ -327,12 +327,12 @@ static int __init epat_init(void)
327#ifdef CONFIG_PARIDE_EPATC8 327#ifdef CONFIG_PARIDE_EPATC8
328 epatc8 = 1; 328 epatc8 = 1;
329#endif 329#endif
330 return pi_register(&epat)-1; 330 return paride_register(&epat);
331} 331}
332 332
333static void __exit epat_exit(void) 333static void __exit epat_exit(void)
334{ 334{
335 pi_unregister(&epat); 335 paride_unregister(&epat);
336} 336}
337 337
338MODULE_LICENSE("GPL"); 338MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/epia.c b/drivers/block/paride/epia.c
index 0f2e0c292d82..fb0e782d055e 100644
--- a/drivers/block/paride/epia.c
+++ b/drivers/block/paride/epia.c
@@ -303,12 +303,12 @@ static struct pi_protocol epia = {
303 303
304static int __init epia_init(void) 304static int __init epia_init(void)
305{ 305{
306 return pi_register(&epia)-1; 306 return paride_register(&epia);
307} 307}
308 308
309static void __exit epia_exit(void) 309static void __exit epia_exit(void)
310{ 310{
311 pi_unregister(&epia); 311 paride_unregister(&epia);
312} 312}
313 313
314MODULE_LICENSE("GPL"); 314MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/fit2.c b/drivers/block/paride/fit2.c
index e0f0691d8bc2..381283753ae4 100644
--- a/drivers/block/paride/fit2.c
+++ b/drivers/block/paride/fit2.c
@@ -138,12 +138,12 @@ static struct pi_protocol fit2 = {
138 138
139static int __init fit2_init(void) 139static int __init fit2_init(void)
140{ 140{
141 return pi_register(&fit2)-1; 141 return paride_register(&fit2);
142} 142}
143 143
144static void __exit fit2_exit(void) 144static void __exit fit2_exit(void)
145{ 145{
146 pi_unregister(&fit2); 146 paride_unregister(&fit2);
147} 147}
148 148
149MODULE_LICENSE("GPL"); 149MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/fit3.c b/drivers/block/paride/fit3.c
index 15400e7bc666..275d269458eb 100644
--- a/drivers/block/paride/fit3.c
+++ b/drivers/block/paride/fit3.c
@@ -198,12 +198,12 @@ static struct pi_protocol fit3 = {
198 198
199static int __init fit3_init(void) 199static int __init fit3_init(void)
200{ 200{
201 return pi_register(&fit3)-1; 201 return paride_register(&fit3);
202} 202}
203 203
204static void __exit fit3_exit(void) 204static void __exit fit3_exit(void)
205{ 205{
206 pi_unregister(&fit3); 206 paride_unregister(&fit3);
207} 207}
208 208
209MODULE_LICENSE("GPL"); 209MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/friq.c b/drivers/block/paride/friq.c
index 5ea2904d2815..4f2ba244689b 100644
--- a/drivers/block/paride/friq.c
+++ b/drivers/block/paride/friq.c
@@ -263,12 +263,12 @@ static struct pi_protocol friq = {
263 263
264static int __init friq_init(void) 264static int __init friq_init(void)
265{ 265{
266 return pi_register(&friq)-1; 266 return paride_register(&friq);
267} 267}
268 268
269static void __exit friq_exit(void) 269static void __exit friq_exit(void)
270{ 270{
271 pi_unregister(&friq); 271 paride_unregister(&friq);
272} 272}
273 273
274MODULE_LICENSE("GPL"); 274MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/frpw.c b/drivers/block/paride/frpw.c
index 56b3824b1538..c3cde364603a 100644
--- a/drivers/block/paride/frpw.c
+++ b/drivers/block/paride/frpw.c
@@ -300,12 +300,12 @@ static struct pi_protocol frpw = {
300 300
301static int __init frpw_init(void) 301static int __init frpw_init(void)
302{ 302{
303 return pi_register(&frpw)-1; 303 return paride_register(&frpw);
304} 304}
305 305
306static void __exit frpw_exit(void) 306static void __exit frpw_exit(void)
307{ 307{
308 pi_unregister(&frpw); 308 paride_unregister(&frpw);
309} 309}
310 310
311MODULE_LICENSE("GPL"); 311MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/jumbo b/drivers/block/paride/jumbo
deleted file mode 100644
index e793b9cb7e72..000000000000
--- a/drivers/block/paride/jumbo
+++ /dev/null
@@ -1,70 +0,0 @@
1#!/bin/sh
2#
3# This script can be used to build "jumbo" modules that contain the
4# base PARIDE support, one protocol module and one high-level driver.
5#
6echo -n "High level driver [pcd] : "
7read X
8HLD=${X:-pcd}
9#
10echo -n "Protocol module [bpck] : "
11read X
12PROTO=${X:-bpck}
13#
14echo -n "Use MODVERSIONS [y] ? "
15read X
16UMODV=${X:-y}
17#
18echo -n "For SMP kernel [n] ? "
19read X
20USMP=${X:-n}
21#
22echo -n "Support PARPORT [n] ? "
23read X
24UPARP=${X:-n}
25#
26echo
27#
28case $USMP in
29 y* | Y* ) FSMP="-DCONFIG_SMP"
30 ;;
31 *) FSMP=""
32 ;;
33esac
34#
35MODI="-include ../../../include/linux/modversions.h"
36#
37case $UMODV in
38 y* | Y* ) FMODV="-DMODVERSIONS $MODI"
39 ;;
40 *) FMODV=""
41 ;;
42esac
43#
44case $UPARP in
45 y* | Y* ) FPARP="-DCONFIG_PARPORT"
46 ;;
47 *) FPARP=""
48 ;;
49esac
50#
51TARG=$HLD-$PROTO.o
52FPROTO=-DCONFIG_PARIDE_`echo "$PROTO" | tr [a-z] [A-Z]`
53FK="-D__KERNEL__ -I ../../../include"
54FLCH=-D_LINUX_CONFIG_H
55#
56echo cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c
57cc $FK $FSMP $FLCH $FPARP $FPROTO $FMODV -Wall -O2 -o Jb.o -c paride.c
58#
59echo cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c
60cc $FK $FSMP $FMODV -Wall -O2 -o Jp.o -c $PROTO.c
61#
62echo cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c
63cc $FK $FSMP $FMODV -DMODULE -DPARIDE_JUMBO -Wall -O2 -o Jd.o -c $HLD.c
64#
65echo ld -r -o $TARG Jp.o Jb.o Jd.o
66ld -r -o $TARG Jp.o Jb.o Jd.o
67#
68#
69rm Jp.o Jb.o Jd.o
70#
diff --git a/drivers/block/paride/kbic.c b/drivers/block/paride/kbic.c
index d983bcea76fe..35999c415ee3 100644
--- a/drivers/block/paride/kbic.c
+++ b/drivers/block/paride/kbic.c
@@ -283,13 +283,21 @@ static struct pi_protocol k971 = {
283 283
284static int __init kbic_init(void) 284static int __init kbic_init(void)
285{ 285{
286 return (pi_register(&k951)||pi_register(&k971))-1; 286 int rv;
287
288 rv = paride_register(&k951);
289 if (rv < 0)
290 return rv;
291 rv = paride_register(&k971);
292 if (rv < 0)
293 paride_unregister(&k951);
294 return rv;
287} 295}
288 296
289static void __exit kbic_exit(void) 297static void __exit kbic_exit(void)
290{ 298{
291 pi_unregister(&k951); 299 paride_unregister(&k951);
292 pi_unregister(&k971); 300 paride_unregister(&k971);
293} 301}
294 302
295MODULE_LICENSE("GPL"); 303MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/ktti.c b/drivers/block/paride/ktti.c
index 6c7edbfba9a0..117ab0e8ccf0 100644
--- a/drivers/block/paride/ktti.c
+++ b/drivers/block/paride/ktti.c
@@ -115,12 +115,12 @@ static struct pi_protocol ktti = {
115 115
116static int __init ktti_init(void) 116static int __init ktti_init(void)
117{ 117{
118 return pi_register(&ktti)-1; 118 return paride_register(&ktti);
119} 119}
120 120
121static void __exit ktti_exit(void) 121static void __exit ktti_exit(void)
122{ 122{
123 pi_unregister(&ktti); 123 paride_unregister(&ktti);
124} 124}
125 125
126MODULE_LICENSE("GPL"); 126MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/on20.c b/drivers/block/paride/on20.c
index 9f8e01096809..0173697a1a4d 100644
--- a/drivers/block/paride/on20.c
+++ b/drivers/block/paride/on20.c
@@ -140,12 +140,12 @@ static struct pi_protocol on20 = {
140 140
141static int __init on20_init(void) 141static int __init on20_init(void)
142{ 142{
143 return pi_register(&on20)-1; 143 return paride_register(&on20);
144} 144}
145 145
146static void __exit on20_exit(void) 146static void __exit on20_exit(void)
147{ 147{
148 pi_unregister(&on20); 148 paride_unregister(&on20);
149} 149}
150 150
151MODULE_LICENSE("GPL"); 151MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/on26.c b/drivers/block/paride/on26.c
index 0f833caa2101..95ba256921f2 100644
--- a/drivers/block/paride/on26.c
+++ b/drivers/block/paride/on26.c
@@ -306,12 +306,12 @@ static struct pi_protocol on26 = {
306 306
307static int __init on26_init(void) 307static int __init on26_init(void)
308{ 308{
309 return pi_register(&on26)-1; 309 return paride_register(&on26);
310} 310}
311 311
312static void __exit on26_exit(void) 312static void __exit on26_exit(void)
313{ 313{
314 pi_unregister(&on26); 314 paride_unregister(&on26);
315} 315}
316 316
317MODULE_LICENSE("GPL"); 317MODULE_LICENSE("GPL");
diff --git a/drivers/block/paride/paride.c b/drivers/block/paride/paride.c
index 4b258f7836f3..48c50f11f63b 100644
--- a/drivers/block/paride/paride.c
+++ b/drivers/block/paride/paride.c
@@ -29,14 +29,7 @@
29#include <linux/spinlock.h> 29#include <linux/spinlock.h>
30#include <linux/wait.h> 30#include <linux/wait.h>
31#include <linux/sched.h> /* TASK_* */ 31#include <linux/sched.h> /* TASK_* */
32
33#ifdef CONFIG_PARPORT_MODULE
34#define CONFIG_PARPORT
35#endif
36
37#ifdef CONFIG_PARPORT
38#include <linux/parport.h> 32#include <linux/parport.h>
39#endif
40 33
41#include "paride.h" 34#include "paride.h"
42 35
@@ -76,8 +69,6 @@ void pi_read_block(PIA * pi, char *buf, int count)
76 69
77EXPORT_SYMBOL(pi_read_block); 70EXPORT_SYMBOL(pi_read_block);
78 71
79#ifdef CONFIG_PARPORT
80
81static void pi_wake_up(void *p) 72static void pi_wake_up(void *p)
82{ 73{
83 PIA *pi = (PIA *) p; 74 PIA *pi = (PIA *) p;
@@ -100,11 +91,8 @@ static void pi_wake_up(void *p)
100 cont(); 91 cont();
101} 92}
102 93
103#endif
104
105int pi_schedule_claimed(PIA * pi, void (*cont) (void)) 94int pi_schedule_claimed(PIA * pi, void (*cont) (void))
106{ 95{
107#ifdef CONFIG_PARPORT
108 unsigned long flags; 96 unsigned long flags;
109 97
110 spin_lock_irqsave(&pi_spinlock, flags); 98 spin_lock_irqsave(&pi_spinlock, flags);
@@ -115,7 +103,6 @@ int pi_schedule_claimed(PIA * pi, void (*cont) (void))
115 } 103 }
116 pi->claimed = 1; 104 pi->claimed = 1;
117 spin_unlock_irqrestore(&pi_spinlock, flags); 105 spin_unlock_irqrestore(&pi_spinlock, flags);
118#endif
119 return 1; 106 return 1;
120} 107}
121EXPORT_SYMBOL(pi_schedule_claimed); 108EXPORT_SYMBOL(pi_schedule_claimed);
@@ -133,20 +120,16 @@ static void pi_claim(PIA * pi)
133 if (pi->claimed) 120 if (pi->claimed)
134 return; 121 return;
135 pi->claimed = 1; 122 pi->claimed = 1;
136#ifdef CONFIG_PARPORT
137 if (pi->pardev) 123 if (pi->pardev)
138 wait_event(pi->parq, 124 wait_event(pi->parq,
139 !parport_claim((struct pardevice *) pi->pardev)); 125 !parport_claim((struct pardevice *) pi->pardev));
140#endif
141} 126}
142 127
143static void pi_unclaim(PIA * pi) 128static void pi_unclaim(PIA * pi)
144{ 129{
145 pi->claimed = 0; 130 pi->claimed = 0;
146#ifdef CONFIG_PARPORT
147 if (pi->pardev) 131 if (pi->pardev)
148 parport_release((struct pardevice *) (pi->pardev)); 132 parport_release((struct pardevice *) (pi->pardev));
149#endif
150} 133}
151 134
152void pi_connect(PIA * pi) 135void pi_connect(PIA * pi)
@@ -167,21 +150,15 @@ EXPORT_SYMBOL(pi_disconnect);
167 150
168static void pi_unregister_parport(PIA * pi) 151static void pi_unregister_parport(PIA * pi)
169{ 152{
170#ifdef CONFIG_PARPORT
171 if (pi->pardev) { 153 if (pi->pardev) {
172 parport_unregister_device((struct pardevice *) (pi->pardev)); 154 parport_unregister_device((struct pardevice *) (pi->pardev));
173 pi->pardev = NULL; 155 pi->pardev = NULL;
174 } 156 }
175#endif
176} 157}
177 158
178void pi_release(PIA * pi) 159void pi_release(PIA * pi)
179{ 160{
180 pi_unregister_parport(pi); 161 pi_unregister_parport(pi);
181#ifndef CONFIG_PARPORT
182 if (pi->reserved)
183 release_region(pi->port, pi->reserved);
184#endif /* !CONFIG_PARPORT */
185 if (pi->proto->release_proto) 162 if (pi->proto->release_proto)
186 pi->proto->release_proto(pi); 163 pi->proto->release_proto(pi);
187 module_put(pi->proto->owner); 164 module_put(pi->proto->owner);
@@ -229,7 +206,7 @@ static int pi_test_proto(PIA * pi, char *scratch, int verbose)
229 return res; 206 return res;
230} 207}
231 208
232int pi_register(PIP * pr) 209int paride_register(PIP * pr)
233{ 210{
234 int k; 211 int k;
235 212
@@ -237,24 +214,24 @@ int pi_register(PIP * pr)
237 if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) { 214 if (protocols[k] && !strcmp(pr->name, protocols[k]->name)) {
238 printk("paride: %s protocol already registered\n", 215 printk("paride: %s protocol already registered\n",
239 pr->name); 216 pr->name);
240 return 0; 217 return -1;
241 } 218 }
242 k = 0; 219 k = 0;
243 while ((k < MAX_PROTOS) && (protocols[k])) 220 while ((k < MAX_PROTOS) && (protocols[k]))
244 k++; 221 k++;
245 if (k == MAX_PROTOS) { 222 if (k == MAX_PROTOS) {
246 printk("paride: protocol table full\n"); 223 printk("paride: protocol table full\n");
247 return 0; 224 return -1;
248 } 225 }
249 protocols[k] = pr; 226 protocols[k] = pr;
250 pr->index = k; 227 pr->index = k;
251 printk("paride: %s registered as protocol %d\n", pr->name, k); 228 printk("paride: %s registered as protocol %d\n", pr->name, k);
252 return 1; 229 return 0;
253} 230}
254 231
255EXPORT_SYMBOL(pi_register); 232EXPORT_SYMBOL(paride_register);
256 233
257void pi_unregister(PIP * pr) 234void paride_unregister(PIP * pr)
258{ 235{
259 if (!pr) 236 if (!pr)
260 return; 237 return;
@@ -265,12 +242,10 @@ void pi_unregister(PIP * pr)
265 protocols[pr->index] = NULL; 242 protocols[pr->index] = NULL;
266} 243}
267 244
268EXPORT_SYMBOL(pi_unregister); 245EXPORT_SYMBOL(paride_unregister);
269 246
270static int pi_register_parport(PIA * pi, int verbose) 247static int pi_register_parport(PIA * pi, int verbose)
271{ 248{
272#ifdef CONFIG_PARPORT
273
274 struct parport *port; 249 struct parport *port;
275 250
276 port = parport_find_base(pi->port); 251 port = parport_find_base(pi->port);
@@ -290,7 +265,6 @@ static int pi_register_parport(PIA * pi, int verbose)
290 printk("%s: 0x%x is %s\n", pi->device, pi->port, port->name); 265 printk("%s: 0x%x is %s\n", pi->device, pi->port, port->name);
291 266
292 pi->parname = (char *) port->name; 267 pi->parname = (char *) port->name;
293#endif
294 268
295 return 1; 269 return 1;
296} 270}
@@ -447,13 +421,6 @@ int pi_init(PIA * pi, int autoprobe, int port, int mode,
447 printk("%s: Adapter not found\n", device); 421 printk("%s: Adapter not found\n", device);
448 return 0; 422 return 0;
449 } 423 }
450#ifndef CONFIG_PARPORT
451 if (!request_region(pi->port, pi->reserved, pi->device)) {
452 printk(KERN_WARNING "paride: Unable to request region 0x%x\n",
453 pi->port);
454 return 0;
455 }
456#endif /* !CONFIG_PARPORT */
457 424
458 if (pi->parname) 425 if (pi->parname)
459 printk("%s: Sharing %s at 0x%x\n", pi->device, 426 printk("%s: Sharing %s at 0x%x\n", pi->device,
diff --git a/drivers/block/paride/paride.h b/drivers/block/paride/paride.h
index c6d98ef09e48..2bddbf45518b 100644
--- a/drivers/block/paride/paride.h
+++ b/drivers/block/paride/paride.h
@@ -163,8 +163,8 @@ struct pi_protocol {
163 163
164typedef struct pi_protocol PIP; 164typedef struct pi_protocol PIP;
165 165
166extern int pi_register( PIP * ); 166extern int paride_register( PIP * );
167extern void pi_unregister ( PIP * ); 167extern void paride_unregister ( PIP * );
168 168
169#endif /* __DRIVERS_PARIDE_H__ */ 169#endif /* __DRIVERS_PARIDE_H__ */
170/* end of paride.h */ 170/* end of paride.h */
diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index ac5ba462710b..c852eed91e4b 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -912,12 +912,12 @@ static int __init pcd_init(void)
912 int unit; 912 int unit;
913 913
914 if (disable) 914 if (disable)
915 return -1; 915 return -EINVAL;
916 916
917 pcd_init_units(); 917 pcd_init_units();
918 918
919 if (pcd_detect()) 919 if (pcd_detect())
920 return -1; 920 return -ENODEV;
921 921
922 /* get the atapi capabilities page */ 922 /* get the atapi capabilities page */
923 pcd_probe_capabilities(); 923 pcd_probe_capabilities();
@@ -925,7 +925,7 @@ static int __init pcd_init(void)
925 if (register_blkdev(major, name)) { 925 if (register_blkdev(major, name)) {
926 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) 926 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
927 put_disk(cd->disk); 927 put_disk(cd->disk);
928 return -1; 928 return -EBUSY;
929 } 929 }
930 930
931 pcd_queue = blk_init_queue(do_pcd_request, &pcd_lock); 931 pcd_queue = blk_init_queue(do_pcd_request, &pcd_lock);
@@ -933,7 +933,7 @@ static int __init pcd_init(void)
933 unregister_blkdev(major, name); 933 unregister_blkdev(major, name);
934 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) 934 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++)
935 put_disk(cd->disk); 935 put_disk(cd->disk);
936 return -1; 936 return -ENOMEM;
937 } 937 }
938 938
939 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) { 939 for (unit = 0, cd = pcd; unit < PCD_UNITS; unit++, cd++) {
diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 1a9dee19efcf..7cdaa1951260 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -933,25 +933,25 @@ static int __init pf_init(void)
933 int unit; 933 int unit;
934 934
935 if (disable) 935 if (disable)
936 return -1; 936 return -EINVAL;
937 937
938 pf_init_units(); 938 pf_init_units();
939 939
940 if (pf_detect()) 940 if (pf_detect())
941 return -1; 941 return -ENODEV;
942 pf_busy = 0; 942 pf_busy = 0;
943 943
944 if (register_blkdev(major, name)) { 944 if (register_blkdev(major, name)) {
945 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) 945 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
946 put_disk(pf->disk); 946 put_disk(pf->disk);
947 return -1; 947 return -EBUSY;
948 } 948 }
949 pf_queue = blk_init_queue(do_pf_request, &pf_spin_lock); 949 pf_queue = blk_init_queue(do_pf_request, &pf_spin_lock);
950 if (!pf_queue) { 950 if (!pf_queue) {
951 unregister_blkdev(major, name); 951 unregister_blkdev(major, name);
952 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) 952 for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
953 put_disk(pf->disk); 953 put_disk(pf->disk);
954 return -1; 954 return -ENOMEM;
955 } 955 }
956 956
957 blk_queue_max_phys_segments(pf_queue, cluster); 957 blk_queue_max_phys_segments(pf_queue, cluster);
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index 13f998aa1cd3..9970aedbb5d9 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -646,14 +646,14 @@ static int __init pg_init(void)
646 int err; 646 int err;
647 647
648 if (disable){ 648 if (disable){
649 err = -1; 649 err = -EINVAL;
650 goto out; 650 goto out;
651 } 651 }
652 652
653 pg_init_units(); 653 pg_init_units();
654 654
655 if (pg_detect()) { 655 if (pg_detect()) {
656 err = -1; 656 err = -ENODEV;
657 goto out; 657 goto out;
658 } 658 }
659 659
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 35fb26636721..c902b25e4869 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -946,12 +946,12 @@ static int __init pt_init(void)
946 int err; 946 int err;
947 947
948 if (disable) { 948 if (disable) {
949 err = -1; 949 err = -EINVAL;
950 goto out; 950 goto out;
951 } 951 }
952 952
953 if (pt_detect()) { 953 if (pt_detect()) {
954 err = -1; 954 err = -ENODEV;
955 goto out; 955 goto out;
956 } 956 }
957 957
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index f2904f67af47..e45eaa264119 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -54,7 +54,7 @@
54#include <linux/proc_fs.h> 54#include <linux/proc_fs.h>
55#include <linux/seq_file.h> 55#include <linux/seq_file.h>
56#include <linux/miscdevice.h> 56#include <linux/miscdevice.h>
57#include <linux/suspend.h> 57#include <linux/freezer.h>
58#include <linux/mutex.h> 58#include <linux/mutex.h>
59#include <scsi/scsi_cmnd.h> 59#include <scsi/scsi_cmnd.h>
60#include <scsi/scsi_ioctl.h> 60#include <scsi/scsi_ioctl.h>
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index d0cface535fb..5e2c31882003 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -330,7 +330,7 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
330 reliable packet if the number of packets sent but not yet ack'ed 330 reliable packet if the number of packets sent but not yet ack'ed
331 is < than the winsize */ 331 is < than the winsize */
332 332
333 spin_lock_irqsave(&bcsp->unack.lock, flags); 333 spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
334 334
335 if (bcsp->unack.qlen < BCSP_TXWINSIZE && (skb = skb_dequeue(&bcsp->rel)) != NULL) { 335 if (bcsp->unack.qlen < BCSP_TXWINSIZE && (skb = skb_dequeue(&bcsp->rel)) != NULL) {
336 struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type); 336 struct sk_buff *nskb = bcsp_prepare_pkt(bcsp, skb->data, skb->len, bt_cb(skb)->pkt_type);
@@ -696,7 +696,7 @@ static void bcsp_timed_event(unsigned long arg)
696 696
697 BT_DBG("hu %p retransmitting %u pkts", hu, bcsp->unack.qlen); 697 BT_DBG("hu %p retransmitting %u pkts", hu, bcsp->unack.qlen);
698 698
699 spin_lock_irqsave(&bcsp->unack.lock, flags); 699 spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
700 700
701 while ((skb = __skb_dequeue_tail(&bcsp->unack)) != NULL) { 701 while ((skb = __skb_dequeue_tail(&bcsp->unack)) != NULL) {
702 bcsp->msgq_txseq = (bcsp->msgq_txseq - 1) & 0x07; 702 bcsp->msgq_txseq = (bcsp->msgq_txseq - 1) & 0x07;
diff --git a/drivers/cdrom/optcd.c b/drivers/cdrom/optcd.c
index 25032d7edc55..3541690a77d4 100644
--- a/drivers/cdrom/optcd.c
+++ b/drivers/cdrom/optcd.c
@@ -101,7 +101,7 @@ static void debug(int debug_this, const char* fmt, ...)
101 return; 101 return;
102 102
103 va_start(args, fmt); 103 va_start(args, fmt);
104 vsprintf(s, fmt, args); 104 vsnprintf(s, sizeof(s), fmt, args);
105 printk(KERN_DEBUG "optcd: %s\n", s); 105 printk(KERN_DEBUG "optcd: %s\n", s);
106 va_end(args); 106 va_end(args);
107} 107}
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index ba50e5a712f2..a1283b1ef989 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -770,11 +770,10 @@ static void msg(int level, const char *fmt, ...)
770 770
771 msgnum++; 771 msgnum++;
772 if (msgnum>99) msgnum=0; 772 if (msgnum>99) msgnum=0;
773 sprintf(buf, MSG_LEVEL "%s-%d [%02d]: ", major_name, current_drive - D_S, msgnum);
774 va_start(args, fmt); 773 va_start(args, fmt);
775 vsprintf(&buf[18], fmt, args); 774 vsnprintf(buf, sizeof(buf), fmt, args);
776 va_end(args); 775 va_end(args);
777 printk(buf); 776 printk(MSG_LEVEL "%s-%d [%02d]: %s", major_name, current_drive - D_S, msgnum, buf);
778#if KLOGD_PAUSE 777#if KLOGD_PAUSE
779 sbp_sleep(KLOGD_PAUSE); /* else messages get lost */ 778 sbp_sleep(KLOGD_PAUSE); /* else messages get lost */
780#endif /* KLOGD_PAUSE */ 779#endif /* KLOGD_PAUSE */
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 00b17ae39736..2f2c4efff8a3 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -459,7 +459,7 @@ static const struct aper_size_info_32 nforce3_sizes[5] =
459 459
460/* Handle shadow device of the Nvidia NForce3 */ 460/* Handle shadow device of the Nvidia NForce3 */
461/* CHECK-ME original 2.4 version set up some IORRs. Check if that is needed. */ 461/* CHECK-ME original 2.4 version set up some IORRs. Check if that is needed. */
462static int __devinit nforce3_agp_init(struct pci_dev *pdev) 462static int nforce3_agp_init(struct pci_dev *pdev)
463{ 463{
464 u32 tmp, apbase, apbar, aplimit; 464 u32 tmp, apbase, apbar, aplimit;
465 struct pci_dev *dev1; 465 struct pci_dev *dev1;
diff --git a/drivers/char/decserial.c b/drivers/char/decserial.c
index 85f404e25c73..8ea2bea2b183 100644
--- a/drivers/char/decserial.c
+++ b/drivers/char/decserial.c
@@ -23,20 +23,12 @@
23extern int zs_init(void); 23extern int zs_init(void);
24#endif 24#endif
25 25
26#ifdef CONFIG_DZ
27extern int dz_init(void);
28#endif
29
30#ifdef CONFIG_SERIAL_CONSOLE 26#ifdef CONFIG_SERIAL_CONSOLE
31 27
32#ifdef CONFIG_ZS 28#ifdef CONFIG_ZS
33extern void zs_serial_console_init(void); 29extern void zs_serial_console_init(void);
34#endif 30#endif
35 31
36#ifdef CONFIG_DZ
37extern void dz_serial_console_init(void);
38#endif
39
40#endif 32#endif
41 33
42/* rs_init - starts up the serial interface - 34/* rs_init - starts up the serial interface -
@@ -46,23 +38,11 @@ extern void dz_serial_console_init(void);
46 38
47int __init rs_init(void) 39int __init rs_init(void)
48{ 40{
49 41#ifdef CONFIG_ZS
50#if defined(CONFIG_ZS) && defined(CONFIG_DZ)
51 if (IOASIC) 42 if (IOASIC)
52 return zs_init(); 43 return zs_init();
53 else
54 return dz_init();
55#else
56
57#ifdef CONFIG_ZS
58 return zs_init();
59#endif
60
61#ifdef CONFIG_DZ
62 return dz_init();
63#endif
64
65#endif 44#endif
45 return -ENXIO;
66} 46}
67 47
68__initcall(rs_init); 48__initcall(rs_init);
@@ -76,21 +56,9 @@ __initcall(rs_init);
76 */ 56 */
77static int __init decserial_console_init(void) 57static int __init decserial_console_init(void)
78{ 58{
79#if defined(CONFIG_ZS) && defined(CONFIG_DZ) 59#ifdef CONFIG_ZS
80 if (IOASIC) 60 if (IOASIC)
81 zs_serial_console_init(); 61 zs_serial_console_init();
82 else
83 dz_serial_console_init();
84#else
85
86#ifdef CONFIG_ZS
87 zs_serial_console_init();
88#endif
89
90#ifdef CONFIG_DZ
91 dz_serial_console_init();
92#endif
93
94#endif 62#endif
95 return 0; 63 return 0;
96} 64}
diff --git a/drivers/char/drm/drm_sman.c b/drivers/char/drm/drm_sman.c
index 425c82336ee0..19c81d2e13d0 100644
--- a/drivers/char/drm/drm_sman.c
+++ b/drivers/char/drm/drm_sman.c
@@ -162,6 +162,7 @@ drm_sman_set_manager(drm_sman_t * sman, unsigned int manager,
162 162
163 return 0; 163 return 0;
164} 164}
165EXPORT_SYMBOL(drm_sman_set_manager);
165 166
166static drm_owner_item_t *drm_sman_get_owner_item(drm_sman_t * sman, 167static drm_owner_item_t *drm_sman_get_owner_item(drm_sman_t * sman,
167 unsigned long owner) 168 unsigned long owner)
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index b40ae438f531..ae2691942ddb 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -147,14 +147,14 @@ static __inline__ struct page *drm_do_vm_shm_nopage(struct vm_area_struct *vma,
147 if (address > vma->vm_end) 147 if (address > vma->vm_end)
148 return NOPAGE_SIGBUS; /* Disallow mremap */ 148 return NOPAGE_SIGBUS; /* Disallow mremap */
149 if (!map) 149 if (!map)
150 return NOPAGE_OOM; /* Nothing allocated */ 150 return NOPAGE_SIGBUS; /* Nothing allocated */
151 151
152 offset = address - vma->vm_start; 152 offset = address - vma->vm_start;
153 i = (unsigned long)map->handle + offset; 153 i = (unsigned long)map->handle + offset;
154 page = (map->type == _DRM_CONSISTENT) ? 154 page = (map->type == _DRM_CONSISTENT) ?
155 virt_to_page((void *)i) : vmalloc_to_page((void *)i); 155 virt_to_page((void *)i) : vmalloc_to_page((void *)i);
156 if (!page) 156 if (!page)
157 return NOPAGE_OOM; 157 return NOPAGE_SIGBUS;
158 get_page(page); 158 get_page(page);
159 159
160 DRM_DEBUG("shm_nopage 0x%lx\n", address); 160 DRM_DEBUG("shm_nopage 0x%lx\n", address);
@@ -272,7 +272,7 @@ static __inline__ struct page *drm_do_vm_dma_nopage(struct vm_area_struct *vma,
272 if (address > vma->vm_end) 272 if (address > vma->vm_end)
273 return NOPAGE_SIGBUS; /* Disallow mremap */ 273 return NOPAGE_SIGBUS; /* Disallow mremap */
274 if (!dma->pagelist) 274 if (!dma->pagelist)
275 return NOPAGE_OOM; /* Nothing allocated */ 275 return NOPAGE_SIGBUS; /* Nothing allocated */
276 276
277 offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */ 277 offset = address - vma->vm_start; /* vm_[pg]off[set] should be 0 */
278 page_nr = offset >> PAGE_SHIFT; 278 page_nr = offset >> PAGE_SHIFT;
@@ -310,7 +310,7 @@ static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
310 if (address > vma->vm_end) 310 if (address > vma->vm_end)
311 return NOPAGE_SIGBUS; /* Disallow mremap */ 311 return NOPAGE_SIGBUS; /* Disallow mremap */
312 if (!entry->pagelist) 312 if (!entry->pagelist)
313 return NOPAGE_OOM; /* Nothing allocated */ 313 return NOPAGE_SIGBUS; /* Nothing allocated */
314 314
315 offset = address - vma->vm_start; 315 offset = address - vma->vm_start;
316 map_offset = map->offset - (unsigned long)dev->sg->virtual; 316 map_offset = map->offset - (unsigned long)dev->sg->virtual;
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c
index 9902ffad3b12..cc2cd46bedc6 100644
--- a/drivers/char/hvc_console.c
+++ b/drivers/char/hvc_console.c
@@ -38,6 +38,7 @@
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <linux/spinlock.h> 39#include <linux/spinlock.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/freezer.h>
41 42
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43 44
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 8728255c9463..d090622f1dea 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -337,11 +337,6 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp);
337static void hvcs_close(struct tty_struct *tty, struct file *filp); 337static void hvcs_close(struct tty_struct *tty, struct file *filp);
338static void hvcs_hangup(struct tty_struct * tty); 338static void hvcs_hangup(struct tty_struct * tty);
339 339
340static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd);
341static void hvcs_remove_device_attrs(struct vio_dev *vdev);
342static void hvcs_create_driver_attrs(void);
343static void hvcs_remove_driver_attrs(void);
344
345static int __devinit hvcs_probe(struct vio_dev *dev, 340static int __devinit hvcs_probe(struct vio_dev *dev,
346 const struct vio_device_id *id); 341 const struct vio_device_id *id);
347static int __devexit hvcs_remove(struct vio_dev *dev); 342static int __devexit hvcs_remove(struct vio_dev *dev);
@@ -353,6 +348,172 @@ static void __exit hvcs_module_exit(void);
353#define HVCS_TRY_WRITE 0x00000004 348#define HVCS_TRY_WRITE 0x00000004
354#define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ) 349#define HVCS_READ_MASK (HVCS_SCHED_READ | HVCS_QUICK_READ)
355 350
351static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
352{
353 return viod->dev.driver_data;
354}
355/* The sysfs interface for the driver and devices */
356
357static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
358{
359 struct vio_dev *viod = to_vio_dev(dev);
360 struct hvcs_struct *hvcsd = from_vio_dev(viod);
361 unsigned long flags;
362 int retval;
363
364 spin_lock_irqsave(&hvcsd->lock, flags);
365 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
366 spin_unlock_irqrestore(&hvcsd->lock, flags);
367 return retval;
368}
369static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
370
371static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
372{
373 struct vio_dev *viod = to_vio_dev(dev);
374 struct hvcs_struct *hvcsd = from_vio_dev(viod);
375 unsigned long flags;
376 int retval;
377
378 spin_lock_irqsave(&hvcsd->lock, flags);
379 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
380 spin_unlock_irqrestore(&hvcsd->lock, flags);
381 return retval;
382}
383static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
384
385static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
386 size_t count)
387{
388 /*
389 * Don't need this feature at the present time because firmware doesn't
390 * yet support multiple partners.
391 */
392 printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
393 return -EPERM;
394}
395
396static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
397{
398 struct vio_dev *viod = to_vio_dev(dev);
399 struct hvcs_struct *hvcsd = from_vio_dev(viod);
400 unsigned long flags;
401 int retval;
402
403 spin_lock_irqsave(&hvcsd->lock, flags);
404 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
405 spin_unlock_irqrestore(&hvcsd->lock, flags);
406 return retval;
407}
408
409static DEVICE_ATTR(current_vty,
410 S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
411
412static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
413 size_t count)
414{
415 struct vio_dev *viod = to_vio_dev(dev);
416 struct hvcs_struct *hvcsd = from_vio_dev(viod);
417 unsigned long flags;
418
419 /* writing a '0' to this sysfs entry will result in the disconnect. */
420 if (simple_strtol(buf, NULL, 0) != 0)
421 return -EINVAL;
422
423 spin_lock_irqsave(&hvcsd->lock, flags);
424
425 if (hvcsd->open_count > 0) {
426 spin_unlock_irqrestore(&hvcsd->lock, flags);
427 printk(KERN_INFO "HVCS: vterm state unchanged. "
428 "The hvcs device node is still in use.\n");
429 return -EPERM;
430 }
431
432 if (hvcsd->connected == 0) {
433 spin_unlock_irqrestore(&hvcsd->lock, flags);
434 printk(KERN_INFO "HVCS: vterm state unchanged. The"
435 " vty-server is not connected to a vty.\n");
436 return -EPERM;
437 }
438
439 hvcs_partner_free(hvcsd);
440 printk(KERN_INFO "HVCS: Closed vty-server@%X and"
441 " partner vty@%X:%d connection.\n",
442 hvcsd->vdev->unit_address,
443 hvcsd->p_unit_address,
444 (uint32_t)hvcsd->p_partition_ID);
445
446 spin_unlock_irqrestore(&hvcsd->lock, flags);
447 return count;
448}
449
450static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
451{
452 struct vio_dev *viod = to_vio_dev(dev);
453 struct hvcs_struct *hvcsd = from_vio_dev(viod);
454 unsigned long flags;
455 int retval;
456
457 spin_lock_irqsave(&hvcsd->lock, flags);
458 retval = sprintf(buf, "%d\n", hvcsd->connected);
459 spin_unlock_irqrestore(&hvcsd->lock, flags);
460 return retval;
461}
462static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
463 hvcs_vterm_state_show, hvcs_vterm_state_store);
464
465static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
466{
467 struct vio_dev *viod = to_vio_dev(dev);
468 struct hvcs_struct *hvcsd = from_vio_dev(viod);
469 unsigned long flags;
470 int retval;
471
472 spin_lock_irqsave(&hvcsd->lock, flags);
473 retval = sprintf(buf, "%d\n", hvcsd->index);
474 spin_unlock_irqrestore(&hvcsd->lock, flags);
475 return retval;
476}
477
478static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);
479
480static struct attribute *hvcs_attrs[] = {
481 &dev_attr_partner_vtys.attr,
482 &dev_attr_partner_clcs.attr,
483 &dev_attr_current_vty.attr,
484 &dev_attr_vterm_state.attr,
485 &dev_attr_index.attr,
486 NULL,
487};
488
489static struct attribute_group hvcs_attr_group = {
490 .attrs = hvcs_attrs,
491};
492
493static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
494{
495 /* A 1 means it is updating, a 0 means it is done updating */
496 return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
497}
498
499static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
500 size_t count)
501{
502 if ((simple_strtol(buf, NULL, 0) != 1)
503 && (hvcs_rescan_status != 0))
504 return -EINVAL;
505
506 hvcs_rescan_status = 1;
507 printk(KERN_INFO "HVCS: rescanning partner info for all"
508 " vty-servers.\n");
509 hvcs_rescan_devices_list();
510 hvcs_rescan_status = 0;
511 return count;
512}
513
514static DRIVER_ATTR(rescan,
515 S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
516
356static void hvcs_kick(void) 517static void hvcs_kick(void)
357{ 518{
358 hvcs_kicked = 1; 519 hvcs_kicked = 1;
@@ -575,7 +736,7 @@ static void destroy_hvcs_struct(struct kobject *kobj)
575 spin_unlock_irqrestore(&hvcsd->lock, flags); 736 spin_unlock_irqrestore(&hvcsd->lock, flags);
576 spin_unlock(&hvcs_structs_lock); 737 spin_unlock(&hvcs_structs_lock);
577 738
578 hvcs_remove_device_attrs(vdev); 739 sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
579 740
580 kfree(hvcsd); 741 kfree(hvcsd);
581} 742}
@@ -608,6 +769,7 @@ static int __devinit hvcs_probe(
608{ 769{
609 struct hvcs_struct *hvcsd; 770 struct hvcs_struct *hvcsd;
610 int index; 771 int index;
772 int retval;
611 773
612 if (!dev || !id) { 774 if (!dev || !id) {
613 printk(KERN_ERR "HVCS: probed with invalid parameter.\n"); 775 printk(KERN_ERR "HVCS: probed with invalid parameter.\n");
@@ -658,14 +820,16 @@ static int __devinit hvcs_probe(
658 * the hvcs_struct has been added to the devices list then the user app 820 * the hvcs_struct has been added to the devices list then the user app
659 * will get -ENODEV. 821 * will get -ENODEV.
660 */ 822 */
661
662 spin_lock(&hvcs_structs_lock); 823 spin_lock(&hvcs_structs_lock);
663
664 list_add_tail(&(hvcsd->next), &hvcs_structs); 824 list_add_tail(&(hvcsd->next), &hvcs_structs);
665
666 spin_unlock(&hvcs_structs_lock); 825 spin_unlock(&hvcs_structs_lock);
667 826
668 hvcs_create_device_attrs(hvcsd); 827 retval = sysfs_create_group(&dev->dev.kobj, &hvcs_attr_group);
828 if (retval) {
829 printk(KERN_ERR "HVCS: Can't create sysfs attrs for vty-server@%X\n",
830 hvcsd->vdev->unit_address);
831 return retval;
832 }
669 833
670 printk(KERN_INFO "HVCS: vty-server@%X added to the vio bus.\n", dev->unit_address); 834 printk(KERN_INFO "HVCS: vty-server@%X added to the vio bus.\n", dev->unit_address);
671 835
@@ -1354,8 +1518,10 @@ static int __init hvcs_module_init(void)
1354 if (!hvcs_tty_driver) 1518 if (!hvcs_tty_driver)
1355 return -ENOMEM; 1519 return -ENOMEM;
1356 1520
1357 if (hvcs_alloc_index_list(num_ttys_to_alloc)) 1521 if (hvcs_alloc_index_list(num_ttys_to_alloc)) {
1358 return -ENOMEM; 1522 rc = -ENOMEM;
1523 goto index_fail;
1524 }
1359 1525
1360 hvcs_tty_driver->owner = THIS_MODULE; 1526 hvcs_tty_driver->owner = THIS_MODULE;
1361 1527
@@ -1385,41 +1551,57 @@ static int __init hvcs_module_init(void)
1385 * dynamically assigned major and minor numbers for our devices. 1551 * dynamically assigned major and minor numbers for our devices.
1386 */ 1552 */
1387 if (tty_register_driver(hvcs_tty_driver)) { 1553 if (tty_register_driver(hvcs_tty_driver)) {
1388 printk(KERN_ERR "HVCS: registration " 1554 printk(KERN_ERR "HVCS: registration as a tty driver failed.\n");
1389 " as a tty driver failed.\n"); 1555 rc = -EIO;
1390 hvcs_free_index_list(); 1556 goto register_fail;
1391 put_tty_driver(hvcs_tty_driver);
1392 return -EIO;
1393 } 1557 }
1394 1558
1395 hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL); 1559 hvcs_pi_buff = kmalloc(PAGE_SIZE, GFP_KERNEL);
1396 if (!hvcs_pi_buff) { 1560 if (!hvcs_pi_buff) {
1397 tty_unregister_driver(hvcs_tty_driver); 1561 rc = -ENOMEM;
1398 hvcs_free_index_list(); 1562 goto buff_alloc_fail;
1399 put_tty_driver(hvcs_tty_driver);
1400 return -ENOMEM;
1401 } 1563 }
1402 1564
1403 hvcs_task = kthread_run(khvcsd, NULL, "khvcsd"); 1565 hvcs_task = kthread_run(khvcsd, NULL, "khvcsd");
1404 if (IS_ERR(hvcs_task)) { 1566 if (IS_ERR(hvcs_task)) {
1405 printk(KERN_ERR "HVCS: khvcsd creation failed. Driver not loaded.\n"); 1567 printk(KERN_ERR "HVCS: khvcsd creation failed. Driver not loaded.\n");
1406 kfree(hvcs_pi_buff); 1568 rc = -EIO;
1407 tty_unregister_driver(hvcs_tty_driver); 1569 goto kthread_fail;
1408 hvcs_free_index_list();
1409 put_tty_driver(hvcs_tty_driver);
1410 return -EIO;
1411 } 1570 }
1412 1571
1413 rc = vio_register_driver(&hvcs_vio_driver); 1572 rc = vio_register_driver(&hvcs_vio_driver);
1573 if (rc) {
1574 printk(KERN_ERR "HVCS: can't register vio driver\n");
1575 goto vio_fail;
1576 }
1414 1577
1415 /* 1578 /*
1416 * This needs to be done AFTER the vio_register_driver() call or else 1579 * This needs to be done AFTER the vio_register_driver() call or else
1417 * the kobjects won't be initialized properly. 1580 * the kobjects won't be initialized properly.
1418 */ 1581 */
1419 hvcs_create_driver_attrs(); 1582 rc = driver_create_file(&(hvcs_vio_driver.driver), &driver_attr_rescan);
1583 if (rc) {
1584 printk(KERN_ERR "HVCS: sysfs attr create failed\n");
1585 goto attr_fail;
1586 }
1420 1587
1421 printk(KERN_INFO "HVCS: driver module inserted.\n"); 1588 printk(KERN_INFO "HVCS: driver module inserted.\n");
1422 1589
1590 return 0;
1591
1592attr_fail:
1593 vio_unregister_driver(&hvcs_vio_driver);
1594vio_fail:
1595 kthread_stop(hvcs_task);
1596kthread_fail:
1597 kfree(hvcs_pi_buff);
1598buff_alloc_fail:
1599 tty_unregister_driver(hvcs_tty_driver);
1600register_fail:
1601 hvcs_free_index_list();
1602index_fail:
1603 put_tty_driver(hvcs_tty_driver);
1604 hvcs_tty_driver = NULL;
1423 return rc; 1605 return rc;
1424} 1606}
1425 1607
@@ -1441,7 +1623,7 @@ static void __exit hvcs_module_exit(void)
1441 hvcs_pi_buff = NULL; 1623 hvcs_pi_buff = NULL;
1442 spin_unlock(&hvcs_pi_lock); 1624 spin_unlock(&hvcs_pi_lock);
1443 1625
1444 hvcs_remove_driver_attrs(); 1626 driver_remove_file(&hvcs_vio_driver.driver, &driver_attr_rescan);
1445 1627
1446 vio_unregister_driver(&hvcs_vio_driver); 1628 vio_unregister_driver(&hvcs_vio_driver);
1447 1629
@@ -1456,191 +1638,3 @@ static void __exit hvcs_module_exit(void)
1456 1638
1457module_init(hvcs_module_init); 1639module_init(hvcs_module_init);
1458module_exit(hvcs_module_exit); 1640module_exit(hvcs_module_exit);
1459
1460static inline struct hvcs_struct *from_vio_dev(struct vio_dev *viod)
1461{
1462 return viod->dev.driver_data;
1463}
1464/* The sysfs interface for the driver and devices */
1465
1466static ssize_t hvcs_partner_vtys_show(struct device *dev, struct device_attribute *attr, char *buf)
1467{
1468 struct vio_dev *viod = to_vio_dev(dev);
1469 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1470 unsigned long flags;
1471 int retval;
1472
1473 spin_lock_irqsave(&hvcsd->lock, flags);
1474 retval = sprintf(buf, "%X\n", hvcsd->p_unit_address);
1475 spin_unlock_irqrestore(&hvcsd->lock, flags);
1476 return retval;
1477}
1478static DEVICE_ATTR(partner_vtys, S_IRUGO, hvcs_partner_vtys_show, NULL);
1479
1480static ssize_t hvcs_partner_clcs_show(struct device *dev, struct device_attribute *attr, char *buf)
1481{
1482 struct vio_dev *viod = to_vio_dev(dev);
1483 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1484 unsigned long flags;
1485 int retval;
1486
1487 spin_lock_irqsave(&hvcsd->lock, flags);
1488 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
1489 spin_unlock_irqrestore(&hvcsd->lock, flags);
1490 return retval;
1491}
1492static DEVICE_ATTR(partner_clcs, S_IRUGO, hvcs_partner_clcs_show, NULL);
1493
1494static ssize_t hvcs_current_vty_store(struct device *dev, struct device_attribute *attr, const char * buf,
1495 size_t count)
1496{
1497 /*
1498 * Don't need this feature at the present time because firmware doesn't
1499 * yet support multiple partners.
1500 */
1501 printk(KERN_INFO "HVCS: Denied current_vty change: -EPERM.\n");
1502 return -EPERM;
1503}
1504
1505static ssize_t hvcs_current_vty_show(struct device *dev, struct device_attribute *attr, char *buf)
1506{
1507 struct vio_dev *viod = to_vio_dev(dev);
1508 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1509 unsigned long flags;
1510 int retval;
1511
1512 spin_lock_irqsave(&hvcsd->lock, flags);
1513 retval = sprintf(buf, "%s\n", &hvcsd->p_location_code[0]);
1514 spin_unlock_irqrestore(&hvcsd->lock, flags);
1515 return retval;
1516}
1517
1518static DEVICE_ATTR(current_vty,
1519 S_IRUGO | S_IWUSR, hvcs_current_vty_show, hvcs_current_vty_store);
1520
1521static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribute *attr, const char *buf,
1522 size_t count)
1523{
1524 struct vio_dev *viod = to_vio_dev(dev);
1525 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1526 unsigned long flags;
1527
1528 /* writing a '0' to this sysfs entry will result in the disconnect. */
1529 if (simple_strtol(buf, NULL, 0) != 0)
1530 return -EINVAL;
1531
1532 spin_lock_irqsave(&hvcsd->lock, flags);
1533
1534 if (hvcsd->open_count > 0) {
1535 spin_unlock_irqrestore(&hvcsd->lock, flags);
1536 printk(KERN_INFO "HVCS: vterm state unchanged. "
1537 "The hvcs device node is still in use.\n");
1538 return -EPERM;
1539 }
1540
1541 if (hvcsd->connected == 0) {
1542 spin_unlock_irqrestore(&hvcsd->lock, flags);
1543 printk(KERN_INFO "HVCS: vterm state unchanged. The"
1544 " vty-server is not connected to a vty.\n");
1545 return -EPERM;
1546 }
1547
1548 hvcs_partner_free(hvcsd);
1549 printk(KERN_INFO "HVCS: Closed vty-server@%X and"
1550 " partner vty@%X:%d connection.\n",
1551 hvcsd->vdev->unit_address,
1552 hvcsd->p_unit_address,
1553 (uint32_t)hvcsd->p_partition_ID);
1554
1555 spin_unlock_irqrestore(&hvcsd->lock, flags);
1556 return count;
1557}
1558
1559static ssize_t hvcs_vterm_state_show(struct device *dev, struct device_attribute *attr, char *buf)
1560{
1561 struct vio_dev *viod = to_vio_dev(dev);
1562 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1563 unsigned long flags;
1564 int retval;
1565
1566 spin_lock_irqsave(&hvcsd->lock, flags);
1567 retval = sprintf(buf, "%d\n", hvcsd->connected);
1568 spin_unlock_irqrestore(&hvcsd->lock, flags);
1569 return retval;
1570}
1571static DEVICE_ATTR(vterm_state, S_IRUGO | S_IWUSR,
1572 hvcs_vterm_state_show, hvcs_vterm_state_store);
1573
1574static ssize_t hvcs_index_show(struct device *dev, struct device_attribute *attr, char *buf)
1575{
1576 struct vio_dev *viod = to_vio_dev(dev);
1577 struct hvcs_struct *hvcsd = from_vio_dev(viod);
1578 unsigned long flags;
1579 int retval;
1580
1581 spin_lock_irqsave(&hvcsd->lock, flags);
1582 retval = sprintf(buf, "%d\n", hvcsd->index);
1583 spin_unlock_irqrestore(&hvcsd->lock, flags);
1584 return retval;
1585}
1586
1587static DEVICE_ATTR(index, S_IRUGO, hvcs_index_show, NULL);
1588
1589static struct attribute *hvcs_attrs[] = {
1590 &dev_attr_partner_vtys.attr,
1591 &dev_attr_partner_clcs.attr,
1592 &dev_attr_current_vty.attr,
1593 &dev_attr_vterm_state.attr,
1594 &dev_attr_index.attr,
1595 NULL,
1596};
1597
1598static struct attribute_group hvcs_attr_group = {
1599 .attrs = hvcs_attrs,
1600};
1601
1602static void hvcs_create_device_attrs(struct hvcs_struct *hvcsd)
1603{
1604 struct vio_dev *vdev = hvcsd->vdev;
1605 sysfs_create_group(&vdev->dev.kobj, &hvcs_attr_group);
1606}
1607
1608static void hvcs_remove_device_attrs(struct vio_dev *vdev)
1609{
1610 sysfs_remove_group(&vdev->dev.kobj, &hvcs_attr_group);
1611}
1612
1613static ssize_t hvcs_rescan_show(struct device_driver *ddp, char *buf)
1614{
1615 /* A 1 means it is updating, a 0 means it is done updating */
1616 return snprintf(buf, PAGE_SIZE, "%d\n", hvcs_rescan_status);
1617}
1618
1619static ssize_t hvcs_rescan_store(struct device_driver *ddp, const char * buf,
1620 size_t count)
1621{
1622 if ((simple_strtol(buf, NULL, 0) != 1)
1623 && (hvcs_rescan_status != 0))
1624 return -EINVAL;
1625
1626 hvcs_rescan_status = 1;
1627 printk(KERN_INFO "HVCS: rescanning partner info for all"
1628 " vty-servers.\n");
1629 hvcs_rescan_devices_list();
1630 hvcs_rescan_status = 0;
1631 return count;
1632}
1633static DRIVER_ATTR(rescan,
1634 S_IRUGO | S_IWUSR, hvcs_rescan_show, hvcs_rescan_store);
1635
1636static void hvcs_create_driver_attrs(void)
1637{
1638 struct device_driver *driverfs = &(hvcs_vio_driver.driver);
1639 driver_create_file(driverfs, &driver_attr_rescan);
1640}
1641
1642static void hvcs_remove_driver_attrs(void)
1643{
1644 struct device_driver *driverfs = &(hvcs_vio_driver.driver);
1645 driver_remove_file(driverfs, &driver_attr_rescan);
1646}
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 9f7635f75178..5f3acd8e64b8 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -3,17 +3,20 @@
3# 3#
4 4
5config HW_RANDOM 5config HW_RANDOM
6 bool "Hardware Random Number Generator Core support" 6 tristate "Hardware Random Number Generator Core support"
7 default y 7 default m
8 ---help--- 8 ---help---
9 Hardware Random Number Generator Core infrastructure. 9 Hardware Random Number Generator Core infrastructure.
10 10
11 To compile this driver as a module, choose M here: the
12 module will be called rng-core.
13
11 If unsure, say Y. 14 If unsure, say Y.
12 15
13config HW_RANDOM_INTEL 16config HW_RANDOM_INTEL
14 tristate "Intel HW Random Number Generator support" 17 tristate "Intel HW Random Number Generator support"
15 depends on HW_RANDOM && (X86 || IA64) && PCI 18 depends on HW_RANDOM && (X86 || IA64) && PCI
16 default y 19 default HW_RANDOM
17 ---help--- 20 ---help---
18 This driver provides kernel-side support for the Random Number 21 This driver provides kernel-side support for the Random Number
19 Generator hardware found on Intel i8xx-based motherboards. 22 Generator hardware found on Intel i8xx-based motherboards.
@@ -26,7 +29,7 @@ config HW_RANDOM_INTEL
26config HW_RANDOM_AMD 29config HW_RANDOM_AMD
27 tristate "AMD HW Random Number Generator support" 30 tristate "AMD HW Random Number Generator support"
28 depends on HW_RANDOM && X86 && PCI 31 depends on HW_RANDOM && X86 && PCI
29 default y 32 default HW_RANDOM
30 ---help--- 33 ---help---
31 This driver provides kernel-side support for the Random Number 34 This driver provides kernel-side support for the Random Number
32 Generator hardware found on AMD 76x-based motherboards. 35 Generator hardware found on AMD 76x-based motherboards.
@@ -39,7 +42,7 @@ config HW_RANDOM_AMD
39config HW_RANDOM_GEODE 42config HW_RANDOM_GEODE
40 tristate "AMD Geode HW Random Number Generator support" 43 tristate "AMD Geode HW Random Number Generator support"
41 depends on HW_RANDOM && X86 && PCI 44 depends on HW_RANDOM && X86 && PCI
42 default y 45 default HW_RANDOM
43 ---help--- 46 ---help---
44 This driver provides kernel-side support for the Random Number 47 This driver provides kernel-side support for the Random Number
45 Generator hardware found on the AMD Geode LX. 48 Generator hardware found on the AMD Geode LX.
@@ -52,7 +55,7 @@ config HW_RANDOM_GEODE
52config HW_RANDOM_VIA 55config HW_RANDOM_VIA
53 tristate "VIA HW Random Number Generator support" 56 tristate "VIA HW Random Number Generator support"
54 depends on HW_RANDOM && X86_32 57 depends on HW_RANDOM && X86_32
55 default y 58 default HW_RANDOM
56 ---help--- 59 ---help---
57 This driver provides kernel-side support for the Random Number 60 This driver provides kernel-side support for the Random Number
58 Generator hardware found on VIA based motherboards. 61 Generator hardware found on VIA based motherboards.
@@ -65,7 +68,7 @@ config HW_RANDOM_VIA
65config HW_RANDOM_IXP4XX 68config HW_RANDOM_IXP4XX
66 tristate "Intel IXP4xx NPU HW Random Number Generator support" 69 tristate "Intel IXP4xx NPU HW Random Number Generator support"
67 depends on HW_RANDOM && ARCH_IXP4XX 70 depends on HW_RANDOM && ARCH_IXP4XX
68 default y 71 default HW_RANDOM
69 ---help--- 72 ---help---
70 This driver provides kernel-side support for the Random 73 This driver provides kernel-side support for the Random
71 Number Generator hardware found on the Intel IXP4xx NPU. 74 Number Generator hardware found on the Intel IXP4xx NPU.
@@ -78,7 +81,7 @@ config HW_RANDOM_IXP4XX
78config HW_RANDOM_OMAP 81config HW_RANDOM_OMAP
79 tristate "OMAP Random Number Generator support" 82 tristate "OMAP Random Number Generator support"
80 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX) 83 depends on HW_RANDOM && (ARCH_OMAP16XX || ARCH_OMAP24XX)
81 default y 84 default HW_RANDOM
82 ---help--- 85 ---help---
83 This driver provides kernel-side support for the Random Number 86 This driver provides kernel-side support for the Random Number
84 Generator hardware found on OMAP16xx and OMAP24xx multimedia 87 Generator hardware found on OMAP16xx and OMAP24xx multimedia
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index e263ae96f940..c41fa19454e3 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -2,7 +2,8 @@
2# Makefile for HW Random Number Generator (RNG) device drivers. 2# Makefile for HW Random Number Generator (RNG) device drivers.
3# 3#
4 4
5obj-$(CONFIG_HW_RANDOM) += core.o 5obj-$(CONFIG_HW_RANDOM) += rng-core.o
6rng-core-y := core.o
6obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o 7obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o
7obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o 8obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o
8obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o 9obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o
diff --git a/drivers/char/ip2/i2cmd.h b/drivers/char/ip2/i2cmd.h
index baa4e721b758..29277ec6b8ed 100644
--- a/drivers/char/ip2/i2cmd.h
+++ b/drivers/char/ip2/i2cmd.h
@@ -367,11 +367,6 @@ static UCHAR cc02[];
367#define CSE_NULL 3 // Replace with a null 367#define CSE_NULL 3 // Replace with a null
368#define CSE_MARK 4 // Replace with a 3-character sequence (as Unix) 368#define CSE_MARK 4 // Replace with a 3-character sequence (as Unix)
369 369
370#define CMD_SET_REPLACEMENT(arg,ch) \
371 (((cmdSyntaxPtr)(ct36a))->cmd[1] = (arg), \
372 (((cmdSyntaxPtr)(ct36a))->cmd[2] = (ch), \
373 (cmdSyntaxPtr)(ct36a))
374
375#define CSE_REPLACE 0x8 // Replace the errored character with the 370#define CSE_REPLACE 0x8 // Replace the errored character with the
376 // replacement character defined here 371 // replacement character defined here
377 372
diff --git a/drivers/char/ip2/i2lib.c b/drivers/char/ip2/i2lib.c
index c213fdbdb2b0..78045767ec33 100644
--- a/drivers/char/ip2/i2lib.c
+++ b/drivers/char/ip2/i2lib.c
@@ -1016,7 +1016,6 @@ i2Output(i2ChanStrPtr pCh, const char *pSource, int count)
1016 unsigned short channel; 1016 unsigned short channel;
1017 unsigned short stuffIndex; 1017 unsigned short stuffIndex;
1018 unsigned long flags; 1018 unsigned long flags;
1019 int rc = 0;
1020 1019
1021 int bailout = 10; 1020 int bailout = 10;
1022 1021
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c
index 0030cd8e2e95..6c59baa887a8 100644
--- a/drivers/char/ipmi/ipmi_bt_sm.c
+++ b/drivers/char/ipmi/ipmi_bt_sm.c
@@ -33,11 +33,13 @@
33#include <linux/ipmi_msgdefs.h> /* for completion codes */ 33#include <linux/ipmi_msgdefs.h> /* for completion codes */
34#include "ipmi_si_sm.h" 34#include "ipmi_si_sm.h"
35 35
36static int bt_debug = 0x00; /* Production value 0, see following flags */ 36#define BT_DEBUG_OFF 0 /* Used in production */
37#define BT_DEBUG_ENABLE 1 /* Generic messages */
38#define BT_DEBUG_MSG 2 /* Prints all request/response buffers */
39#define BT_DEBUG_STATES 4 /* Verbose look at state changes */
40
41static int bt_debug = BT_DEBUG_OFF;
37 42
38#define BT_DEBUG_ENABLE 1
39#define BT_DEBUG_MSG 2
40#define BT_DEBUG_STATES 4
41module_param(bt_debug, int, 0644); 43module_param(bt_debug, int, 0644);
42MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states"); 44MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
43 45
@@ -47,38 +49,54 @@ MODULE_PARM_DESC(bt_debug, "debug bitmask, 1=enable, 2=messages, 4=states");
47 Since the Open IPMI architecture is single-message oriented at this 49 Since the Open IPMI architecture is single-message oriented at this
48 stage, the queue depth of BT is of no concern. */ 50 stage, the queue depth of BT is of no concern. */
49 51
50#define BT_NORMAL_TIMEOUT 5000000 /* seconds in microseconds */ 52#define BT_NORMAL_TIMEOUT 5 /* seconds */
51#define BT_RETRY_LIMIT 2 53#define BT_NORMAL_RETRY_LIMIT 2
52#define BT_RESET_DELAY 6000000 /* 6 seconds after warm reset */ 54#define BT_RESET_DELAY 6 /* seconds after warm reset */
55
56/* States are written in chronological order and usually cover
57 multiple rows of the state table discussion in the IPMI spec. */
53 58
54enum bt_states { 59enum bt_states {
55 BT_STATE_IDLE, 60 BT_STATE_IDLE = 0, /* Order is critical in this list */
56 BT_STATE_XACTION_START, 61 BT_STATE_XACTION_START,
57 BT_STATE_WRITE_BYTES, 62 BT_STATE_WRITE_BYTES,
58 BT_STATE_WRITE_END,
59 BT_STATE_WRITE_CONSUME, 63 BT_STATE_WRITE_CONSUME,
60 BT_STATE_B2H_WAIT, 64 BT_STATE_READ_WAIT,
61 BT_STATE_READ_END, 65 BT_STATE_CLEAR_B2H,
62 BT_STATE_RESET1, /* These must come last */ 66 BT_STATE_READ_BYTES,
67 BT_STATE_RESET1, /* These must come last */
63 BT_STATE_RESET2, 68 BT_STATE_RESET2,
64 BT_STATE_RESET3, 69 BT_STATE_RESET3,
65 BT_STATE_RESTART, 70 BT_STATE_RESTART,
66 BT_STATE_HOSED 71 BT_STATE_PRINTME,
72 BT_STATE_CAPABILITIES_BEGIN,
73 BT_STATE_CAPABILITIES_END,
74 BT_STATE_LONG_BUSY /* BT doesn't get hosed :-) */
67}; 75};
68 76
77/* Macros seen at the end of state "case" blocks. They help with legibility
78 and debugging. */
79
80#define BT_STATE_CHANGE(X,Y) { bt->state = X; return Y; }
81
82#define BT_SI_SM_RETURN(Y) { last_printed = BT_STATE_PRINTME; return Y; }
83
69struct si_sm_data { 84struct si_sm_data {
70 enum bt_states state; 85 enum bt_states state;
71 enum bt_states last_state; /* assist printing and resets */
72 unsigned char seq; /* BT sequence number */ 86 unsigned char seq; /* BT sequence number */
73 struct si_sm_io *io; 87 struct si_sm_io *io;
74 unsigned char write_data[IPMI_MAX_MSG_LENGTH]; 88 unsigned char write_data[IPMI_MAX_MSG_LENGTH];
75 int write_count; 89 int write_count;
76 unsigned char read_data[IPMI_MAX_MSG_LENGTH]; 90 unsigned char read_data[IPMI_MAX_MSG_LENGTH];
77 int read_count; 91 int read_count;
78 int truncated; 92 int truncated;
79 long timeout; 93 long timeout; /* microseconds countdown */
80 unsigned int error_retries; /* end of "common" fields */ 94 int error_retries; /* end of "common" fields */
81 int nonzero_status; /* hung BMCs stay all 0 */ 95 int nonzero_status; /* hung BMCs stay all 0 */
96 enum bt_states complete; /* to divert the state machine */
97 int BT_CAP_outreqs;
98 long BT_CAP_req2rsp;
99 int BT_CAP_retries; /* Recommended retries */
82}; 100};
83 101
84#define BT_CLR_WR_PTR 0x01 /* See IPMI 1.5 table 11.6.4 */ 102#define BT_CLR_WR_PTR 0x01 /* See IPMI 1.5 table 11.6.4 */
@@ -111,86 +129,118 @@ struct si_sm_data {
111static char *state2txt(unsigned char state) 129static char *state2txt(unsigned char state)
112{ 130{
113 switch (state) { 131 switch (state) {
114 case BT_STATE_IDLE: return("IDLE"); 132 case BT_STATE_IDLE: return("IDLE");
115 case BT_STATE_XACTION_START: return("XACTION"); 133 case BT_STATE_XACTION_START: return("XACTION");
116 case BT_STATE_WRITE_BYTES: return("WR_BYTES"); 134 case BT_STATE_WRITE_BYTES: return("WR_BYTES");
117 case BT_STATE_WRITE_END: return("WR_END"); 135 case BT_STATE_WRITE_CONSUME: return("WR_CONSUME");
118 case BT_STATE_WRITE_CONSUME: return("WR_CONSUME"); 136 case BT_STATE_READ_WAIT: return("RD_WAIT");
119 case BT_STATE_B2H_WAIT: return("B2H_WAIT"); 137 case BT_STATE_CLEAR_B2H: return("CLEAR_B2H");
120 case BT_STATE_READ_END: return("RD_END"); 138 case BT_STATE_READ_BYTES: return("RD_BYTES");
121 case BT_STATE_RESET1: return("RESET1"); 139 case BT_STATE_RESET1: return("RESET1");
122 case BT_STATE_RESET2: return("RESET2"); 140 case BT_STATE_RESET2: return("RESET2");
123 case BT_STATE_RESET3: return("RESET3"); 141 case BT_STATE_RESET3: return("RESET3");
124 case BT_STATE_RESTART: return("RESTART"); 142 case BT_STATE_RESTART: return("RESTART");
125 case BT_STATE_HOSED: return("HOSED"); 143 case BT_STATE_LONG_BUSY: return("LONG_BUSY");
144 case BT_STATE_CAPABILITIES_BEGIN: return("CAP_BEGIN");
145 case BT_STATE_CAPABILITIES_END: return("CAP_END");
126 } 146 }
127 return("BAD STATE"); 147 return("BAD STATE");
128} 148}
129#define STATE2TXT state2txt(bt->state) 149#define STATE2TXT state2txt(bt->state)
130 150
131static char *status2txt(unsigned char status, char *buf) 151static char *status2txt(unsigned char status)
132{ 152{
153 /*
154 * This cannot be called by two threads at the same time and
155 * the buffer is always consumed immediately, so the static is
156 * safe to use.
157 */
158 static char buf[40];
159
133 strcpy(buf, "[ "); 160 strcpy(buf, "[ ");
134 if (status & BT_B_BUSY) strcat(buf, "B_BUSY "); 161 if (status & BT_B_BUSY)
135 if (status & BT_H_BUSY) strcat(buf, "H_BUSY "); 162 strcat(buf, "B_BUSY ");
136 if (status & BT_OEM0) strcat(buf, "OEM0 "); 163 if (status & BT_H_BUSY)
137 if (status & BT_SMS_ATN) strcat(buf, "SMS "); 164 strcat(buf, "H_BUSY ");
138 if (status & BT_B2H_ATN) strcat(buf, "B2H "); 165 if (status & BT_OEM0)
139 if (status & BT_H2B_ATN) strcat(buf, "H2B "); 166 strcat(buf, "OEM0 ");
167 if (status & BT_SMS_ATN)
168 strcat(buf, "SMS ");
169 if (status & BT_B2H_ATN)
170 strcat(buf, "B2H ");
171 if (status & BT_H2B_ATN)
172 strcat(buf, "H2B ");
140 strcat(buf, "]"); 173 strcat(buf, "]");
141 return buf; 174 return buf;
142} 175}
143#define STATUS2TXT(buf) status2txt(status, buf) 176#define STATUS2TXT status2txt(status)
177
178/* called externally at insmod time, and internally on cleanup */
144 179
145/* This will be called from within this module on a hosed condition */
146#define FIRST_SEQ 0
147static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io) 180static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io)
148{ 181{
149 bt->state = BT_STATE_IDLE; 182 memset(bt, 0, sizeof(struct si_sm_data));
150 bt->last_state = BT_STATE_IDLE; 183 if (bt->io != io) { /* external: one-time only things */
151 bt->seq = FIRST_SEQ; 184 bt->io = io;
152 bt->io = io; 185 bt->seq = 0;
153 bt->write_count = 0; 186 }
154 bt->read_count = 0; 187 bt->state = BT_STATE_IDLE; /* start here */
155 bt->error_retries = 0; 188 bt->complete = BT_STATE_IDLE; /* end here */
156 bt->nonzero_status = 0; 189 bt->BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * 1000000;
157 bt->truncated = 0; 190 bt->BT_CAP_retries = BT_NORMAL_RETRY_LIMIT;
158 bt->timeout = BT_NORMAL_TIMEOUT; 191 /* BT_CAP_outreqs == zero is a flag to read BT Capabilities */
159 return 3; /* We claim 3 bytes of space; ought to check SPMI table */ 192 return 3; /* We claim 3 bytes of space; ought to check SPMI table */
160} 193}
161 194
195/* Jam a completion code (probably an error) into a response */
196
197static void force_result(struct si_sm_data *bt, unsigned char completion_code)
198{
199 bt->read_data[0] = 4; /* # following bytes */
200 bt->read_data[1] = bt->write_data[1] | 4; /* Odd NetFn/LUN */
201 bt->read_data[2] = bt->write_data[2]; /* seq (ignored) */
202 bt->read_data[3] = bt->write_data[3]; /* Command */
203 bt->read_data[4] = completion_code;
204 bt->read_count = 5;
205}
206
207/* The upper state machine starts here */
208
162static int bt_start_transaction(struct si_sm_data *bt, 209static int bt_start_transaction(struct si_sm_data *bt,
163 unsigned char *data, 210 unsigned char *data,
164 unsigned int size) 211 unsigned int size)
165{ 212{
166 unsigned int i; 213 unsigned int i;
167 214
168 if ((size < 2) || (size > (IPMI_MAX_MSG_LENGTH - 2))) 215 if (size < 2)
169 return -1; 216 return IPMI_REQ_LEN_INVALID_ERR;
217 if (size > IPMI_MAX_MSG_LENGTH)
218 return IPMI_REQ_LEN_EXCEEDED_ERR;
170 219
171 if ((bt->state != BT_STATE_IDLE) && (bt->state != BT_STATE_HOSED)) 220 if (bt->state == BT_STATE_LONG_BUSY)
172 return -2; 221 return IPMI_NODE_BUSY_ERR;
222
223 if (bt->state != BT_STATE_IDLE)
224 return IPMI_NOT_IN_MY_STATE_ERR;
173 225
174 if (bt_debug & BT_DEBUG_MSG) { 226 if (bt_debug & BT_DEBUG_MSG) {
175 printk(KERN_WARNING "+++++++++++++++++++++++++++++++++++++\n"); 227 printk(KERN_WARNING "BT: +++++++++++++++++ New command\n");
176 printk(KERN_WARNING "BT: write seq=0x%02X:", bt->seq); 228 printk(KERN_WARNING "BT: NetFn/LUN CMD [%d data]:", size - 2);
177 for (i = 0; i < size; i ++) 229 for (i = 0; i < size; i ++)
178 printk (" %02x", data[i]); 230 printk (" %02x", data[i]);
179 printk("\n"); 231 printk("\n");
180 } 232 }
181 bt->write_data[0] = size + 1; /* all data plus seq byte */ 233 bt->write_data[0] = size + 1; /* all data plus seq byte */
182 bt->write_data[1] = *data; /* NetFn/LUN */ 234 bt->write_data[1] = *data; /* NetFn/LUN */
183 bt->write_data[2] = bt->seq; 235 bt->write_data[2] = bt->seq++;
184 memcpy(bt->write_data + 3, data + 1, size - 1); 236 memcpy(bt->write_data + 3, data + 1, size - 1);
185 bt->write_count = size + 2; 237 bt->write_count = size + 2;
186
187 bt->error_retries = 0; 238 bt->error_retries = 0;
188 bt->nonzero_status = 0; 239 bt->nonzero_status = 0;
189 bt->read_count = 0;
190 bt->truncated = 0; 240 bt->truncated = 0;
191 bt->state = BT_STATE_XACTION_START; 241 bt->state = BT_STATE_XACTION_START;
192 bt->last_state = BT_STATE_IDLE; 242 bt->timeout = bt->BT_CAP_req2rsp;
193 bt->timeout = BT_NORMAL_TIMEOUT; 243 force_result(bt, IPMI_ERR_UNSPECIFIED);
194 return 0; 244 return 0;
195} 245}
196 246
@@ -198,38 +248,30 @@ static int bt_start_transaction(struct si_sm_data *bt,
198 it calls this. Strip out the length and seq bytes. */ 248 it calls this. Strip out the length and seq bytes. */
199 249
200static int bt_get_result(struct si_sm_data *bt, 250static int bt_get_result(struct si_sm_data *bt,
201 unsigned char *data, 251 unsigned char *data,
202 unsigned int length) 252 unsigned int length)
203{ 253{
204 int i, msg_len; 254 int i, msg_len;
205 255
206 msg_len = bt->read_count - 2; /* account for length & seq */ 256 msg_len = bt->read_count - 2; /* account for length & seq */
207 /* Always NetFn, Cmd, cCode */
208 if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH) { 257 if (msg_len < 3 || msg_len > IPMI_MAX_MSG_LENGTH) {
209 printk(KERN_DEBUG "BT results: bad msg_len = %d\n", msg_len); 258 force_result(bt, IPMI_ERR_UNSPECIFIED);
210 data[0] = bt->write_data[1] | 0x4; /* Kludge a response */
211 data[1] = bt->write_data[3];
212 data[2] = IPMI_ERR_UNSPECIFIED;
213 msg_len = 3; 259 msg_len = 3;
214 } else { 260 }
215 data[0] = bt->read_data[1]; 261 data[0] = bt->read_data[1];
216 data[1] = bt->read_data[3]; 262 data[1] = bt->read_data[3];
217 if (length < msg_len) 263 if (length < msg_len || bt->truncated) {
218 bt->truncated = 1; 264 data[2] = IPMI_ERR_MSG_TRUNCATED;
219 if (bt->truncated) { /* can be set in read_all_bytes() */ 265 msg_len = 3;
220 data[2] = IPMI_ERR_MSG_TRUNCATED; 266 } else
221 msg_len = 3; 267 memcpy(data + 2, bt->read_data + 4, msg_len - 2);
222 } else
223 memcpy(data + 2, bt->read_data + 4, msg_len - 2);
224 268
225 if (bt_debug & BT_DEBUG_MSG) { 269 if (bt_debug & BT_DEBUG_MSG) {
226 printk (KERN_WARNING "BT: res (raw)"); 270 printk (KERN_WARNING "BT: result %d bytes:", msg_len);
227 for (i = 0; i < msg_len; i++) 271 for (i = 0; i < msg_len; i++)
228 printk(" %02x", data[i]); 272 printk(" %02x", data[i]);
229 printk ("\n"); 273 printk ("\n");
230 }
231 } 274 }
232 bt->read_count = 0; /* paranoia */
233 return msg_len; 275 return msg_len;
234} 276}
235 277
@@ -238,22 +280,40 @@ static int bt_get_result(struct si_sm_data *bt,
238 280
239static void reset_flags(struct si_sm_data *bt) 281static void reset_flags(struct si_sm_data *bt)
240{ 282{
283 if (bt_debug)
284 printk(KERN_WARNING "IPMI BT: flag reset %s\n",
285 status2txt(BT_STATUS));
241 if (BT_STATUS & BT_H_BUSY) 286 if (BT_STATUS & BT_H_BUSY)
242 BT_CONTROL(BT_H_BUSY); 287 BT_CONTROL(BT_H_BUSY); /* force clear */
243 if (BT_STATUS & BT_B_BUSY) 288 BT_CONTROL(BT_CLR_WR_PTR); /* always reset */
244 BT_CONTROL(BT_B_BUSY); 289 BT_CONTROL(BT_SMS_ATN); /* always clear */
245 BT_CONTROL(BT_CLR_WR_PTR); 290 BT_INTMASK_W(BT_BMC_HWRST);
246 BT_CONTROL(BT_SMS_ATN); 291}
247 292
248 if (BT_STATUS & BT_B2H_ATN) { 293/* Get rid of an unwanted/stale response. This should only be needed for
249 int i; 294 BMCs that support multiple outstanding requests. */
250 BT_CONTROL(BT_H_BUSY); 295
251 BT_CONTROL(BT_B2H_ATN); 296static void drain_BMC2HOST(struct si_sm_data *bt)
252 BT_CONTROL(BT_CLR_RD_PTR); 297{
253 for (i = 0; i < IPMI_MAX_MSG_LENGTH + 2; i++) 298 int i, size;
254 BMC2HOST; 299
255 BT_CONTROL(BT_H_BUSY); 300 if (!(BT_STATUS & BT_B2H_ATN)) /* Not signalling a response */
256 } 301 return;
302
303 BT_CONTROL(BT_H_BUSY); /* now set */
304 BT_CONTROL(BT_B2H_ATN); /* always clear */
305 BT_STATUS; /* pause */
306 BT_CONTROL(BT_B2H_ATN); /* some BMCs are stubborn */
307 BT_CONTROL(BT_CLR_RD_PTR); /* always reset */
308 if (bt_debug)
309 printk(KERN_WARNING "IPMI BT: stale response %s; ",
310 status2txt(BT_STATUS));
311 size = BMC2HOST;
312 for (i = 0; i < size ; i++)
313 BMC2HOST;
314 BT_CONTROL(BT_H_BUSY); /* now clear */
315 if (bt_debug)
316 printk("drained %d bytes\n", size + 1);
257} 317}
258 318
259static inline void write_all_bytes(struct si_sm_data *bt) 319static inline void write_all_bytes(struct si_sm_data *bt)
@@ -261,201 +321,256 @@ static inline void write_all_bytes(struct si_sm_data *bt)
261 int i; 321 int i;
262 322
263 if (bt_debug & BT_DEBUG_MSG) { 323 if (bt_debug & BT_DEBUG_MSG) {
264 printk(KERN_WARNING "BT: write %d bytes seq=0x%02X", 324 printk(KERN_WARNING "BT: write %d bytes seq=0x%02X",
265 bt->write_count, bt->seq); 325 bt->write_count, bt->seq);
266 for (i = 0; i < bt->write_count; i++) 326 for (i = 0; i < bt->write_count; i++)
267 printk (" %02x", bt->write_data[i]); 327 printk (" %02x", bt->write_data[i]);
268 printk ("\n"); 328 printk ("\n");
269 } 329 }
270 for (i = 0; i < bt->write_count; i++) 330 for (i = 0; i < bt->write_count; i++)
271 HOST2BMC(bt->write_data[i]); 331 HOST2BMC(bt->write_data[i]);
272} 332}
273 333
274static inline int read_all_bytes(struct si_sm_data *bt) 334static inline int read_all_bytes(struct si_sm_data *bt)
275{ 335{
276 unsigned char i; 336 unsigned char i;
277 337
338 /* length is "framing info", minimum = 4: NetFn, Seq, Cmd, cCode.
339 Keep layout of first four bytes aligned with write_data[] */
340
278 bt->read_data[0] = BMC2HOST; 341 bt->read_data[0] = BMC2HOST;
279 bt->read_count = bt->read_data[0]; 342 bt->read_count = bt->read_data[0];
280 if (bt_debug & BT_DEBUG_MSG)
281 printk(KERN_WARNING "BT: read %d bytes:", bt->read_count);
282 343
283 /* minimum: length, NetFn, Seq, Cmd, cCode == 5 total, or 4 more
284 following the length byte. */
285 if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) { 344 if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) {
286 if (bt_debug & BT_DEBUG_MSG) 345 if (bt_debug & BT_DEBUG_MSG)
287 printk("bad length %d\n", bt->read_count); 346 printk(KERN_WARNING "BT: bad raw rsp len=%d\n",
347 bt->read_count);
288 bt->truncated = 1; 348 bt->truncated = 1;
289 return 1; /* let next XACTION START clean it up */ 349 return 1; /* let next XACTION START clean it up */
290 } 350 }
291 for (i = 1; i <= bt->read_count; i++) 351 for (i = 1; i <= bt->read_count; i++)
292 bt->read_data[i] = BMC2HOST; 352 bt->read_data[i] = BMC2HOST;
293 bt->read_count++; /* account for the length byte */ 353 bt->read_count++; /* Account internally for length byte */
294 354
295 if (bt_debug & BT_DEBUG_MSG) { 355 if (bt_debug & BT_DEBUG_MSG) {
296 for (i = 0; i < bt->read_count; i++) 356 int max = bt->read_count;
357
358 printk(KERN_WARNING "BT: got %d bytes seq=0x%02X",
359 max, bt->read_data[2]);
360 if (max > 16)
361 max = 16;
362 for (i = 0; i < max; i++)
297 printk (" %02x", bt->read_data[i]); 363 printk (" %02x", bt->read_data[i]);
298 printk ("\n"); 364 printk ("%s\n", bt->read_count == max ? "" : " ...");
299 } 365 }
300 if (bt->seq != bt->write_data[2]) /* idiot check */
301 printk(KERN_DEBUG "BT: internal error: sequence mismatch\n");
302 366
303 /* per the spec, the (NetFn, Seq, Cmd) tuples should match */ 367 /* per the spec, the (NetFn[1], Seq[2], Cmd[3]) tuples must match */
304 if ((bt->read_data[3] == bt->write_data[3]) && /* Cmd */ 368 if ((bt->read_data[3] == bt->write_data[3]) &&
305 (bt->read_data[2] == bt->write_data[2]) && /* Sequence */ 369 (bt->read_data[2] == bt->write_data[2]) &&
306 ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8))) 370 ((bt->read_data[1] & 0xF8) == (bt->write_data[1] & 0xF8)))
307 return 1; 371 return 1;
308 372
309 if (bt_debug & BT_DEBUG_MSG) 373 if (bt_debug & BT_DEBUG_MSG)
310 printk(KERN_WARNING "BT: bad packet: " 374 printk(KERN_WARNING "IPMI BT: bad packet: "
311 "want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n", 375 "want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n",
312 bt->write_data[1], bt->write_data[2], bt->write_data[3], 376 bt->write_data[1] | 0x04, bt->write_data[2], bt->write_data[3],
313 bt->read_data[1], bt->read_data[2], bt->read_data[3]); 377 bt->read_data[1], bt->read_data[2], bt->read_data[3]);
314 return 0; 378 return 0;
315} 379}
316 380
317/* Modifies bt->state appropriately, need to get into the bt_event() switch */ 381/* Restart if retries are left, or return an error completion code */
318 382
319static void error_recovery(struct si_sm_data *bt, char *reason) 383static enum si_sm_result error_recovery(struct si_sm_data *bt,
384 unsigned char status,
385 unsigned char cCode)
320{ 386{
321 unsigned char status; 387 char *reason;
322 char buf[40]; /* For getting status */
323 388
324 bt->timeout = BT_NORMAL_TIMEOUT; /* various places want to retry */ 389 bt->timeout = bt->BT_CAP_req2rsp;
325 390
326 status = BT_STATUS; 391 switch (cCode) {
327 printk(KERN_DEBUG "BT: %s in %s %s\n", reason, STATE2TXT, 392 case IPMI_TIMEOUT_ERR:
328 STATUS2TXT(buf)); 393 reason = "timeout";
394 break;
395 default:
396 reason = "internal error";
397 break;
398 }
399
400 printk(KERN_WARNING "IPMI BT: %s in %s %s ", /* open-ended line */
401 reason, STATE2TXT, STATUS2TXT);
329 402
403 /* Per the IPMI spec, retries are based on the sequence number
404 known only to this module, so manage a restart here. */
330 (bt->error_retries)++; 405 (bt->error_retries)++;
331 if (bt->error_retries > BT_RETRY_LIMIT) { 406 if (bt->error_retries < bt->BT_CAP_retries) {
332 printk(KERN_DEBUG "retry limit (%d) exceeded\n", BT_RETRY_LIMIT); 407 printk("%d retries left\n",
333 bt->state = BT_STATE_HOSED; 408 bt->BT_CAP_retries - bt->error_retries);
334 if (!bt->nonzero_status) 409 bt->state = BT_STATE_RESTART;
335 printk(KERN_ERR "IPMI: BT stuck, try power cycle\n"); 410 return SI_SM_CALL_WITHOUT_DELAY;
336 else if (bt->error_retries <= BT_RETRY_LIMIT + 1) {
337 printk(KERN_DEBUG "IPMI: BT reset (takes 5 secs)\n");
338 bt->state = BT_STATE_RESET1;
339 }
340 return;
341 } 411 }
342 412
343 /* Sometimes the BMC queues get in an "off-by-one" state...*/ 413 printk("failed %d retries, sending error response\n",
344 if ((bt->state == BT_STATE_B2H_WAIT) && (status & BT_B2H_ATN)) { 414 bt->BT_CAP_retries);
345 printk(KERN_DEBUG "retry B2H_WAIT\n"); 415 if (!bt->nonzero_status)
346 return; 416 printk(KERN_ERR "IPMI BT: stuck, try power cycle\n");
417
418 /* this is most likely during insmod */
419 else if (bt->seq <= (unsigned char)(bt->BT_CAP_retries & 0xFF)) {
420 printk(KERN_WARNING "IPMI: BT reset (takes 5 secs)\n");
421 bt->state = BT_STATE_RESET1;
422 return SI_SM_CALL_WITHOUT_DELAY;
347 } 423 }
348 424
349 printk(KERN_DEBUG "restart command\n"); 425 /* Concoct a useful error message, set up the next state, and
350 bt->state = BT_STATE_RESTART; 426 be done with this sequence. */
427
428 bt->state = BT_STATE_IDLE;
429 switch (cCode) {
430 case IPMI_TIMEOUT_ERR:
431 if (status & BT_B_BUSY) {
432 cCode = IPMI_NODE_BUSY_ERR;
433 bt->state = BT_STATE_LONG_BUSY;
434 }
435 break;
436 default:
437 break;
438 }
439 force_result(bt, cCode);
440 return SI_SM_TRANSACTION_COMPLETE;
351} 441}
352 442
353/* Check the status and (possibly) advance the BT state machine. The 443/* Check status and (usually) take action and change this state machine. */
354 default return is SI_SM_CALL_WITH_DELAY. */
355 444
356static enum si_sm_result bt_event(struct si_sm_data *bt, long time) 445static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
357{ 446{
358 unsigned char status; 447 unsigned char status, BT_CAP[8];
359 char buf[40]; /* For getting status */ 448 static enum bt_states last_printed = BT_STATE_PRINTME;
360 int i; 449 int i;
361 450
362 status = BT_STATUS; 451 status = BT_STATUS;
363 bt->nonzero_status |= status; 452 bt->nonzero_status |= status;
364 453 if ((bt_debug & BT_DEBUG_STATES) && (bt->state != last_printed)) {
365 if ((bt_debug & BT_DEBUG_STATES) && (bt->state != bt->last_state))
366 printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n", 454 printk(KERN_WARNING "BT: %s %s TO=%ld - %ld \n",
367 STATE2TXT, 455 STATE2TXT,
368 STATUS2TXT(buf), 456 STATUS2TXT,
369 bt->timeout, 457 bt->timeout,
370 time); 458 time);
371 bt->last_state = bt->state; 459 last_printed = bt->state;
460 }
372 461
373 if (bt->state == BT_STATE_HOSED) 462 /* Commands that time out may still (eventually) provide a response.
374 return SI_SM_HOSED; 463 This stale response will get in the way of a new response so remove
464 it if possible (hopefully during IDLE). Even if it comes up later
465 it will be rejected by its (now-forgotten) seq number. */
466
467 if ((bt->state < BT_STATE_WRITE_BYTES) && (status & BT_B2H_ATN)) {
468 drain_BMC2HOST(bt);
469 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
470 }
375 471
376 if (bt->state != BT_STATE_IDLE) { /* do timeout test */ 472 if ((bt->state != BT_STATE_IDLE) &&
473 (bt->state < BT_STATE_PRINTME)) { /* check timeout */
377 bt->timeout -= time; 474 bt->timeout -= time;
378 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1)) { 475 if ((bt->timeout < 0) && (bt->state < BT_STATE_RESET1))
379 error_recovery(bt, "timed out"); 476 return error_recovery(bt,
380 return SI_SM_CALL_WITHOUT_DELAY; 477 status,
381 } 478 IPMI_TIMEOUT_ERR);
382 } 479 }
383 480
384 switch (bt->state) { 481 switch (bt->state) {
385 482
386 case BT_STATE_IDLE: /* check for asynchronous messages */ 483 /* Idle state first checks for asynchronous messages from another
484 channel, then does some opportunistic housekeeping. */
485
486 case BT_STATE_IDLE:
387 if (status & BT_SMS_ATN) { 487 if (status & BT_SMS_ATN) {
388 BT_CONTROL(BT_SMS_ATN); /* clear it */ 488 BT_CONTROL(BT_SMS_ATN); /* clear it */
389 return SI_SM_ATTN; 489 return SI_SM_ATTN;
390 } 490 }
391 return SI_SM_IDLE;
392 491
393 case BT_STATE_XACTION_START: 492 if (status & BT_H_BUSY) /* clear a leftover H_BUSY */
394 if (status & BT_H_BUSY) {
395 BT_CONTROL(BT_H_BUSY); 493 BT_CONTROL(BT_H_BUSY);
396 break;
397 }
398 if (status & BT_B2H_ATN)
399 break;
400 bt->state = BT_STATE_WRITE_BYTES;
401 return SI_SM_CALL_WITHOUT_DELAY; /* for logging */
402 494
403 case BT_STATE_WRITE_BYTES: 495 /* Read BT capabilities if it hasn't been done yet */
496 if (!bt->BT_CAP_outreqs)
497 BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN,
498 SI_SM_CALL_WITHOUT_DELAY);
499 bt->timeout = bt->BT_CAP_req2rsp;
500 BT_SI_SM_RETURN(SI_SM_IDLE);
501
502 case BT_STATE_XACTION_START:
404 if (status & (BT_B_BUSY | BT_H2B_ATN)) 503 if (status & (BT_B_BUSY | BT_H2B_ATN))
405 break; 504 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
505 if (BT_STATUS & BT_H_BUSY)
506 BT_CONTROL(BT_H_BUSY); /* force clear */
507 BT_STATE_CHANGE(BT_STATE_WRITE_BYTES,
508 SI_SM_CALL_WITHOUT_DELAY);
509
510 case BT_STATE_WRITE_BYTES:
511 if (status & BT_H_BUSY)
512 BT_CONTROL(BT_H_BUSY); /* clear */
406 BT_CONTROL(BT_CLR_WR_PTR); 513 BT_CONTROL(BT_CLR_WR_PTR);
407 write_all_bytes(bt); 514 write_all_bytes(bt);
408 BT_CONTROL(BT_H2B_ATN); /* clears too fast to catch? */ 515 BT_CONTROL(BT_H2B_ATN); /* can clear too fast to catch */
409 bt->state = BT_STATE_WRITE_CONSUME; 516 BT_STATE_CHANGE(BT_STATE_WRITE_CONSUME,
410 return SI_SM_CALL_WITHOUT_DELAY; /* it MIGHT sail through */ 517 SI_SM_CALL_WITHOUT_DELAY);
411
412 case BT_STATE_WRITE_CONSUME: /* BMCs usually blow right thru here */
413 if (status & (BT_H2B_ATN | BT_B_BUSY))
414 break;
415 bt->state = BT_STATE_B2H_WAIT;
416 /* fall through with status */
417
418 /* Stay in BT_STATE_B2H_WAIT until a packet matches. However, spinning
419 hard here, constantly reading status, seems to hold off the
420 generation of B2H_ATN so ALWAYS return CALL_WITH_DELAY. */
421
422 case BT_STATE_B2H_WAIT:
423 if (!(status & BT_B2H_ATN))
424 break;
425
426 /* Assume ordered, uncached writes: no need to wait */
427 if (!(status & BT_H_BUSY))
428 BT_CONTROL(BT_H_BUSY); /* set */
429 BT_CONTROL(BT_B2H_ATN); /* clear it, ACK to the BMC */
430 BT_CONTROL(BT_CLR_RD_PTR); /* reset the queue */
431 i = read_all_bytes(bt);
432 BT_CONTROL(BT_H_BUSY); /* clear */
433 if (!i) /* Try this state again */
434 break;
435 bt->state = BT_STATE_READ_END;
436 return SI_SM_CALL_WITHOUT_DELAY; /* for logging */
437
438 case BT_STATE_READ_END:
439
440 /* I could wait on BT_H_BUSY to go clear for a truly clean
441 exit. However, this is already done in XACTION_START
442 and the (possible) extra loop/status/possible wait affects
443 performance. So, as long as it works, just ignore H_BUSY */
444
445#ifdef MAKE_THIS_TRUE_IF_NECESSARY
446 518
447 if (status & BT_H_BUSY) 519 case BT_STATE_WRITE_CONSUME:
448 break; 520 if (status & (BT_B_BUSY | BT_H2B_ATN))
449#endif 521 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
450 bt->seq++; 522 BT_STATE_CHANGE(BT_STATE_READ_WAIT,
451 bt->state = BT_STATE_IDLE; 523 SI_SM_CALL_WITHOUT_DELAY);
452 return SI_SM_TRANSACTION_COMPLETE; 524
525 /* Spinning hard can suppress B2H_ATN and force a timeout */
526
527 case BT_STATE_READ_WAIT:
528 if (!(status & BT_B2H_ATN))
529 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
530 BT_CONTROL(BT_H_BUSY); /* set */
531
532 /* Uncached, ordered writes should just proceeed serially but
533 some BMCs don't clear B2H_ATN with one hit. Fast-path a
534 workaround without too much penalty to the general case. */
535
536 BT_CONTROL(BT_B2H_ATN); /* clear it to ACK the BMC */
537 BT_STATE_CHANGE(BT_STATE_CLEAR_B2H,
538 SI_SM_CALL_WITHOUT_DELAY);
539
540 case BT_STATE_CLEAR_B2H:
541 if (status & BT_B2H_ATN) { /* keep hitting it */
542 BT_CONTROL(BT_B2H_ATN);
543 BT_SI_SM_RETURN(SI_SM_CALL_WITH_DELAY);
544 }
545 BT_STATE_CHANGE(BT_STATE_READ_BYTES,
546 SI_SM_CALL_WITHOUT_DELAY);
547
548 case BT_STATE_READ_BYTES:
549 if (!(status & BT_H_BUSY)) /* check in case of retry */
550 BT_CONTROL(BT_H_BUSY);
551 BT_CONTROL(BT_CLR_RD_PTR); /* start of BMC2HOST buffer */
552 i = read_all_bytes(bt); /* true == packet seq match */
553 BT_CONTROL(BT_H_BUSY); /* NOW clear */
554 if (!i) /* Not my message */
555 BT_STATE_CHANGE(BT_STATE_READ_WAIT,
556 SI_SM_CALL_WITHOUT_DELAY);
557 bt->state = bt->complete;
558 return bt->state == BT_STATE_IDLE ? /* where to next? */
559 SI_SM_TRANSACTION_COMPLETE : /* normal */
560 SI_SM_CALL_WITHOUT_DELAY; /* Startup magic */
561
562 case BT_STATE_LONG_BUSY: /* For example: after FW update */
563 if (!(status & BT_B_BUSY)) {
564 reset_flags(bt); /* next state is now IDLE */
565 bt_init_data(bt, bt->io);
566 }
567 return SI_SM_CALL_WITH_DELAY; /* No repeat printing */
453 568
454 case BT_STATE_RESET1: 569 case BT_STATE_RESET1:
455 reset_flags(bt); 570 reset_flags(bt);
456 bt->timeout = BT_RESET_DELAY; 571 drain_BMC2HOST(bt);
457 bt->state = BT_STATE_RESET2; 572 BT_STATE_CHANGE(BT_STATE_RESET2,
458 break; 573 SI_SM_CALL_WITH_DELAY);
459 574
460 case BT_STATE_RESET2: /* Send a soft reset */ 575 case BT_STATE_RESET2: /* Send a soft reset */
461 BT_CONTROL(BT_CLR_WR_PTR); 576 BT_CONTROL(BT_CLR_WR_PTR);
@@ -464,29 +579,59 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time)
464 HOST2BMC(42); /* Sequence number */ 579 HOST2BMC(42); /* Sequence number */
465 HOST2BMC(3); /* Cmd == Soft reset */ 580 HOST2BMC(3); /* Cmd == Soft reset */
466 BT_CONTROL(BT_H2B_ATN); 581 BT_CONTROL(BT_H2B_ATN);
467 bt->state = BT_STATE_RESET3; 582 bt->timeout = BT_RESET_DELAY * 1000000;
468 break; 583 BT_STATE_CHANGE(BT_STATE_RESET3,
584 SI_SM_CALL_WITH_DELAY);
469 585
470 case BT_STATE_RESET3: 586 case BT_STATE_RESET3: /* Hold off everything for a bit */
471 if (bt->timeout > 0) 587 if (bt->timeout > 0)
472 return SI_SM_CALL_WITH_DELAY; 588 return SI_SM_CALL_WITH_DELAY;
473 bt->state = BT_STATE_RESTART; /* printk in debug modes */ 589 drain_BMC2HOST(bt);
474 break; 590 BT_STATE_CHANGE(BT_STATE_RESTART,
591 SI_SM_CALL_WITH_DELAY);
475 592
476 case BT_STATE_RESTART: /* don't reset retries! */ 593 case BT_STATE_RESTART: /* don't reset retries or seq! */
477 reset_flags(bt);
478 bt->write_data[2] = ++bt->seq;
479 bt->read_count = 0; 594 bt->read_count = 0;
480 bt->nonzero_status = 0; 595 bt->nonzero_status = 0;
481 bt->timeout = BT_NORMAL_TIMEOUT; 596 bt->timeout = bt->BT_CAP_req2rsp;
482 bt->state = BT_STATE_XACTION_START; 597 BT_STATE_CHANGE(BT_STATE_XACTION_START,
483 break; 598 SI_SM_CALL_WITH_DELAY);
484 599
485 default: /* HOSED is supposed to be caught much earlier */ 600 /* Get BT Capabilities, using timing of upper level state machine.
486 error_recovery(bt, "internal logic error"); 601 Set outreqs to prevent infinite loop on timeout. */
487 break; 602 case BT_STATE_CAPABILITIES_BEGIN:
488 } 603 bt->BT_CAP_outreqs = 1;
489 return SI_SM_CALL_WITH_DELAY; 604 {
605 unsigned char GetBT_CAP[] = { 0x18, 0x36 };
606 bt->state = BT_STATE_IDLE;
607 bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP));
608 }
609 bt->complete = BT_STATE_CAPABILITIES_END;
610 BT_STATE_CHANGE(BT_STATE_XACTION_START,
611 SI_SM_CALL_WITH_DELAY);
612
613 case BT_STATE_CAPABILITIES_END:
614 i = bt_get_result(bt, BT_CAP, sizeof(BT_CAP));
615 bt_init_data(bt, bt->io);
616 if ((i == 8) && !BT_CAP[2]) {
617 bt->BT_CAP_outreqs = BT_CAP[3];
618 bt->BT_CAP_req2rsp = BT_CAP[6] * 1000000;
619 bt->BT_CAP_retries = BT_CAP[7];
620 } else
621 printk(KERN_WARNING "IPMI BT: using default values\n");
622 if (!bt->BT_CAP_outreqs)
623 bt->BT_CAP_outreqs = 1;
624 printk(KERN_WARNING "IPMI BT: req2rsp=%ld secs retries=%d\n",
625 bt->BT_CAP_req2rsp / 1000000L, bt->BT_CAP_retries);
626 bt->timeout = bt->BT_CAP_req2rsp;
627 return SI_SM_CALL_WITHOUT_DELAY;
628
629 default: /* should never occur */
630 return error_recovery(bt,
631 status,
632 IPMI_ERR_UNSPECIFIED);
633 }
634 return SI_SM_CALL_WITH_DELAY;
490} 635}
491 636
492static int bt_detect(struct si_sm_data *bt) 637static int bt_detect(struct si_sm_data *bt)
@@ -497,7 +642,7 @@ static int bt_detect(struct si_sm_data *bt)
497 test that first. The calling routine uses negative logic. */ 642 test that first. The calling routine uses negative logic. */
498 643
499 if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) 644 if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF))
500 return 1; 645 return 1;
501 reset_flags(bt); 646 reset_flags(bt);
502 return 0; 647 return 0;
503} 648}
@@ -513,11 +658,11 @@ static int bt_size(void)
513 658
514struct si_sm_handlers bt_smi_handlers = 659struct si_sm_handlers bt_smi_handlers =
515{ 660{
516 .init_data = bt_init_data, 661 .init_data = bt_init_data,
517 .start_transaction = bt_start_transaction, 662 .start_transaction = bt_start_transaction,
518 .get_result = bt_get_result, 663 .get_result = bt_get_result,
519 .event = bt_event, 664 .event = bt_event,
520 .detect = bt_detect, 665 .detect = bt_detect,
521 .cleanup = bt_cleanup, 666 .cleanup = bt_cleanup,
522 .size = bt_size, 667 .size = bt_size,
523}; 668};
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 81fcf0ce21d1..375d3378eecd 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -596,6 +596,31 @@ static int ipmi_ioctl(struct inode *inode,
596 rv = 0; 596 rv = 0;
597 break; 597 break;
598 } 598 }
599
600 case IPMICTL_GET_MAINTENANCE_MODE_CMD:
601 {
602 int mode;
603
604 mode = ipmi_get_maintenance_mode(priv->user);
605 if (copy_to_user(arg, &mode, sizeof(mode))) {
606 rv = -EFAULT;
607 break;
608 }
609 rv = 0;
610 break;
611 }
612
613 case IPMICTL_SET_MAINTENANCE_MODE_CMD:
614 {
615 int mode;
616
617 if (copy_from_user(&mode, arg, sizeof(mode))) {
618 rv = -EFAULT;
619 break;
620 }
621 rv = ipmi_set_maintenance_mode(priv->user, mode);
622 break;
623 }
599 } 624 }
600 625
601 return rv; 626 return rv;
diff --git a/drivers/char/ipmi/ipmi_kcs_sm.c b/drivers/char/ipmi/ipmi_kcs_sm.c
index 2062675f9e99..c1b8228cb7b6 100644
--- a/drivers/char/ipmi/ipmi_kcs_sm.c
+++ b/drivers/char/ipmi/ipmi_kcs_sm.c
@@ -93,8 +93,8 @@ enum kcs_states {
93 state machine. */ 93 state machine. */
94}; 94};
95 95
96#define MAX_KCS_READ_SIZE 80 96#define MAX_KCS_READ_SIZE IPMI_MAX_MSG_LENGTH
97#define MAX_KCS_WRITE_SIZE 80 97#define MAX_KCS_WRITE_SIZE IPMI_MAX_MSG_LENGTH
98 98
99/* Timeouts in microseconds. */ 99/* Timeouts in microseconds. */
100#define IBF_RETRY_TIMEOUT 1000000 100#define IBF_RETRY_TIMEOUT 1000000
@@ -261,12 +261,14 @@ static int start_kcs_transaction(struct si_sm_data *kcs, unsigned char *data,
261{ 261{
262 unsigned int i; 262 unsigned int i;
263 263
264 if ((size < 2) || (size > MAX_KCS_WRITE_SIZE)) { 264 if (size < 2)
265 return -1; 265 return IPMI_REQ_LEN_INVALID_ERR;
266 } 266 if (size > MAX_KCS_WRITE_SIZE)
267 if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED)) { 267 return IPMI_REQ_LEN_EXCEEDED_ERR;
268 return -2; 268
269 } 269 if ((kcs->state != KCS_IDLE) && (kcs->state != KCS_HOSED))
270 return IPMI_NOT_IN_MY_STATE_ERR;
271
270 if (kcs_debug & KCS_DEBUG_MSG) { 272 if (kcs_debug & KCS_DEBUG_MSG) {
271 printk(KERN_DEBUG "start_kcs_transaction -"); 273 printk(KERN_DEBUG "start_kcs_transaction -");
272 for (i = 0; i < size; i ++) { 274 for (i = 0; i < size; i ++) {
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index c47add8e47df..5703ee28e1cc 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -48,7 +48,7 @@
48 48
49#define PFX "IPMI message handler: " 49#define PFX "IPMI message handler: "
50 50
51#define IPMI_DRIVER_VERSION "39.0" 51#define IPMI_DRIVER_VERSION "39.1"
52 52
53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); 53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
54static int ipmi_init_msghandler(void); 54static int ipmi_init_msghandler(void);
@@ -59,6 +59,9 @@ static int initialized = 0;
59static struct proc_dir_entry *proc_ipmi_root = NULL; 59static struct proc_dir_entry *proc_ipmi_root = NULL;
60#endif /* CONFIG_PROC_FS */ 60#endif /* CONFIG_PROC_FS */
61 61
62/* Remain in auto-maintenance mode for this amount of time (in ms). */
63#define IPMI_MAINTENANCE_MODE_TIMEOUT 30000
64
62#define MAX_EVENTS_IN_QUEUE 25 65#define MAX_EVENTS_IN_QUEUE 25
63 66
64/* Don't let a message sit in a queue forever, always time it with at lest 67/* Don't let a message sit in a queue forever, always time it with at lest
@@ -193,17 +196,28 @@ struct ipmi_smi
193 196
194 struct kref refcount; 197 struct kref refcount;
195 198
199 /* Used for a list of interfaces. */
200 struct list_head link;
201
196 /* The list of upper layers that are using me. seq_lock 202 /* The list of upper layers that are using me. seq_lock
197 * protects this. */ 203 * protects this. */
198 struct list_head users; 204 struct list_head users;
199 205
206 /* Information to supply to users. */
207 unsigned char ipmi_version_major;
208 unsigned char ipmi_version_minor;
209
200 /* Used for wake ups at startup. */ 210 /* Used for wake ups at startup. */
201 wait_queue_head_t waitq; 211 wait_queue_head_t waitq;
202 212
203 struct bmc_device *bmc; 213 struct bmc_device *bmc;
204 char *my_dev_name; 214 char *my_dev_name;
215 char *sysfs_name;
205 216
206 /* This is the lower-layer's sender routine. */ 217 /* This is the lower-layer's sender routine. Note that you
218 * must either be holding the ipmi_interfaces_mutex or be in
219 * an umpreemptible region to use this. You must fetch the
220 * value into a local variable and make sure it is not NULL. */
207 struct ipmi_smi_handlers *handlers; 221 struct ipmi_smi_handlers *handlers;
208 void *send_info; 222 void *send_info;
209 223
@@ -242,6 +256,7 @@ struct ipmi_smi
242 spinlock_t events_lock; /* For dealing with event stuff. */ 256 spinlock_t events_lock; /* For dealing with event stuff. */
243 struct list_head waiting_events; 257 struct list_head waiting_events;
244 unsigned int waiting_events_count; /* How many events in queue? */ 258 unsigned int waiting_events_count; /* How many events in queue? */
259 int delivering_events;
245 260
246 /* The event receiver for my BMC, only really used at panic 261 /* The event receiver for my BMC, only really used at panic
247 shutdown as a place to store this. */ 262 shutdown as a place to store this. */
@@ -250,6 +265,12 @@ struct ipmi_smi
250 unsigned char local_sel_device; 265 unsigned char local_sel_device;
251 unsigned char local_event_generator; 266 unsigned char local_event_generator;
252 267
268 /* For handling of maintenance mode. */
269 int maintenance_mode;
270 int maintenance_mode_enable;
271 int auto_maintenance_timeout;
272 spinlock_t maintenance_mode_lock; /* Used in a timer... */
273
253 /* A cheap hack, if this is non-null and a message to an 274 /* A cheap hack, if this is non-null and a message to an
254 interface comes in with a NULL user, call this routine with 275 interface comes in with a NULL user, call this routine with
255 it. Note that the message will still be freed by the 276 it. Note that the message will still be freed by the
@@ -338,13 +359,6 @@ struct ipmi_smi
338}; 359};
339#define to_si_intf_from_dev(device) container_of(device, struct ipmi_smi, dev) 360#define to_si_intf_from_dev(device) container_of(device, struct ipmi_smi, dev)
340 361
341/* Used to mark an interface entry that cannot be used but is not a
342 * free entry, either, primarily used at creation and deletion time so
343 * a slot doesn't get reused too quickly. */
344#define IPMI_INVALID_INTERFACE_ENTRY ((ipmi_smi_t) ((long) 1))
345#define IPMI_INVALID_INTERFACE(i) (((i) == NULL) \
346 || (i == IPMI_INVALID_INTERFACE_ENTRY))
347
348/** 362/**
349 * The driver model view of the IPMI messaging driver. 363 * The driver model view of the IPMI messaging driver.
350 */ 364 */
@@ -354,16 +368,13 @@ static struct device_driver ipmidriver = {
354}; 368};
355static DEFINE_MUTEX(ipmidriver_mutex); 369static DEFINE_MUTEX(ipmidriver_mutex);
356 370
357#define MAX_IPMI_INTERFACES 4 371static struct list_head ipmi_interfaces = LIST_HEAD_INIT(ipmi_interfaces);
358static ipmi_smi_t ipmi_interfaces[MAX_IPMI_INTERFACES]; 372static DEFINE_MUTEX(ipmi_interfaces_mutex);
359
360/* Directly protects the ipmi_interfaces data structure. */
361static DEFINE_SPINLOCK(interfaces_lock);
362 373
363/* List of watchers that want to know when smi's are added and 374/* List of watchers that want to know when smi's are added and
364 deleted. */ 375 deleted. */
365static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers); 376static struct list_head smi_watchers = LIST_HEAD_INIT(smi_watchers);
366static DECLARE_RWSEM(smi_watchers_sem); 377static DEFINE_MUTEX(smi_watchers_mutex);
367 378
368 379
369static void free_recv_msg_list(struct list_head *q) 380static void free_recv_msg_list(struct list_head *q)
@@ -423,48 +434,84 @@ static void intf_free(struct kref *ref)
423 kfree(intf); 434 kfree(intf);
424} 435}
425 436
437struct watcher_entry {
438 int intf_num;
439 ipmi_smi_t intf;
440 struct list_head link;
441};
442
426int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher) 443int ipmi_smi_watcher_register(struct ipmi_smi_watcher *watcher)
427{ 444{
428 int i; 445 ipmi_smi_t intf;
429 unsigned long flags; 446 struct list_head to_deliver = LIST_HEAD_INIT(to_deliver);
447 struct watcher_entry *e, *e2;
448
449 mutex_lock(&smi_watchers_mutex);
450
451 mutex_lock(&ipmi_interfaces_mutex);
430 452
431 down_write(&smi_watchers_sem); 453 /* Build a list of things to deliver. */
432 list_add(&(watcher->link), &smi_watchers); 454 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
433 up_write(&smi_watchers_sem); 455 if (intf->intf_num == -1)
434 spin_lock_irqsave(&interfaces_lock, flags);
435 for (i = 0; i < MAX_IPMI_INTERFACES; i++) {
436 ipmi_smi_t intf = ipmi_interfaces[i];
437 if (IPMI_INVALID_INTERFACE(intf))
438 continue; 456 continue;
439 spin_unlock_irqrestore(&interfaces_lock, flags); 457 e = kmalloc(sizeof(*e), GFP_KERNEL);
440 watcher->new_smi(i, intf->si_dev); 458 if (!e)
441 spin_lock_irqsave(&interfaces_lock, flags); 459 goto out_err;
460 kref_get(&intf->refcount);
461 e->intf = intf;
462 e->intf_num = intf->intf_num;
463 list_add_tail(&e->link, &to_deliver);
442 } 464 }
443 spin_unlock_irqrestore(&interfaces_lock, flags); 465
466 /* We will succeed, so add it to the list. */
467 list_add(&watcher->link, &smi_watchers);
468
469 mutex_unlock(&ipmi_interfaces_mutex);
470
471 list_for_each_entry_safe(e, e2, &to_deliver, link) {
472 list_del(&e->link);
473 watcher->new_smi(e->intf_num, e->intf->si_dev);
474 kref_put(&e->intf->refcount, intf_free);
475 kfree(e);
476 }
477
478 mutex_unlock(&smi_watchers_mutex);
479
444 return 0; 480 return 0;
481
482 out_err:
483 mutex_unlock(&ipmi_interfaces_mutex);
484 mutex_unlock(&smi_watchers_mutex);
485 list_for_each_entry_safe(e, e2, &to_deliver, link) {
486 list_del(&e->link);
487 kref_put(&e->intf->refcount, intf_free);
488 kfree(e);
489 }
490 return -ENOMEM;
445} 491}
446 492
447int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher) 493int ipmi_smi_watcher_unregister(struct ipmi_smi_watcher *watcher)
448{ 494{
449 down_write(&smi_watchers_sem); 495 mutex_lock(&smi_watchers_mutex);
450 list_del(&(watcher->link)); 496 list_del(&(watcher->link));
451 up_write(&smi_watchers_sem); 497 mutex_unlock(&smi_watchers_mutex);
452 return 0; 498 return 0;
453} 499}
454 500
501/*
502 * Must be called with smi_watchers_mutex held.
503 */
455static void 504static void
456call_smi_watchers(int i, struct device *dev) 505call_smi_watchers(int i, struct device *dev)
457{ 506{
458 struct ipmi_smi_watcher *w; 507 struct ipmi_smi_watcher *w;
459 508
460 down_read(&smi_watchers_sem);
461 list_for_each_entry(w, &smi_watchers, link) { 509 list_for_each_entry(w, &smi_watchers, link) {
462 if (try_module_get(w->owner)) { 510 if (try_module_get(w->owner)) {
463 w->new_smi(i, dev); 511 w->new_smi(i, dev);
464 module_put(w->owner); 512 module_put(w->owner);
465 } 513 }
466 } 514 }
467 up_read(&smi_watchers_sem);
468} 515}
469 516
470static int 517static int
@@ -590,6 +637,17 @@ static void deliver_response(struct ipmi_recv_msg *msg)
590 } 637 }
591} 638}
592 639
640static void
641deliver_err_response(struct ipmi_recv_msg *msg, int err)
642{
643 msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
644 msg->msg_data[0] = err;
645 msg->msg.netfn |= 1; /* Convert to a response. */
646 msg->msg.data_len = 1;
647 msg->msg.data = msg->msg_data;
648 deliver_response(msg);
649}
650
593/* Find the next sequence number not being used and add the given 651/* Find the next sequence number not being used and add the given
594 message with the given timeout to the sequence table. This must be 652 message with the given timeout to the sequence table. This must be
595 called with the interface's seq_lock held. */ 653 called with the interface's seq_lock held. */
@@ -727,14 +785,8 @@ static int intf_err_seq(ipmi_smi_t intf,
727 } 785 }
728 spin_unlock_irqrestore(&(intf->seq_lock), flags); 786 spin_unlock_irqrestore(&(intf->seq_lock), flags);
729 787
730 if (msg) { 788 if (msg)
731 msg->recv_type = IPMI_RESPONSE_RECV_TYPE; 789 deliver_err_response(msg, err);
732 msg->msg_data[0] = err;
733 msg->msg.netfn |= 1; /* Convert to a response. */
734 msg->msg.data_len = 1;
735 msg->msg.data = msg->msg_data;
736 deliver_response(msg);
737 }
738 790
739 return rv; 791 return rv;
740} 792}
@@ -776,17 +828,18 @@ int ipmi_create_user(unsigned int if_num,
776 if (!new_user) 828 if (!new_user)
777 return -ENOMEM; 829 return -ENOMEM;
778 830
779 spin_lock_irqsave(&interfaces_lock, flags); 831 mutex_lock(&ipmi_interfaces_mutex);
780 intf = ipmi_interfaces[if_num]; 832 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
781 if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) { 833 if (intf->intf_num == if_num)
782 spin_unlock_irqrestore(&interfaces_lock, flags); 834 goto found;
783 rv = -EINVAL;
784 goto out_kfree;
785 } 835 }
836 /* Not found, return an error */
837 rv = -EINVAL;
838 goto out_kfree;
786 839
840 found:
787 /* Note that each existing user holds a refcount to the interface. */ 841 /* Note that each existing user holds a refcount to the interface. */
788 kref_get(&intf->refcount); 842 kref_get(&intf->refcount);
789 spin_unlock_irqrestore(&interfaces_lock, flags);
790 843
791 kref_init(&new_user->refcount); 844 kref_init(&new_user->refcount);
792 new_user->handler = handler; 845 new_user->handler = handler;
@@ -807,6 +860,10 @@ int ipmi_create_user(unsigned int if_num,
807 } 860 }
808 } 861 }
809 862
863 /* Hold the lock so intf->handlers is guaranteed to be good
864 * until now */
865 mutex_unlock(&ipmi_interfaces_mutex);
866
810 new_user->valid = 1; 867 new_user->valid = 1;
811 spin_lock_irqsave(&intf->seq_lock, flags); 868 spin_lock_irqsave(&intf->seq_lock, flags);
812 list_add_rcu(&new_user->link, &intf->users); 869 list_add_rcu(&new_user->link, &intf->users);
@@ -817,6 +874,7 @@ int ipmi_create_user(unsigned int if_num,
817out_kref: 874out_kref:
818 kref_put(&intf->refcount, intf_free); 875 kref_put(&intf->refcount, intf_free);
819out_kfree: 876out_kfree:
877 mutex_unlock(&ipmi_interfaces_mutex);
820 kfree(new_user); 878 kfree(new_user);
821 return rv; 879 return rv;
822} 880}
@@ -846,6 +904,7 @@ int ipmi_destroy_user(ipmi_user_t user)
846 && (intf->seq_table[i].recv_msg->user == user)) 904 && (intf->seq_table[i].recv_msg->user == user))
847 { 905 {
848 intf->seq_table[i].inuse = 0; 906 intf->seq_table[i].inuse = 0;
907 ipmi_free_recv_msg(intf->seq_table[i].recv_msg);
849 } 908 }
850 } 909 }
851 spin_unlock_irqrestore(&intf->seq_lock, flags); 910 spin_unlock_irqrestore(&intf->seq_lock, flags);
@@ -872,9 +931,13 @@ int ipmi_destroy_user(ipmi_user_t user)
872 kfree(rcvr); 931 kfree(rcvr);
873 } 932 }
874 933
875 module_put(intf->handlers->owner); 934 mutex_lock(&ipmi_interfaces_mutex);
876 if (intf->handlers->dec_usecount) 935 if (intf->handlers) {
877 intf->handlers->dec_usecount(intf->send_info); 936 module_put(intf->handlers->owner);
937 if (intf->handlers->dec_usecount)
938 intf->handlers->dec_usecount(intf->send_info);
939 }
940 mutex_unlock(&ipmi_interfaces_mutex);
878 941
879 kref_put(&intf->refcount, intf_free); 942 kref_put(&intf->refcount, intf_free);
880 943
@@ -887,8 +950,8 @@ void ipmi_get_version(ipmi_user_t user,
887 unsigned char *major, 950 unsigned char *major,
888 unsigned char *minor) 951 unsigned char *minor)
889{ 952{
890 *major = ipmi_version_major(&user->intf->bmc->id); 953 *major = user->intf->ipmi_version_major;
891 *minor = ipmi_version_minor(&user->intf->bmc->id); 954 *minor = user->intf->ipmi_version_minor;
892} 955}
893 956
894int ipmi_set_my_address(ipmi_user_t user, 957int ipmi_set_my_address(ipmi_user_t user,
@@ -931,6 +994,65 @@ int ipmi_get_my_LUN(ipmi_user_t user,
931 return 0; 994 return 0;
932} 995}
933 996
997int ipmi_get_maintenance_mode(ipmi_user_t user)
998{
999 int mode;
1000 unsigned long flags;
1001
1002 spin_lock_irqsave(&user->intf->maintenance_mode_lock, flags);
1003 mode = user->intf->maintenance_mode;
1004 spin_unlock_irqrestore(&user->intf->maintenance_mode_lock, flags);
1005
1006 return mode;
1007}
1008EXPORT_SYMBOL(ipmi_get_maintenance_mode);
1009
1010static void maintenance_mode_update(ipmi_smi_t intf)
1011{
1012 if (intf->handlers->set_maintenance_mode)
1013 intf->handlers->set_maintenance_mode(
1014 intf->send_info, intf->maintenance_mode_enable);
1015}
1016
1017int ipmi_set_maintenance_mode(ipmi_user_t user, int mode)
1018{
1019 int rv = 0;
1020 unsigned long flags;
1021 ipmi_smi_t intf = user->intf;
1022
1023 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
1024 if (intf->maintenance_mode != mode) {
1025 switch (mode) {
1026 case IPMI_MAINTENANCE_MODE_AUTO:
1027 intf->maintenance_mode = mode;
1028 intf->maintenance_mode_enable
1029 = (intf->auto_maintenance_timeout > 0);
1030 break;
1031
1032 case IPMI_MAINTENANCE_MODE_OFF:
1033 intf->maintenance_mode = mode;
1034 intf->maintenance_mode_enable = 0;
1035 break;
1036
1037 case IPMI_MAINTENANCE_MODE_ON:
1038 intf->maintenance_mode = mode;
1039 intf->maintenance_mode_enable = 1;
1040 break;
1041
1042 default:
1043 rv = -EINVAL;
1044 goto out_unlock;
1045 }
1046
1047 maintenance_mode_update(intf);
1048 }
1049 out_unlock:
1050 spin_unlock_irqrestore(&intf->maintenance_mode_lock, flags);
1051
1052 return rv;
1053}
1054EXPORT_SYMBOL(ipmi_set_maintenance_mode);
1055
934int ipmi_set_gets_events(ipmi_user_t user, int val) 1056int ipmi_set_gets_events(ipmi_user_t user, int val)
935{ 1057{
936 unsigned long flags; 1058 unsigned long flags;
@@ -943,20 +1065,33 @@ int ipmi_set_gets_events(ipmi_user_t user, int val)
943 spin_lock_irqsave(&intf->events_lock, flags); 1065 spin_lock_irqsave(&intf->events_lock, flags);
944 user->gets_events = val; 1066 user->gets_events = val;
945 1067
946 if (val) { 1068 if (intf->delivering_events)
947 /* Deliver any queued events. */ 1069 /*
1070 * Another thread is delivering events for this, so
1071 * let it handle any new events.
1072 */
1073 goto out;
1074
1075 /* Deliver any queued events. */
1076 while (user->gets_events && !list_empty(&intf->waiting_events)) {
948 list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link) 1077 list_for_each_entry_safe(msg, msg2, &intf->waiting_events, link)
949 list_move_tail(&msg->link, &msgs); 1078 list_move_tail(&msg->link, &msgs);
950 intf->waiting_events_count = 0; 1079 intf->waiting_events_count = 0;
951 }
952 1080
953 /* Hold the events lock while doing this to preserve order. */ 1081 intf->delivering_events = 1;
954 list_for_each_entry_safe(msg, msg2, &msgs, link) { 1082 spin_unlock_irqrestore(&intf->events_lock, flags);
955 msg->user = user; 1083
956 kref_get(&user->refcount); 1084 list_for_each_entry_safe(msg, msg2, &msgs, link) {
957 deliver_response(msg); 1085 msg->user = user;
1086 kref_get(&user->refcount);
1087 deliver_response(msg);
1088 }
1089
1090 spin_lock_irqsave(&intf->events_lock, flags);
1091 intf->delivering_events = 0;
958 } 1092 }
959 1093
1094 out:
960 spin_unlock_irqrestore(&intf->events_lock, flags); 1095 spin_unlock_irqrestore(&intf->events_lock, flags);
961 1096
962 return 0; 1097 return 0;
@@ -1067,7 +1202,8 @@ int ipmi_unregister_for_cmd(ipmi_user_t user,
1067void ipmi_user_set_run_to_completion(ipmi_user_t user, int val) 1202void ipmi_user_set_run_to_completion(ipmi_user_t user, int val)
1068{ 1203{
1069 ipmi_smi_t intf = user->intf; 1204 ipmi_smi_t intf = user->intf;
1070 intf->handlers->set_run_to_completion(intf->send_info, val); 1205 if (intf->handlers)
1206 intf->handlers->set_run_to_completion(intf->send_info, val);
1071} 1207}
1072 1208
1073static unsigned char 1209static unsigned char
@@ -1178,10 +1314,11 @@ static int i_ipmi_request(ipmi_user_t user,
1178 int retries, 1314 int retries,
1179 unsigned int retry_time_ms) 1315 unsigned int retry_time_ms)
1180{ 1316{
1181 int rv = 0; 1317 int rv = 0;
1182 struct ipmi_smi_msg *smi_msg; 1318 struct ipmi_smi_msg *smi_msg;
1183 struct ipmi_recv_msg *recv_msg; 1319 struct ipmi_recv_msg *recv_msg;
1184 unsigned long flags; 1320 unsigned long flags;
1321 struct ipmi_smi_handlers *handlers;
1185 1322
1186 1323
1187 if (supplied_recv) { 1324 if (supplied_recv) {
@@ -1204,6 +1341,13 @@ static int i_ipmi_request(ipmi_user_t user,
1204 } 1341 }
1205 } 1342 }
1206 1343
1344 rcu_read_lock();
1345 handlers = intf->handlers;
1346 if (!handlers) {
1347 rv = -ENODEV;
1348 goto out_err;
1349 }
1350
1207 recv_msg->user = user; 1351 recv_msg->user = user;
1208 if (user) 1352 if (user)
1209 kref_get(&user->refcount); 1353 kref_get(&user->refcount);
@@ -1246,6 +1390,24 @@ static int i_ipmi_request(ipmi_user_t user,
1246 goto out_err; 1390 goto out_err;
1247 } 1391 }
1248 1392
1393 if (((msg->netfn == IPMI_NETFN_APP_REQUEST)
1394 && ((msg->cmd == IPMI_COLD_RESET_CMD)
1395 || (msg->cmd == IPMI_WARM_RESET_CMD)))
1396 || (msg->netfn == IPMI_NETFN_FIRMWARE_REQUEST))
1397 {
1398 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
1399 intf->auto_maintenance_timeout
1400 = IPMI_MAINTENANCE_MODE_TIMEOUT;
1401 if (!intf->maintenance_mode
1402 && !intf->maintenance_mode_enable)
1403 {
1404 intf->maintenance_mode_enable = 1;
1405 maintenance_mode_update(intf);
1406 }
1407 spin_unlock_irqrestore(&intf->maintenance_mode_lock,
1408 flags);
1409 }
1410
1249 if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) { 1411 if ((msg->data_len + 2) > IPMI_MAX_MSG_LENGTH) {
1250 spin_lock_irqsave(&intf->counter_lock, flags); 1412 spin_lock_irqsave(&intf->counter_lock, flags);
1251 intf->sent_invalid_commands++; 1413 intf->sent_invalid_commands++;
@@ -1520,11 +1682,14 @@ static int i_ipmi_request(ipmi_user_t user,
1520 printk("\n"); 1682 printk("\n");
1521 } 1683 }
1522#endif 1684#endif
1523 intf->handlers->sender(intf->send_info, smi_msg, priority); 1685
1686 handlers->sender(intf->send_info, smi_msg, priority);
1687 rcu_read_unlock();
1524 1688
1525 return 0; 1689 return 0;
1526 1690
1527 out_err: 1691 out_err:
1692 rcu_read_unlock();
1528 ipmi_free_smi_msg(smi_msg); 1693 ipmi_free_smi_msg(smi_msg);
1529 ipmi_free_recv_msg(recv_msg); 1694 ipmi_free_recv_msg(recv_msg);
1530 return rv; 1695 return rv;
@@ -1604,6 +1769,7 @@ int ipmi_request_supply_msgs(ipmi_user_t user,
1604 -1, 0); 1769 -1, 0);
1605} 1770}
1606 1771
1772#ifdef CONFIG_PROC_FS
1607static int ipmb_file_read_proc(char *page, char **start, off_t off, 1773static int ipmb_file_read_proc(char *page, char **start, off_t off,
1608 int count, int *eof, void *data) 1774 int count, int *eof, void *data)
1609{ 1775{
@@ -1692,6 +1858,7 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
1692 1858
1693 return (out - ((char *) page)); 1859 return (out - ((char *) page));
1694} 1860}
1861#endif /* CONFIG_PROC_FS */
1695 1862
1696int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name, 1863int ipmi_smi_add_proc_entry(ipmi_smi_t smi, char *name,
1697 read_proc_t *read_proc, write_proc_t *write_proc, 1864 read_proc_t *read_proc, write_proc_t *write_proc,
@@ -1817,13 +1984,12 @@ static int __find_bmc_prod_dev_id(struct device *dev, void *data)
1817 struct bmc_device *bmc = dev_get_drvdata(dev); 1984 struct bmc_device *bmc = dev_get_drvdata(dev);
1818 1985
1819 return (bmc->id.product_id == id->product_id 1986 return (bmc->id.product_id == id->product_id
1820 && bmc->id.product_id == id->product_id
1821 && bmc->id.device_id == id->device_id); 1987 && bmc->id.device_id == id->device_id);
1822} 1988}
1823 1989
1824static struct bmc_device *ipmi_find_bmc_prod_dev_id( 1990static struct bmc_device *ipmi_find_bmc_prod_dev_id(
1825 struct device_driver *drv, 1991 struct device_driver *drv,
1826 unsigned char product_id, unsigned char device_id) 1992 unsigned int product_id, unsigned char device_id)
1827{ 1993{
1828 struct prod_dev_id id = { 1994 struct prod_dev_id id = {
1829 .product_id = product_id, 1995 .product_id = product_id,
@@ -1940,6 +2106,9 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
1940 2106
1941static void remove_files(struct bmc_device *bmc) 2107static void remove_files(struct bmc_device *bmc)
1942{ 2108{
2109 if (!bmc->dev)
2110 return;
2111
1943 device_remove_file(&bmc->dev->dev, 2112 device_remove_file(&bmc->dev->dev,
1944 &bmc->device_id_attr); 2113 &bmc->device_id_attr);
1945 device_remove_file(&bmc->dev->dev, 2114 device_remove_file(&bmc->dev->dev,
@@ -1973,7 +2142,8 @@ cleanup_bmc_device(struct kref *ref)
1973 bmc = container_of(ref, struct bmc_device, refcount); 2142 bmc = container_of(ref, struct bmc_device, refcount);
1974 2143
1975 remove_files(bmc); 2144 remove_files(bmc);
1976 platform_device_unregister(bmc->dev); 2145 if (bmc->dev)
2146 platform_device_unregister(bmc->dev);
1977 kfree(bmc); 2147 kfree(bmc);
1978} 2148}
1979 2149
@@ -1981,7 +2151,11 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
1981{ 2151{
1982 struct bmc_device *bmc = intf->bmc; 2152 struct bmc_device *bmc = intf->bmc;
1983 2153
1984 sysfs_remove_link(&intf->si_dev->kobj, "bmc"); 2154 if (intf->sysfs_name) {
2155 sysfs_remove_link(&intf->si_dev->kobj, intf->sysfs_name);
2156 kfree(intf->sysfs_name);
2157 intf->sysfs_name = NULL;
2158 }
1985 if (intf->my_dev_name) { 2159 if (intf->my_dev_name) {
1986 sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name); 2160 sysfs_remove_link(&bmc->dev->dev.kobj, intf->my_dev_name);
1987 kfree(intf->my_dev_name); 2161 kfree(intf->my_dev_name);
@@ -1990,6 +2164,7 @@ static void ipmi_bmc_unregister(ipmi_smi_t intf)
1990 2164
1991 mutex_lock(&ipmidriver_mutex); 2165 mutex_lock(&ipmidriver_mutex);
1992 kref_put(&bmc->refcount, cleanup_bmc_device); 2166 kref_put(&bmc->refcount, cleanup_bmc_device);
2167 intf->bmc = NULL;
1993 mutex_unlock(&ipmidriver_mutex); 2168 mutex_unlock(&ipmidriver_mutex);
1994} 2169}
1995 2170
@@ -1997,6 +2172,56 @@ static int create_files(struct bmc_device *bmc)
1997{ 2172{
1998 int err; 2173 int err;
1999 2174
2175 bmc->device_id_attr.attr.name = "device_id";
2176 bmc->device_id_attr.attr.owner = THIS_MODULE;
2177 bmc->device_id_attr.attr.mode = S_IRUGO;
2178 bmc->device_id_attr.show = device_id_show;
2179
2180 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
2181 bmc->provides_dev_sdrs_attr.attr.owner = THIS_MODULE;
2182 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2183 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2184
2185 bmc->revision_attr.attr.name = "revision";
2186 bmc->revision_attr.attr.owner = THIS_MODULE;
2187 bmc->revision_attr.attr.mode = S_IRUGO;
2188 bmc->revision_attr.show = revision_show;
2189
2190 bmc->firmware_rev_attr.attr.name = "firmware_revision";
2191 bmc->firmware_rev_attr.attr.owner = THIS_MODULE;
2192 bmc->firmware_rev_attr.attr.mode = S_IRUGO;
2193 bmc->firmware_rev_attr.show = firmware_rev_show;
2194
2195 bmc->version_attr.attr.name = "ipmi_version";
2196 bmc->version_attr.attr.owner = THIS_MODULE;
2197 bmc->version_attr.attr.mode = S_IRUGO;
2198 bmc->version_attr.show = ipmi_version_show;
2199
2200 bmc->add_dev_support_attr.attr.name = "additional_device_support";
2201 bmc->add_dev_support_attr.attr.owner = THIS_MODULE;
2202 bmc->add_dev_support_attr.attr.mode = S_IRUGO;
2203 bmc->add_dev_support_attr.show = add_dev_support_show;
2204
2205 bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
2206 bmc->manufacturer_id_attr.attr.owner = THIS_MODULE;
2207 bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
2208 bmc->manufacturer_id_attr.show = manufacturer_id_show;
2209
2210 bmc->product_id_attr.attr.name = "product_id";
2211 bmc->product_id_attr.attr.owner = THIS_MODULE;
2212 bmc->product_id_attr.attr.mode = S_IRUGO;
2213 bmc->product_id_attr.show = product_id_show;
2214
2215 bmc->guid_attr.attr.name = "guid";
2216 bmc->guid_attr.attr.owner = THIS_MODULE;
2217 bmc->guid_attr.attr.mode = S_IRUGO;
2218 bmc->guid_attr.show = guid_show;
2219
2220 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2221 bmc->aux_firmware_rev_attr.attr.owner = THIS_MODULE;
2222 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2223 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2224
2000 err = device_create_file(&bmc->dev->dev, 2225 err = device_create_file(&bmc->dev->dev,
2001 &bmc->device_id_attr); 2226 &bmc->device_id_attr);
2002 if (err) goto out; 2227 if (err) goto out;
@@ -2066,7 +2291,8 @@ out:
2066 return err; 2291 return err;
2067} 2292}
2068 2293
2069static int ipmi_bmc_register(ipmi_smi_t intf) 2294static int ipmi_bmc_register(ipmi_smi_t intf, int ifnum,
2295 const char *sysfs_name)
2070{ 2296{
2071 int rv; 2297 int rv;
2072 struct bmc_device *bmc = intf->bmc; 2298 struct bmc_device *bmc = intf->bmc;
@@ -2106,9 +2332,39 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2106 bmc->id.product_id, 2332 bmc->id.product_id,
2107 bmc->id.device_id); 2333 bmc->id.device_id);
2108 } else { 2334 } else {
2109 bmc->dev = platform_device_alloc("ipmi_bmc", 2335 char name[14];
2110 bmc->id.device_id); 2336 unsigned char orig_dev_id = bmc->id.device_id;
2337 int warn_printed = 0;
2338
2339 snprintf(name, sizeof(name),
2340 "ipmi_bmc.%4.4x", bmc->id.product_id);
2341
2342 while (ipmi_find_bmc_prod_dev_id(&ipmidriver,
2343 bmc->id.product_id,
2344 bmc->id.device_id))
2345 {
2346 if (!warn_printed) {
2347 printk(KERN_WARNING PFX
2348 "This machine has two different BMCs"
2349 " with the same product id and device"
2350 " id. This is an error in the"
2351 " firmware, but incrementing the"
2352 " device id to work around the problem."
2353 " Prod ID = 0x%x, Dev ID = 0x%x\n",
2354 bmc->id.product_id, bmc->id.device_id);
2355 warn_printed = 1;
2356 }
2357 bmc->id.device_id++; /* Wraps at 255 */
2358 if (bmc->id.device_id == orig_dev_id) {
2359 printk(KERN_ERR PFX
2360 "Out of device ids!\n");
2361 break;
2362 }
2363 }
2364
2365 bmc->dev = platform_device_alloc(name, bmc->id.device_id);
2111 if (!bmc->dev) { 2366 if (!bmc->dev) {
2367 mutex_unlock(&ipmidriver_mutex);
2112 printk(KERN_ERR 2368 printk(KERN_ERR
2113 "ipmi_msghandler:" 2369 "ipmi_msghandler:"
2114 " Unable to allocate platform device\n"); 2370 " Unable to allocate platform device\n");
@@ -2121,6 +2377,8 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2121 rv = platform_device_add(bmc->dev); 2377 rv = platform_device_add(bmc->dev);
2122 mutex_unlock(&ipmidriver_mutex); 2378 mutex_unlock(&ipmidriver_mutex);
2123 if (rv) { 2379 if (rv) {
2380 platform_device_put(bmc->dev);
2381 bmc->dev = NULL;
2124 printk(KERN_ERR 2382 printk(KERN_ERR
2125 "ipmi_msghandler:" 2383 "ipmi_msghandler:"
2126 " Unable to register bmc device: %d\n", 2384 " Unable to register bmc device: %d\n",
@@ -2130,57 +2388,6 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2130 return rv; 2388 return rv;
2131 } 2389 }
2132 2390
2133 bmc->device_id_attr.attr.name = "device_id";
2134 bmc->device_id_attr.attr.owner = THIS_MODULE;
2135 bmc->device_id_attr.attr.mode = S_IRUGO;
2136 bmc->device_id_attr.show = device_id_show;
2137
2138 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs";
2139 bmc->provides_dev_sdrs_attr.attr.owner = THIS_MODULE;
2140 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO;
2141 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show;
2142
2143 bmc->revision_attr.attr.name = "revision";
2144 bmc->revision_attr.attr.owner = THIS_MODULE;
2145 bmc->revision_attr.attr.mode = S_IRUGO;
2146 bmc->revision_attr.show = revision_show;
2147
2148 bmc->firmware_rev_attr.attr.name = "firmware_revision";
2149 bmc->firmware_rev_attr.attr.owner = THIS_MODULE;
2150 bmc->firmware_rev_attr.attr.mode = S_IRUGO;
2151 bmc->firmware_rev_attr.show = firmware_rev_show;
2152
2153 bmc->version_attr.attr.name = "ipmi_version";
2154 bmc->version_attr.attr.owner = THIS_MODULE;
2155 bmc->version_attr.attr.mode = S_IRUGO;
2156 bmc->version_attr.show = ipmi_version_show;
2157
2158 bmc->add_dev_support_attr.attr.name
2159 = "additional_device_support";
2160 bmc->add_dev_support_attr.attr.owner = THIS_MODULE;
2161 bmc->add_dev_support_attr.attr.mode = S_IRUGO;
2162 bmc->add_dev_support_attr.show = add_dev_support_show;
2163
2164 bmc->manufacturer_id_attr.attr.name = "manufacturer_id";
2165 bmc->manufacturer_id_attr.attr.owner = THIS_MODULE;
2166 bmc->manufacturer_id_attr.attr.mode = S_IRUGO;
2167 bmc->manufacturer_id_attr.show = manufacturer_id_show;
2168
2169 bmc->product_id_attr.attr.name = "product_id";
2170 bmc->product_id_attr.attr.owner = THIS_MODULE;
2171 bmc->product_id_attr.attr.mode = S_IRUGO;
2172 bmc->product_id_attr.show = product_id_show;
2173
2174 bmc->guid_attr.attr.name = "guid";
2175 bmc->guid_attr.attr.owner = THIS_MODULE;
2176 bmc->guid_attr.attr.mode = S_IRUGO;
2177 bmc->guid_attr.show = guid_show;
2178
2179 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision";
2180 bmc->aux_firmware_rev_attr.attr.owner = THIS_MODULE;
2181 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO;
2182 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show;
2183
2184 rv = create_files(bmc); 2391 rv = create_files(bmc);
2185 if (rv) { 2392 if (rv) {
2186 mutex_lock(&ipmidriver_mutex); 2393 mutex_lock(&ipmidriver_mutex);
@@ -2202,29 +2409,44 @@ static int ipmi_bmc_register(ipmi_smi_t intf)
2202 * create symlink from system interface device to bmc device 2409 * create symlink from system interface device to bmc device
2203 * and back. 2410 * and back.
2204 */ 2411 */
2412 intf->sysfs_name = kstrdup(sysfs_name, GFP_KERNEL);
2413 if (!intf->sysfs_name) {
2414 rv = -ENOMEM;
2415 printk(KERN_ERR
2416 "ipmi_msghandler: allocate link to BMC: %d\n",
2417 rv);
2418 goto out_err;
2419 }
2420
2205 rv = sysfs_create_link(&intf->si_dev->kobj, 2421 rv = sysfs_create_link(&intf->si_dev->kobj,
2206 &bmc->dev->dev.kobj, "bmc"); 2422 &bmc->dev->dev.kobj, intf->sysfs_name);
2207 if (rv) { 2423 if (rv) {
2424 kfree(intf->sysfs_name);
2425 intf->sysfs_name = NULL;
2208 printk(KERN_ERR 2426 printk(KERN_ERR
2209 "ipmi_msghandler: Unable to create bmc symlink: %d\n", 2427 "ipmi_msghandler: Unable to create bmc symlink: %d\n",
2210 rv); 2428 rv);
2211 goto out_err; 2429 goto out_err;
2212 } 2430 }
2213 2431
2214 size = snprintf(dummy, 0, "ipmi%d", intf->intf_num); 2432 size = snprintf(dummy, 0, "ipmi%d", ifnum);
2215 intf->my_dev_name = kmalloc(size+1, GFP_KERNEL); 2433 intf->my_dev_name = kmalloc(size+1, GFP_KERNEL);
2216 if (!intf->my_dev_name) { 2434 if (!intf->my_dev_name) {
2435 kfree(intf->sysfs_name);
2436 intf->sysfs_name = NULL;
2217 rv = -ENOMEM; 2437 rv = -ENOMEM;
2218 printk(KERN_ERR 2438 printk(KERN_ERR
2219 "ipmi_msghandler: allocate link from BMC: %d\n", 2439 "ipmi_msghandler: allocate link from BMC: %d\n",
2220 rv); 2440 rv);
2221 goto out_err; 2441 goto out_err;
2222 } 2442 }
2223 snprintf(intf->my_dev_name, size+1, "ipmi%d", intf->intf_num); 2443 snprintf(intf->my_dev_name, size+1, "ipmi%d", ifnum);
2224 2444
2225 rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj, 2445 rv = sysfs_create_link(&bmc->dev->dev.kobj, &intf->si_dev->kobj,
2226 intf->my_dev_name); 2446 intf->my_dev_name);
2227 if (rv) { 2447 if (rv) {
2448 kfree(intf->sysfs_name);
2449 intf->sysfs_name = NULL;
2228 kfree(intf->my_dev_name); 2450 kfree(intf->my_dev_name);
2229 intf->my_dev_name = NULL; 2451 intf->my_dev_name = NULL;
2230 printk(KERN_ERR 2452 printk(KERN_ERR
@@ -2409,17 +2631,14 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2409 void *send_info, 2631 void *send_info,
2410 struct ipmi_device_id *device_id, 2632 struct ipmi_device_id *device_id,
2411 struct device *si_dev, 2633 struct device *si_dev,
2634 const char *sysfs_name,
2412 unsigned char slave_addr) 2635 unsigned char slave_addr)
2413{ 2636{
2414 int i, j; 2637 int i, j;
2415 int rv; 2638 int rv;
2416 ipmi_smi_t intf; 2639 ipmi_smi_t intf;
2417 unsigned long flags; 2640 ipmi_smi_t tintf;
2418 int version_major; 2641 struct list_head *link;
2419 int version_minor;
2420
2421 version_major = ipmi_version_major(device_id);
2422 version_minor = ipmi_version_minor(device_id);
2423 2642
2424 /* Make sure the driver is actually initialized, this handles 2643 /* Make sure the driver is actually initialized, this handles
2425 problems with initialization order. */ 2644 problems with initialization order. */
@@ -2437,12 +2656,16 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2437 if (!intf) 2656 if (!intf)
2438 return -ENOMEM; 2657 return -ENOMEM;
2439 memset(intf, 0, sizeof(*intf)); 2658 memset(intf, 0, sizeof(*intf));
2659
2660 intf->ipmi_version_major = ipmi_version_major(device_id);
2661 intf->ipmi_version_minor = ipmi_version_minor(device_id);
2662
2440 intf->bmc = kzalloc(sizeof(*intf->bmc), GFP_KERNEL); 2663 intf->bmc = kzalloc(sizeof(*intf->bmc), GFP_KERNEL);
2441 if (!intf->bmc) { 2664 if (!intf->bmc) {
2442 kfree(intf); 2665 kfree(intf);
2443 return -ENOMEM; 2666 return -ENOMEM;
2444 } 2667 }
2445 intf->intf_num = -1; 2668 intf->intf_num = -1; /* Mark it invalid for now. */
2446 kref_init(&intf->refcount); 2669 kref_init(&intf->refcount);
2447 intf->bmc->id = *device_id; 2670 intf->bmc->id = *device_id;
2448 intf->si_dev = si_dev; 2671 intf->si_dev = si_dev;
@@ -2470,26 +2693,30 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2470 INIT_LIST_HEAD(&intf->waiting_events); 2693 INIT_LIST_HEAD(&intf->waiting_events);
2471 intf->waiting_events_count = 0; 2694 intf->waiting_events_count = 0;
2472 mutex_init(&intf->cmd_rcvrs_mutex); 2695 mutex_init(&intf->cmd_rcvrs_mutex);
2696 spin_lock_init(&intf->maintenance_mode_lock);
2473 INIT_LIST_HEAD(&intf->cmd_rcvrs); 2697 INIT_LIST_HEAD(&intf->cmd_rcvrs);
2474 init_waitqueue_head(&intf->waitq); 2698 init_waitqueue_head(&intf->waitq);
2475 2699
2476 spin_lock_init(&intf->counter_lock); 2700 spin_lock_init(&intf->counter_lock);
2477 intf->proc_dir = NULL; 2701 intf->proc_dir = NULL;
2478 2702
2479 rv = -ENOMEM; 2703 mutex_lock(&smi_watchers_mutex);
2480 spin_lock_irqsave(&interfaces_lock, flags); 2704 mutex_lock(&ipmi_interfaces_mutex);
2481 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 2705 /* Look for a hole in the numbers. */
2482 if (ipmi_interfaces[i] == NULL) { 2706 i = 0;
2483 intf->intf_num = i; 2707 link = &ipmi_interfaces;
2484 /* Reserve the entry till we are done. */ 2708 list_for_each_entry_rcu(tintf, &ipmi_interfaces, link) {
2485 ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY; 2709 if (tintf->intf_num != i) {
2486 rv = 0; 2710 link = &tintf->link;
2487 break; 2711 break;
2488 } 2712 }
2713 i++;
2489 } 2714 }
2490 spin_unlock_irqrestore(&interfaces_lock, flags); 2715 /* Add the new interface in numeric order. */
2491 if (rv) 2716 if (i == 0)
2492 goto out; 2717 list_add_rcu(&intf->link, &ipmi_interfaces);
2718 else
2719 list_add_tail_rcu(&intf->link, link);
2493 2720
2494 rv = handlers->start_processing(send_info, intf); 2721 rv = handlers->start_processing(send_info, intf);
2495 if (rv) 2722 if (rv)
@@ -2497,8 +2724,9 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2497 2724
2498 get_guid(intf); 2725 get_guid(intf);
2499 2726
2500 if ((version_major > 1) 2727 if ((intf->ipmi_version_major > 1)
2501 || ((version_major == 1) && (version_minor >= 5))) 2728 || ((intf->ipmi_version_major == 1)
2729 && (intf->ipmi_version_minor >= 5)))
2502 { 2730 {
2503 /* Start scanning the channels to see what is 2731 /* Start scanning the channels to see what is
2504 available. */ 2732 available. */
@@ -2521,64 +2749,67 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
2521 if (rv == 0) 2749 if (rv == 0)
2522 rv = add_proc_entries(intf, i); 2750 rv = add_proc_entries(intf, i);
2523 2751
2524 rv = ipmi_bmc_register(intf); 2752 rv = ipmi_bmc_register(intf, i, sysfs_name);
2525 2753
2526 out: 2754 out:
2527 if (rv) { 2755 if (rv) {
2528 if (intf->proc_dir) 2756 if (intf->proc_dir)
2529 remove_proc_entries(intf); 2757 remove_proc_entries(intf);
2758 intf->handlers = NULL;
2759 list_del_rcu(&intf->link);
2760 mutex_unlock(&ipmi_interfaces_mutex);
2761 mutex_unlock(&smi_watchers_mutex);
2762 synchronize_rcu();
2530 kref_put(&intf->refcount, intf_free); 2763 kref_put(&intf->refcount, intf_free);
2531 if (i < MAX_IPMI_INTERFACES) {
2532 spin_lock_irqsave(&interfaces_lock, flags);
2533 ipmi_interfaces[i] = NULL;
2534 spin_unlock_irqrestore(&interfaces_lock, flags);
2535 }
2536 } else { 2764 } else {
2537 spin_lock_irqsave(&interfaces_lock, flags); 2765 /* After this point the interface is legal to use. */
2538 ipmi_interfaces[i] = intf; 2766 intf->intf_num = i;
2539 spin_unlock_irqrestore(&interfaces_lock, flags); 2767 mutex_unlock(&ipmi_interfaces_mutex);
2540 call_smi_watchers(i, intf->si_dev); 2768 call_smi_watchers(i, intf->si_dev);
2769 mutex_unlock(&smi_watchers_mutex);
2541 } 2770 }
2542 2771
2543 return rv; 2772 return rv;
2544} 2773}
2545 2774
2775static void cleanup_smi_msgs(ipmi_smi_t intf)
2776{
2777 int i;
2778 struct seq_table *ent;
2779
2780 /* No need for locks, the interface is down. */
2781 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++) {
2782 ent = &(intf->seq_table[i]);
2783 if (!ent->inuse)
2784 continue;
2785 deliver_err_response(ent->recv_msg, IPMI_ERR_UNSPECIFIED);
2786 }
2787}
2788
2546int ipmi_unregister_smi(ipmi_smi_t intf) 2789int ipmi_unregister_smi(ipmi_smi_t intf)
2547{ 2790{
2548 int i;
2549 struct ipmi_smi_watcher *w; 2791 struct ipmi_smi_watcher *w;
2550 unsigned long flags; 2792 int intf_num = intf->intf_num;
2551 2793
2552 ipmi_bmc_unregister(intf); 2794 ipmi_bmc_unregister(intf);
2553 2795
2554 spin_lock_irqsave(&interfaces_lock, flags); 2796 mutex_lock(&smi_watchers_mutex);
2555 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 2797 mutex_lock(&ipmi_interfaces_mutex);
2556 if (ipmi_interfaces[i] == intf) { 2798 intf->intf_num = -1;
2557 /* Set the interface number reserved until we 2799 intf->handlers = NULL;
2558 * are done. */ 2800 list_del_rcu(&intf->link);
2559 ipmi_interfaces[i] = IPMI_INVALID_INTERFACE_ENTRY; 2801 mutex_unlock(&ipmi_interfaces_mutex);
2560 intf->intf_num = -1; 2802 synchronize_rcu();
2561 break;
2562 }
2563 }
2564 spin_unlock_irqrestore(&interfaces_lock,flags);
2565 2803
2566 if (i == MAX_IPMI_INTERFACES) 2804 cleanup_smi_msgs(intf);
2567 return -ENODEV;
2568 2805
2569 remove_proc_entries(intf); 2806 remove_proc_entries(intf);
2570 2807
2571 /* Call all the watcher interfaces to tell them that 2808 /* Call all the watcher interfaces to tell them that
2572 an interface is gone. */ 2809 an interface is gone. */
2573 down_read(&smi_watchers_sem);
2574 list_for_each_entry(w, &smi_watchers, link) 2810 list_for_each_entry(w, &smi_watchers, link)
2575 w->smi_gone(i); 2811 w->smi_gone(intf_num);
2576 up_read(&smi_watchers_sem); 2812 mutex_unlock(&smi_watchers_mutex);
2577
2578 /* Allow the entry to be reused now. */
2579 spin_lock_irqsave(&interfaces_lock, flags);
2580 ipmi_interfaces[i] = NULL;
2581 spin_unlock_irqrestore(&interfaces_lock,flags);
2582 2813
2583 kref_put(&intf->refcount, intf_free); 2814 kref_put(&intf->refcount, intf_free);
2584 return 0; 2815 return 0;
@@ -2660,6 +2891,7 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2660 struct ipmi_ipmb_addr *ipmb_addr; 2891 struct ipmi_ipmb_addr *ipmb_addr;
2661 struct ipmi_recv_msg *recv_msg; 2892 struct ipmi_recv_msg *recv_msg;
2662 unsigned long flags; 2893 unsigned long flags;
2894 struct ipmi_smi_handlers *handlers;
2663 2895
2664 if (msg->rsp_size < 10) { 2896 if (msg->rsp_size < 10) {
2665 /* Message not big enough, just ignore it. */ 2897 /* Message not big enough, just ignore it. */
@@ -2716,10 +2948,16 @@ static int handle_ipmb_get_msg_cmd(ipmi_smi_t intf,
2716 printk("\n"); 2948 printk("\n");
2717 } 2949 }
2718#endif 2950#endif
2719 intf->handlers->sender(intf->send_info, msg, 0); 2951 rcu_read_lock();
2720 2952 handlers = intf->handlers;
2721 rv = -1; /* We used the message, so return the value that 2953 if (handlers) {
2722 causes it to not be freed or queued. */ 2954 handlers->sender(intf->send_info, msg, 0);
2955 /* We used the message, so return the value
2956 that causes it to not be freed or
2957 queued. */
2958 rv = -1;
2959 }
2960 rcu_read_unlock();
2723 } else { 2961 } else {
2724 /* Deliver the message to the user. */ 2962 /* Deliver the message to the user. */
2725 spin_lock_irqsave(&intf->counter_lock, flags); 2963 spin_lock_irqsave(&intf->counter_lock, flags);
@@ -3309,16 +3547,6 @@ void ipmi_smi_watchdog_pretimeout(ipmi_smi_t intf)
3309 rcu_read_unlock(); 3547 rcu_read_unlock();
3310} 3548}
3311 3549
3312static void
3313handle_msg_timeout(struct ipmi_recv_msg *msg)
3314{
3315 msg->recv_type = IPMI_RESPONSE_RECV_TYPE;
3316 msg->msg_data[0] = IPMI_TIMEOUT_COMPLETION_CODE;
3317 msg->msg.netfn |= 1; /* Convert to a response. */
3318 msg->msg.data_len = 1;
3319 msg->msg.data = msg->msg_data;
3320 deliver_response(msg);
3321}
3322 3550
3323static struct ipmi_smi_msg * 3551static struct ipmi_smi_msg *
3324smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg, 3552smi_from_recv_msg(ipmi_smi_t intf, struct ipmi_recv_msg *recv_msg,
@@ -3350,7 +3578,11 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3350 struct list_head *timeouts, long timeout_period, 3578 struct list_head *timeouts, long timeout_period,
3351 int slot, unsigned long *flags) 3579 int slot, unsigned long *flags)
3352{ 3580{
3353 struct ipmi_recv_msg *msg; 3581 struct ipmi_recv_msg *msg;
3582 struct ipmi_smi_handlers *handlers;
3583
3584 if (intf->intf_num == -1)
3585 return;
3354 3586
3355 if (!ent->inuse) 3587 if (!ent->inuse)
3356 return; 3588 return;
@@ -3393,13 +3625,19 @@ static void check_msg_timeout(ipmi_smi_t intf, struct seq_table *ent,
3393 return; 3625 return;
3394 3626
3395 spin_unlock_irqrestore(&intf->seq_lock, *flags); 3627 spin_unlock_irqrestore(&intf->seq_lock, *flags);
3628
3396 /* Send the new message. We send with a zero 3629 /* Send the new message. We send with a zero
3397 * priority. It timed out, I doubt time is 3630 * priority. It timed out, I doubt time is
3398 * that critical now, and high priority 3631 * that critical now, and high priority
3399 * messages are really only for messages to the 3632 * messages are really only for messages to the
3400 * local MC, which don't get resent. */ 3633 * local MC, which don't get resent. */
3401 intf->handlers->sender(intf->send_info, 3634 handlers = intf->handlers;
3402 smi_msg, 0); 3635 if (handlers)
3636 intf->handlers->sender(intf->send_info,
3637 smi_msg, 0);
3638 else
3639 ipmi_free_smi_msg(smi_msg);
3640
3403 spin_lock_irqsave(&intf->seq_lock, *flags); 3641 spin_lock_irqsave(&intf->seq_lock, *flags);
3404 } 3642 }
3405} 3643}
@@ -3411,18 +3649,12 @@ static void ipmi_timeout_handler(long timeout_period)
3411 struct ipmi_recv_msg *msg, *msg2; 3649 struct ipmi_recv_msg *msg, *msg2;
3412 struct ipmi_smi_msg *smi_msg, *smi_msg2; 3650 struct ipmi_smi_msg *smi_msg, *smi_msg2;
3413 unsigned long flags; 3651 unsigned long flags;
3414 int i, j; 3652 int i;
3415 3653
3416 INIT_LIST_HEAD(&timeouts); 3654 INIT_LIST_HEAD(&timeouts);
3417 3655
3418 spin_lock(&interfaces_lock); 3656 rcu_read_lock();
3419 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3657 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3420 intf = ipmi_interfaces[i];
3421 if (IPMI_INVALID_INTERFACE(intf))
3422 continue;
3423 kref_get(&intf->refcount);
3424 spin_unlock(&interfaces_lock);
3425
3426 /* See if any waiting messages need to be processed. */ 3658 /* See if any waiting messages need to be processed. */
3427 spin_lock_irqsave(&intf->waiting_msgs_lock, flags); 3659 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
3428 list_for_each_entry_safe(smi_msg, smi_msg2, 3660 list_for_each_entry_safe(smi_msg, smi_msg2,
@@ -3442,35 +3674,60 @@ static void ipmi_timeout_handler(long timeout_period)
3442 have timed out, putting them in the timeouts 3674 have timed out, putting them in the timeouts
3443 list. */ 3675 list. */
3444 spin_lock_irqsave(&intf->seq_lock, flags); 3676 spin_lock_irqsave(&intf->seq_lock, flags);
3445 for (j = 0; j < IPMI_IPMB_NUM_SEQ; j++) 3677 for (i = 0; i < IPMI_IPMB_NUM_SEQ; i++)
3446 check_msg_timeout(intf, &(intf->seq_table[j]), 3678 check_msg_timeout(intf, &(intf->seq_table[i]),
3447 &timeouts, timeout_period, j, 3679 &timeouts, timeout_period, i,
3448 &flags); 3680 &flags);
3449 spin_unlock_irqrestore(&intf->seq_lock, flags); 3681 spin_unlock_irqrestore(&intf->seq_lock, flags);
3450 3682
3451 list_for_each_entry_safe(msg, msg2, &timeouts, link) 3683 list_for_each_entry_safe(msg, msg2, &timeouts, link)
3452 handle_msg_timeout(msg); 3684 deliver_err_response(msg, IPMI_TIMEOUT_COMPLETION_CODE);
3453 3685
3454 kref_put(&intf->refcount, intf_free); 3686 /*
3455 spin_lock(&interfaces_lock); 3687 * Maintenance mode handling. Check the timeout
3688 * optimistically before we claim the lock. It may
3689 * mean a timeout gets missed occasionally, but that
3690 * only means the timeout gets extended by one period
3691 * in that case. No big deal, and it avoids the lock
3692 * most of the time.
3693 */
3694 if (intf->auto_maintenance_timeout > 0) {
3695 spin_lock_irqsave(&intf->maintenance_mode_lock, flags);
3696 if (intf->auto_maintenance_timeout > 0) {
3697 intf->auto_maintenance_timeout
3698 -= timeout_period;
3699 if (!intf->maintenance_mode
3700 && (intf->auto_maintenance_timeout <= 0))
3701 {
3702 intf->maintenance_mode_enable = 0;
3703 maintenance_mode_update(intf);
3704 }
3705 }
3706 spin_unlock_irqrestore(&intf->maintenance_mode_lock,
3707 flags);
3708 }
3456 } 3709 }
3457 spin_unlock(&interfaces_lock); 3710 rcu_read_unlock();
3458} 3711}
3459 3712
3460static void ipmi_request_event(void) 3713static void ipmi_request_event(void)
3461{ 3714{
3462 ipmi_smi_t intf; 3715 ipmi_smi_t intf;
3463 int i; 3716 struct ipmi_smi_handlers *handlers;
3464 3717
3465 spin_lock(&interfaces_lock); 3718 rcu_read_lock();
3466 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3719 /* Called from the timer, no need to check if handlers is
3467 intf = ipmi_interfaces[i]; 3720 * valid. */
3468 if (IPMI_INVALID_INTERFACE(intf)) 3721 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3722 /* No event requests when in maintenance mode. */
3723 if (intf->maintenance_mode_enable)
3469 continue; 3724 continue;
3470 3725
3471 intf->handlers->request_events(intf->send_info); 3726 handlers = intf->handlers;
3727 if (handlers)
3728 handlers->request_events(intf->send_info);
3472 } 3729 }
3473 spin_unlock(&interfaces_lock); 3730 rcu_read_unlock();
3474} 3731}
3475 3732
3476static struct timer_list ipmi_timer; 3733static struct timer_list ipmi_timer;
@@ -3599,7 +3856,6 @@ static void send_panic_events(char *str)
3599 struct kernel_ipmi_msg msg; 3856 struct kernel_ipmi_msg msg;
3600 ipmi_smi_t intf; 3857 ipmi_smi_t intf;
3601 unsigned char data[16]; 3858 unsigned char data[16];
3602 int i;
3603 struct ipmi_system_interface_addr *si; 3859 struct ipmi_system_interface_addr *si;
3604 struct ipmi_addr addr; 3860 struct ipmi_addr addr;
3605 struct ipmi_smi_msg smi_msg; 3861 struct ipmi_smi_msg smi_msg;
@@ -3633,9 +3889,9 @@ static void send_panic_events(char *str)
3633 recv_msg.done = dummy_recv_done_handler; 3889 recv_msg.done = dummy_recv_done_handler;
3634 3890
3635 /* For every registered interface, send the event. */ 3891 /* For every registered interface, send the event. */
3636 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3892 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3637 intf = ipmi_interfaces[i]; 3893 if (!intf->handlers)
3638 if (IPMI_INVALID_INTERFACE(intf)) 3894 /* Interface is not ready. */
3639 continue; 3895 continue;
3640 3896
3641 /* Send the event announcing the panic. */ 3897 /* Send the event announcing the panic. */
@@ -3660,13 +3916,14 @@ static void send_panic_events(char *str)
3660 if (!str) 3916 if (!str)
3661 return; 3917 return;
3662 3918
3663 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 3919 /* For every registered interface, send the event. */
3920 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3664 char *p = str; 3921 char *p = str;
3665 struct ipmi_ipmb_addr *ipmb; 3922 struct ipmi_ipmb_addr *ipmb;
3666 int j; 3923 int j;
3667 3924
3668 intf = ipmi_interfaces[i]; 3925 if (intf->intf_num == -1)
3669 if (IPMI_INVALID_INTERFACE(intf)) 3926 /* Interface was not ready yet. */
3670 continue; 3927 continue;
3671 3928
3672 /* First job here is to figure out where to send the 3929 /* First job here is to figure out where to send the
@@ -3792,7 +4049,6 @@ static int panic_event(struct notifier_block *this,
3792 unsigned long event, 4049 unsigned long event,
3793 void *ptr) 4050 void *ptr)
3794{ 4051{
3795 int i;
3796 ipmi_smi_t intf; 4052 ipmi_smi_t intf;
3797 4053
3798 if (has_panicked) 4054 if (has_panicked)
@@ -3800,9 +4056,9 @@ static int panic_event(struct notifier_block *this,
3800 has_panicked = 1; 4056 has_panicked = 1;
3801 4057
3802 /* For every registered interface, set it to run to completion. */ 4058 /* For every registered interface, set it to run to completion. */
3803 for (i = 0; i < MAX_IPMI_INTERFACES; i++) { 4059 list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
3804 intf = ipmi_interfaces[i]; 4060 if (!intf->handlers)
3805 if (IPMI_INVALID_INTERFACE(intf)) 4061 /* Interface is not ready. */
3806 continue; 4062 continue;
3807 4063
3808 intf->handlers->set_run_to_completion(intf->send_info, 1); 4064 intf->handlers->set_run_to_completion(intf->send_info, 1);
@@ -3823,7 +4079,6 @@ static struct notifier_block panic_block = {
3823 4079
3824static int ipmi_init_msghandler(void) 4080static int ipmi_init_msghandler(void)
3825{ 4081{
3826 int i;
3827 int rv; 4082 int rv;
3828 4083
3829 if (initialized) 4084 if (initialized)
@@ -3838,9 +4093,6 @@ static int ipmi_init_msghandler(void)
3838 printk(KERN_INFO "ipmi message handler version " 4093 printk(KERN_INFO "ipmi message handler version "
3839 IPMI_DRIVER_VERSION "\n"); 4094 IPMI_DRIVER_VERSION "\n");
3840 4095
3841 for (i = 0; i < MAX_IPMI_INTERFACES; i++)
3842 ipmi_interfaces[i] = NULL;
3843
3844#ifdef CONFIG_PROC_FS 4096#ifdef CONFIG_PROC_FS
3845 proc_ipmi_root = proc_mkdir("ipmi", NULL); 4097 proc_ipmi_root = proc_mkdir("ipmi", NULL);
3846 if (!proc_ipmi_root) { 4098 if (!proc_ipmi_root) {
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index 8d941db83457..597eb4f88b84 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -43,6 +43,9 @@
43 43
44#define PFX "IPMI poweroff: " 44#define PFX "IPMI poweroff: "
45 45
46static void ipmi_po_smi_gone(int if_num);
47static void ipmi_po_new_smi(int if_num, struct device *device);
48
46/* Definitions for controlling power off (if the system supports it). It 49/* Definitions for controlling power off (if the system supports it). It
47 * conveniently matches the IPMI chassis control values. */ 50 * conveniently matches the IPMI chassis control values. */
48#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */ 51#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */
@@ -51,6 +54,37 @@
51/* the IPMI data command */ 54/* the IPMI data command */
52static int poweroff_powercycle; 55static int poweroff_powercycle;
53 56
57/* Which interface to use, -1 means the first we see. */
58static int ifnum_to_use = -1;
59
60/* Our local state. */
61static int ready = 0;
62static ipmi_user_t ipmi_user;
63static int ipmi_ifnum;
64static void (*specific_poweroff_func)(ipmi_user_t user) = NULL;
65
66/* Holds the old poweroff function so we can restore it on removal. */
67static void (*old_poweroff_func)(void);
68
69static int set_param_ifnum(const char *val, struct kernel_param *kp)
70{
71 int rv = param_set_int(val, kp);
72 if (rv)
73 return rv;
74 if ((ifnum_to_use < 0) || (ifnum_to_use == ipmi_ifnum))
75 return 0;
76
77 ipmi_po_smi_gone(ipmi_ifnum);
78 ipmi_po_new_smi(ifnum_to_use, NULL);
79 return 0;
80}
81
82module_param_call(ifnum_to_use, set_param_ifnum, param_get_int,
83 &ifnum_to_use, 0644);
84MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
85 "timer. Setting to -1 defaults to the first registered "
86 "interface");
87
54/* parameter definition to allow user to flag power cycle */ 88/* parameter definition to allow user to flag power cycle */
55module_param(poweroff_powercycle, int, 0644); 89module_param(poweroff_powercycle, int, 0644);
56MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); 90MODULE_PARM_DESC(poweroff_powercycle, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down.");
@@ -142,6 +176,42 @@ static int ipmi_request_in_rc_mode(ipmi_user_t user,
142#define IPMI_ATCA_GET_ADDR_INFO_CMD 0x01 176#define IPMI_ATCA_GET_ADDR_INFO_CMD 0x01
143#define IPMI_PICMG_ID 0 177#define IPMI_PICMG_ID 0
144 178
179#define IPMI_NETFN_OEM 0x2e
180#define IPMI_ATCA_PPS_GRACEFUL_RESTART 0x11
181#define IPMI_ATCA_PPS_IANA "\x00\x40\x0A"
182#define IPMI_MOTOROLA_MANUFACTURER_ID 0x0000A1
183#define IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID 0x0051
184
185static void (*atca_oem_poweroff_hook)(ipmi_user_t user) = NULL;
186
187static void pps_poweroff_atca (ipmi_user_t user)
188{
189 struct ipmi_system_interface_addr smi_addr;
190 struct kernel_ipmi_msg send_msg;
191 int rv;
192 /*
193 * Configure IPMI address for local access
194 */
195 smi_addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
196 smi_addr.channel = IPMI_BMC_CHANNEL;
197 smi_addr.lun = 0;
198
199 printk(KERN_INFO PFX "PPS powerdown hook used");
200
201 send_msg.netfn = IPMI_NETFN_OEM;
202 send_msg.cmd = IPMI_ATCA_PPS_GRACEFUL_RESTART;
203 send_msg.data = IPMI_ATCA_PPS_IANA;
204 send_msg.data_len = 3;
205 rv = ipmi_request_in_rc_mode(user,
206 (struct ipmi_addr *) &smi_addr,
207 &send_msg);
208 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
209 printk(KERN_ERR PFX "Unable to send ATCA ,"
210 " IPMI error 0x%x\n", rv);
211 }
212 return;
213}
214
145static int ipmi_atca_detect (ipmi_user_t user) 215static int ipmi_atca_detect (ipmi_user_t user)
146{ 216{
147 struct ipmi_system_interface_addr smi_addr; 217 struct ipmi_system_interface_addr smi_addr;
@@ -167,6 +237,13 @@ static int ipmi_atca_detect (ipmi_user_t user)
167 rv = ipmi_request_wait_for_response(user, 237 rv = ipmi_request_wait_for_response(user,
168 (struct ipmi_addr *) &smi_addr, 238 (struct ipmi_addr *) &smi_addr,
169 &send_msg); 239 &send_msg);
240
241 printk(KERN_INFO PFX "ATCA Detect mfg 0x%X prod 0x%X\n", mfg_id, prod_id);
242 if((mfg_id == IPMI_MOTOROLA_MANUFACTURER_ID)
243 && (prod_id == IPMI_MOTOROLA_PPS_IPMC_PRODUCT_ID)) {
244 printk(KERN_INFO PFX "Installing Pigeon Point Systems Poweroff Hook\n");
245 atca_oem_poweroff_hook = pps_poweroff_atca;
246 }
170 return !rv; 247 return !rv;
171} 248}
172 249
@@ -200,12 +277,19 @@ static void ipmi_poweroff_atca (ipmi_user_t user)
200 rv = ipmi_request_in_rc_mode(user, 277 rv = ipmi_request_in_rc_mode(user,
201 (struct ipmi_addr *) &smi_addr, 278 (struct ipmi_addr *) &smi_addr,
202 &send_msg); 279 &send_msg);
203 if (rv) { 280 /** At this point, the system may be shutting down, and most
281 ** serial drivers (if used) will have interrupts turned off
282 ** it may be better to ignore IPMI_UNKNOWN_ERR_COMPLETION_CODE
283 ** return code
284 **/
285 if (rv && rv != IPMI_UNKNOWN_ERR_COMPLETION_CODE) {
204 printk(KERN_ERR PFX "Unable to send ATCA powerdown message," 286 printk(KERN_ERR PFX "Unable to send ATCA powerdown message,"
205 " IPMI error 0x%x\n", rv); 287 " IPMI error 0x%x\n", rv);
206 goto out; 288 goto out;
207 } 289 }
208 290
291 if(atca_oem_poweroff_hook)
292 return atca_oem_poweroff_hook(user);
209 out: 293 out:
210 return; 294 return;
211} 295}
@@ -440,15 +524,6 @@ static struct poweroff_function poweroff_functions[] = {
440 / sizeof(struct poweroff_function)) 524 / sizeof(struct poweroff_function))
441 525
442 526
443/* Our local state. */
444static int ready = 0;
445static ipmi_user_t ipmi_user;
446static void (*specific_poweroff_func)(ipmi_user_t user) = NULL;
447
448/* Holds the old poweroff function so we can restore it on removal. */
449static void (*old_poweroff_func)(void);
450
451
452/* Called on a powerdown request. */ 527/* Called on a powerdown request. */
453static void ipmi_poweroff_function (void) 528static void ipmi_poweroff_function (void)
454{ 529{
@@ -473,6 +548,9 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
473 if (ready) 548 if (ready)
474 return; 549 return;
475 550
551 if ((ifnum_to_use >= 0) && (ifnum_to_use != if_num))
552 return;
553
476 rv = ipmi_create_user(if_num, &ipmi_poweroff_handler, NULL, 554 rv = ipmi_create_user(if_num, &ipmi_poweroff_handler, NULL,
477 &ipmi_user); 555 &ipmi_user);
478 if (rv) { 556 if (rv) {
@@ -481,6 +559,8 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
481 return; 559 return;
482 } 560 }
483 561
562 ipmi_ifnum = if_num;
563
484 /* 564 /*
485 * Do a get device ide and store some results, since this is 565 * Do a get device ide and store some results, since this is
486 * used by several functions. 566 * used by several functions.
@@ -541,9 +621,15 @@ static void ipmi_po_new_smi(int if_num, struct device *device)
541 621
542static void ipmi_po_smi_gone(int if_num) 622static void ipmi_po_smi_gone(int if_num)
543{ 623{
544 /* This can never be called, because once poweroff driver is 624 if (!ready)
545 registered, the interface can't go away until the power 625 return;
546 driver is unregistered. */ 626
627 if (ipmi_ifnum != if_num)
628 return;
629
630 ready = 0;
631 ipmi_destroy_user(ipmi_user);
632 pm_power_off = old_poweroff_func;
547} 633}
548 634
549static struct ipmi_smi_watcher smi_watcher = 635static struct ipmi_smi_watcher smi_watcher =
@@ -616,9 +702,9 @@ static int ipmi_poweroff_init (void)
616 printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv); 702 printk(KERN_ERR PFX "Unable to register SMI watcher: %d\n", rv);
617 goto out_err; 703 goto out_err;
618 } 704 }
619#endif
620 705
621 out_err: 706 out_err:
707#endif
622 return rv; 708 return rv;
623} 709}
624 710
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index bb1fac104fda..81a0c89598e7 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -61,6 +61,10 @@
61#include "ipmi_si_sm.h" 61#include "ipmi_si_sm.h"
62#include <linux/init.h> 62#include <linux/init.h>
63#include <linux/dmi.h> 63#include <linux/dmi.h>
64#include <linux/string.h>
65#include <linux/ctype.h>
66
67#define PFX "ipmi_si: "
64 68
65/* Measure times between events in the driver. */ 69/* Measure times between events in the driver. */
66#undef DEBUG_TIMING 70#undef DEBUG_TIMING
@@ -92,7 +96,7 @@ enum si_intf_state {
92enum si_type { 96enum si_type {
93 SI_KCS, SI_SMIC, SI_BT 97 SI_KCS, SI_SMIC, SI_BT
94}; 98};
95static char *si_to_str[] = { "KCS", "SMIC", "BT" }; 99static char *si_to_str[] = { "kcs", "smic", "bt" };
96 100
97#define DEVICE_NAME "ipmi_si" 101#define DEVICE_NAME "ipmi_si"
98 102
@@ -222,7 +226,10 @@ struct smi_info
222static int force_kipmid[SI_MAX_PARMS]; 226static int force_kipmid[SI_MAX_PARMS];
223static int num_force_kipmid; 227static int num_force_kipmid;
224 228
229static int unload_when_empty = 1;
230
225static int try_smi_init(struct smi_info *smi); 231static int try_smi_init(struct smi_info *smi);
232static void cleanup_one_si(struct smi_info *to_clean);
226 233
227static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list); 234static ATOMIC_NOTIFIER_HEAD(xaction_notifier_list);
228static int register_xaction_notifier(struct notifier_block * nb) 235static int register_xaction_notifier(struct notifier_block * nb)
@@ -240,14 +247,18 @@ static void deliver_recv_msg(struct smi_info *smi_info,
240 spin_lock(&(smi_info->si_lock)); 247 spin_lock(&(smi_info->si_lock));
241} 248}
242 249
243static void return_hosed_msg(struct smi_info *smi_info) 250static void return_hosed_msg(struct smi_info *smi_info, int cCode)
244{ 251{
245 struct ipmi_smi_msg *msg = smi_info->curr_msg; 252 struct ipmi_smi_msg *msg = smi_info->curr_msg;
246 253
254 if (cCode < 0 || cCode > IPMI_ERR_UNSPECIFIED)
255 cCode = IPMI_ERR_UNSPECIFIED;
256 /* else use it as is */
257
247 /* Make it a reponse */ 258 /* Make it a reponse */
248 msg->rsp[0] = msg->data[0] | 4; 259 msg->rsp[0] = msg->data[0] | 4;
249 msg->rsp[1] = msg->data[1]; 260 msg->rsp[1] = msg->data[1];
250 msg->rsp[2] = 0xFF; /* Unknown error. */ 261 msg->rsp[2] = cCode;
251 msg->rsp_size = 3; 262 msg->rsp_size = 3;
252 263
253 smi_info->curr_msg = NULL; 264 smi_info->curr_msg = NULL;
@@ -298,7 +309,7 @@ static enum si_sm_result start_next_msg(struct smi_info *smi_info)
298 smi_info->curr_msg->data, 309 smi_info->curr_msg->data,
299 smi_info->curr_msg->data_size); 310 smi_info->curr_msg->data_size);
300 if (err) { 311 if (err) {
301 return_hosed_msg(smi_info); 312 return_hosed_msg(smi_info, err);
302 } 313 }
303 314
304 rv = SI_SM_CALL_WITHOUT_DELAY; 315 rv = SI_SM_CALL_WITHOUT_DELAY;
@@ -640,7 +651,7 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
640 /* If we were handling a user message, format 651 /* If we were handling a user message, format
641 a response to send to the upper layer to 652 a response to send to the upper layer to
642 tell it about the error. */ 653 tell it about the error. */
643 return_hosed_msg(smi_info); 654 return_hosed_msg(smi_info, IPMI_ERR_UNSPECIFIED);
644 } 655 }
645 si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0); 656 si_sm_result = smi_info->handlers->event(smi_info->si_sm, 0);
646 } 657 }
@@ -684,22 +695,24 @@ static enum si_sm_result smi_event_handler(struct smi_info *smi_info,
684 { 695 {
685 /* We are idle and the upper layer requested that I fetch 696 /* We are idle and the upper layer requested that I fetch
686 events, so do so. */ 697 events, so do so. */
687 unsigned char msg[2]; 698 atomic_set(&smi_info->req_events, 0);
688 699
689 spin_lock(&smi_info->count_lock); 700 smi_info->curr_msg = ipmi_alloc_smi_msg();
690 smi_info->flag_fetches++; 701 if (!smi_info->curr_msg)
691 spin_unlock(&smi_info->count_lock); 702 goto out;
692 703
693 atomic_set(&smi_info->req_events, 0); 704 smi_info->curr_msg->data[0] = (IPMI_NETFN_APP_REQUEST << 2);
694 msg[0] = (IPMI_NETFN_APP_REQUEST << 2); 705 smi_info->curr_msg->data[1] = IPMI_READ_EVENT_MSG_BUFFER_CMD;
695 msg[1] = IPMI_GET_MSG_FLAGS_CMD; 706 smi_info->curr_msg->data_size = 2;
696 707
697 smi_info->handlers->start_transaction( 708 smi_info->handlers->start_transaction(
698 smi_info->si_sm, msg, 2); 709 smi_info->si_sm,
699 smi_info->si_state = SI_GETTING_FLAGS; 710 smi_info->curr_msg->data,
711 smi_info->curr_msg->data_size);
712 smi_info->si_state = SI_GETTING_EVENTS;
700 goto restart; 713 goto restart;
701 } 714 }
702 715 out:
703 return si_sm_result; 716 return si_sm_result;
704} 717}
705 718
@@ -714,6 +727,15 @@ static void sender(void *send_info,
714 struct timeval t; 727 struct timeval t;
715#endif 728#endif
716 729
730 if (atomic_read(&smi_info->stop_operation)) {
731 msg->rsp[0] = msg->data[0] | 4;
732 msg->rsp[1] = msg->data[1];
733 msg->rsp[2] = IPMI_ERR_UNSPECIFIED;
734 msg->rsp_size = 3;
735 deliver_recv_msg(smi_info, msg);
736 return;
737 }
738
717 spin_lock_irqsave(&(smi_info->msg_lock), flags); 739 spin_lock_irqsave(&(smi_info->msg_lock), flags);
718#ifdef DEBUG_TIMING 740#ifdef DEBUG_TIMING
719 do_gettimeofday(&t); 741 do_gettimeofday(&t);
@@ -805,13 +827,21 @@ static void poll(void *send_info)
805{ 827{
806 struct smi_info *smi_info = send_info; 828 struct smi_info *smi_info = send_info;
807 829
808 smi_event_handler(smi_info, 0); 830 /*
831 * Make sure there is some delay in the poll loop so we can
832 * drive time forward and timeout things.
833 */
834 udelay(10);
835 smi_event_handler(smi_info, 10);
809} 836}
810 837
811static void request_events(void *send_info) 838static void request_events(void *send_info)
812{ 839{
813 struct smi_info *smi_info = send_info; 840 struct smi_info *smi_info = send_info;
814 841
842 if (atomic_read(&smi_info->stop_operation))
843 return;
844
815 atomic_set(&smi_info->req_events, 1); 845 atomic_set(&smi_info->req_events, 1);
816} 846}
817 847
@@ -949,12 +979,21 @@ static int smi_start_processing(void *send_info,
949 return 0; 979 return 0;
950} 980}
951 981
982static void set_maintenance_mode(void *send_info, int enable)
983{
984 struct smi_info *smi_info = send_info;
985
986 if (!enable)
987 atomic_set(&smi_info->req_events, 0);
988}
989
952static struct ipmi_smi_handlers handlers = 990static struct ipmi_smi_handlers handlers =
953{ 991{
954 .owner = THIS_MODULE, 992 .owner = THIS_MODULE,
955 .start_processing = smi_start_processing, 993 .start_processing = smi_start_processing,
956 .sender = sender, 994 .sender = sender,
957 .request_events = request_events, 995 .request_events = request_events,
996 .set_maintenance_mode = set_maintenance_mode,
958 .set_run_to_completion = set_run_to_completion, 997 .set_run_to_completion = set_run_to_completion,
959 .poll = poll, 998 .poll = poll,
960}; 999};
@@ -987,6 +1026,16 @@ static int num_regshifts = 0;
987static int slave_addrs[SI_MAX_PARMS]; 1026static int slave_addrs[SI_MAX_PARMS];
988static int num_slave_addrs = 0; 1027static int num_slave_addrs = 0;
989 1028
1029#define IPMI_IO_ADDR_SPACE 0
1030#define IPMI_MEM_ADDR_SPACE 1
1031static char *addr_space_to_str[] = { "I/O", "mem" };
1032
1033static int hotmod_handler(const char *val, struct kernel_param *kp);
1034
1035module_param_call(hotmod, hotmod_handler, NULL, NULL, 0200);
1036MODULE_PARM_DESC(hotmod, "Add and remove interfaces. See"
1037 " Documentation/IPMI.txt in the kernel sources for the"
1038 " gory details.");
990 1039
991module_param_named(trydefaults, si_trydefaults, bool, 0); 1040module_param_named(trydefaults, si_trydefaults, bool, 0);
992MODULE_PARM_DESC(trydefaults, "Setting this to 'false' will disable the" 1041MODULE_PARM_DESC(trydefaults, "Setting this to 'false' will disable the"
@@ -1038,12 +1087,12 @@ module_param_array(force_kipmid, int, &num_force_kipmid, 0);
1038MODULE_PARM_DESC(force_kipmid, "Force the kipmi daemon to be enabled (1) or" 1087MODULE_PARM_DESC(force_kipmid, "Force the kipmi daemon to be enabled (1) or"
1039 " disabled(0). Normally the IPMI driver auto-detects" 1088 " disabled(0). Normally the IPMI driver auto-detects"
1040 " this, but the value may be overridden by this parm."); 1089 " this, but the value may be overridden by this parm.");
1090module_param(unload_when_empty, int, 0);
1091MODULE_PARM_DESC(unload_when_empty, "Unload the module if no interfaces are"
1092 " specified or found, default is 1. Setting to 0"
1093 " is useful for hot add of devices using hotmod.");
1041 1094
1042 1095
1043#define IPMI_IO_ADDR_SPACE 0
1044#define IPMI_MEM_ADDR_SPACE 1
1045static char *addr_space_to_str[] = { "I/O", "memory" };
1046
1047static void std_irq_cleanup(struct smi_info *info) 1096static void std_irq_cleanup(struct smi_info *info)
1048{ 1097{
1049 if (info->si_type == SI_BT) 1098 if (info->si_type == SI_BT)
@@ -1317,6 +1366,234 @@ static int mem_setup(struct smi_info *info)
1317 return 0; 1366 return 0;
1318} 1367}
1319 1368
1369/*
1370 * Parms come in as <op1>[:op2[:op3...]]. ops are:
1371 * add|remove,kcs|bt|smic,mem|i/o,<address>[,<opt1>[,<opt2>[,...]]]
1372 * Options are:
1373 * rsp=<regspacing>
1374 * rsi=<regsize>
1375 * rsh=<regshift>
1376 * irq=<irq>
1377 * ipmb=<ipmb addr>
1378 */
1379enum hotmod_op { HM_ADD, HM_REMOVE };
1380struct hotmod_vals {
1381 char *name;
1382 int val;
1383};
1384static struct hotmod_vals hotmod_ops[] = {
1385 { "add", HM_ADD },
1386 { "remove", HM_REMOVE },
1387 { NULL }
1388};
1389static struct hotmod_vals hotmod_si[] = {
1390 { "kcs", SI_KCS },
1391 { "smic", SI_SMIC },
1392 { "bt", SI_BT },
1393 { NULL }
1394};
1395static struct hotmod_vals hotmod_as[] = {
1396 { "mem", IPMI_MEM_ADDR_SPACE },
1397 { "i/o", IPMI_IO_ADDR_SPACE },
1398 { NULL }
1399};
1400static int ipmi_strcasecmp(const char *s1, const char *s2)
1401{
1402 while (*s1 || *s2) {
1403 if (!*s1)
1404 return -1;
1405 if (!*s2)
1406 return 1;
1407 if (*s1 != *s2)
1408 return *s1 - *s2;
1409 s1++;
1410 s2++;
1411 }
1412 return 0;
1413}
1414static int parse_str(struct hotmod_vals *v, int *val, char *name, char **curr)
1415{
1416 char *s;
1417 int i;
1418
1419 s = strchr(*curr, ',');
1420 if (!s) {
1421 printk(KERN_WARNING PFX "No hotmod %s given.\n", name);
1422 return -EINVAL;
1423 }
1424 *s = '\0';
1425 s++;
1426 for (i = 0; hotmod_ops[i].name; i++) {
1427 if (ipmi_strcasecmp(*curr, v[i].name) == 0) {
1428 *val = v[i].val;
1429 *curr = s;
1430 return 0;
1431 }
1432 }
1433
1434 printk(KERN_WARNING PFX "Invalid hotmod %s '%s'\n", name, *curr);
1435 return -EINVAL;
1436}
1437
1438static int hotmod_handler(const char *val, struct kernel_param *kp)
1439{
1440 char *str = kstrdup(val, GFP_KERNEL);
1441 int rv = -EINVAL;
1442 char *next, *curr, *s, *n, *o;
1443 enum hotmod_op op;
1444 enum si_type si_type;
1445 int addr_space;
1446 unsigned long addr;
1447 int regspacing;
1448 int regsize;
1449 int regshift;
1450 int irq;
1451 int ipmb;
1452 int ival;
1453 struct smi_info *info;
1454
1455 if (!str)
1456 return -ENOMEM;
1457
1458 /* Kill any trailing spaces, as we can get a "\n" from echo. */
1459 ival = strlen(str) - 1;
1460 while ((ival >= 0) && isspace(str[ival])) {
1461 str[ival] = '\0';
1462 ival--;
1463 }
1464
1465 for (curr = str; curr; curr = next) {
1466 regspacing = 1;
1467 regsize = 1;
1468 regshift = 0;
1469 irq = 0;
1470 ipmb = 0x20;
1471
1472 next = strchr(curr, ':');
1473 if (next) {
1474 *next = '\0';
1475 next++;
1476 }
1477
1478 rv = parse_str(hotmod_ops, &ival, "operation", &curr);
1479 if (rv)
1480 break;
1481 op = ival;
1482
1483 rv = parse_str(hotmod_si, &ival, "interface type", &curr);
1484 if (rv)
1485 break;
1486 si_type = ival;
1487
1488 rv = parse_str(hotmod_as, &addr_space, "address space", &curr);
1489 if (rv)
1490 break;
1491
1492 s = strchr(curr, ',');
1493 if (s) {
1494 *s = '\0';
1495 s++;
1496 }
1497 addr = simple_strtoul(curr, &n, 0);
1498 if ((*n != '\0') || (*curr == '\0')) {
1499 printk(KERN_WARNING PFX "Invalid hotmod address"
1500 " '%s'\n", curr);
1501 break;
1502 }
1503
1504 while (s) {
1505 curr = s;
1506 s = strchr(curr, ',');
1507 if (s) {
1508 *s = '\0';
1509 s++;
1510 }
1511 o = strchr(curr, '=');
1512 if (o) {
1513 *o = '\0';
1514 o++;
1515 }
1516#define HOTMOD_INT_OPT(name, val) \
1517 if (ipmi_strcasecmp(curr, name) == 0) { \
1518 if (!o) { \
1519 printk(KERN_WARNING PFX \
1520 "No option given for '%s'\n", \
1521 curr); \
1522 goto out; \
1523 } \
1524 val = simple_strtoul(o, &n, 0); \
1525 if ((*n != '\0') || (*o == '\0')) { \
1526 printk(KERN_WARNING PFX \
1527 "Bad option given for '%s'\n", \
1528 curr); \
1529 goto out; \
1530 } \
1531 }
1532
1533 HOTMOD_INT_OPT("rsp", regspacing)
1534 else HOTMOD_INT_OPT("rsi", regsize)
1535 else HOTMOD_INT_OPT("rsh", regshift)
1536 else HOTMOD_INT_OPT("irq", irq)
1537 else HOTMOD_INT_OPT("ipmb", ipmb)
1538 else {
1539 printk(KERN_WARNING PFX
1540 "Invalid hotmod option '%s'\n",
1541 curr);
1542 goto out;
1543 }
1544#undef HOTMOD_INT_OPT
1545 }
1546
1547 if (op == HM_ADD) {
1548 info = kzalloc(sizeof(*info), GFP_KERNEL);
1549 if (!info) {
1550 rv = -ENOMEM;
1551 goto out;
1552 }
1553
1554 info->addr_source = "hotmod";
1555 info->si_type = si_type;
1556 info->io.addr_data = addr;
1557 info->io.addr_type = addr_space;
1558 if (addr_space == IPMI_MEM_ADDR_SPACE)
1559 info->io_setup = mem_setup;
1560 else
1561 info->io_setup = port_setup;
1562
1563 info->io.addr = NULL;
1564 info->io.regspacing = regspacing;
1565 if (!info->io.regspacing)
1566 info->io.regspacing = DEFAULT_REGSPACING;
1567 info->io.regsize = regsize;
1568 if (!info->io.regsize)
1569 info->io.regsize = DEFAULT_REGSPACING;
1570 info->io.regshift = regshift;
1571 info->irq = irq;
1572 if (info->irq)
1573 info->irq_setup = std_irq_setup;
1574 info->slave_addr = ipmb;
1575
1576 try_smi_init(info);
1577 } else {
1578 /* remove */
1579 struct smi_info *e, *tmp_e;
1580
1581 mutex_lock(&smi_infos_lock);
1582 list_for_each_entry_safe(e, tmp_e, &smi_infos, link) {
1583 if (e->io.addr_type != addr_space)
1584 continue;
1585 if (e->si_type != si_type)
1586 continue;
1587 if (e->io.addr_data == addr)
1588 cleanup_one_si(e);
1589 }
1590 mutex_unlock(&smi_infos_lock);
1591 }
1592 }
1593 out:
1594 kfree(str);
1595 return rv;
1596}
1320 1597
1321static __devinit void hardcode_find_bmc(void) 1598static __devinit void hardcode_find_bmc(void)
1322{ 1599{
@@ -1333,11 +1610,11 @@ static __devinit void hardcode_find_bmc(void)
1333 1610
1334 info->addr_source = "hardcoded"; 1611 info->addr_source = "hardcoded";
1335 1612
1336 if (!si_type[i] || strcmp(si_type[i], "kcs") == 0) { 1613 if (!si_type[i] || ipmi_strcasecmp(si_type[i], "kcs") == 0) {
1337 info->si_type = SI_KCS; 1614 info->si_type = SI_KCS;
1338 } else if (strcmp(si_type[i], "smic") == 0) { 1615 } else if (ipmi_strcasecmp(si_type[i], "smic") == 0) {
1339 info->si_type = SI_SMIC; 1616 info->si_type = SI_SMIC;
1340 } else if (strcmp(si_type[i], "bt") == 0) { 1617 } else if (ipmi_strcasecmp(si_type[i], "bt") == 0) {
1341 info->si_type = SI_BT; 1618 info->si_type = SI_BT;
1342 } else { 1619 } else {
1343 printk(KERN_WARNING 1620 printk(KERN_WARNING
@@ -1952,19 +2229,9 @@ static int try_get_dev_id(struct smi_info *smi_info)
1952static int type_file_read_proc(char *page, char **start, off_t off, 2229static int type_file_read_proc(char *page, char **start, off_t off,
1953 int count, int *eof, void *data) 2230 int count, int *eof, void *data)
1954{ 2231{
1955 char *out = (char *) page;
1956 struct smi_info *smi = data; 2232 struct smi_info *smi = data;
1957 2233
1958 switch (smi->si_type) { 2234 return sprintf(page, "%s\n", si_to_str[smi->si_type]);
1959 case SI_KCS:
1960 return sprintf(out, "kcs\n");
1961 case SI_SMIC:
1962 return sprintf(out, "smic\n");
1963 case SI_BT:
1964 return sprintf(out, "bt\n");
1965 default:
1966 return 0;
1967 }
1968} 2235}
1969 2236
1970static int stat_file_read_proc(char *page, char **start, off_t off, 2237static int stat_file_read_proc(char *page, char **start, off_t off,
@@ -2000,7 +2267,24 @@ static int stat_file_read_proc(char *page, char **start, off_t off,
2000 out += sprintf(out, "incoming_messages: %ld\n", 2267 out += sprintf(out, "incoming_messages: %ld\n",
2001 smi->incoming_messages); 2268 smi->incoming_messages);
2002 2269
2003 return (out - ((char *) page)); 2270 return out - page;
2271}
2272
2273static int param_read_proc(char *page, char **start, off_t off,
2274 int count, int *eof, void *data)
2275{
2276 struct smi_info *smi = data;
2277
2278 return sprintf(page,
2279 "%s,%s,0x%lx,rsp=%d,rsi=%d,rsh=%d,irq=%d,ipmb=%d\n",
2280 si_to_str[smi->si_type],
2281 addr_space_to_str[smi->io.addr_type],
2282 smi->io.addr_data,
2283 smi->io.regspacing,
2284 smi->io.regsize,
2285 smi->io.regshift,
2286 smi->irq,
2287 smi->slave_addr);
2004} 2288}
2005 2289
2006/* 2290/*
@@ -2362,6 +2646,7 @@ static int try_smi_init(struct smi_info *new_smi)
2362 new_smi, 2646 new_smi,
2363 &new_smi->device_id, 2647 &new_smi->device_id,
2364 new_smi->dev, 2648 new_smi->dev,
2649 "bmc",
2365 new_smi->slave_addr); 2650 new_smi->slave_addr);
2366 if (rv) { 2651 if (rv) {
2367 printk(KERN_ERR 2652 printk(KERN_ERR
@@ -2390,6 +2675,16 @@ static int try_smi_init(struct smi_info *new_smi)
2390 goto out_err_stop_timer; 2675 goto out_err_stop_timer;
2391 } 2676 }
2392 2677
2678 rv = ipmi_smi_add_proc_entry(new_smi->intf, "params",
2679 param_read_proc, NULL,
2680 new_smi, THIS_MODULE);
2681 if (rv) {
2682 printk(KERN_ERR
2683 "ipmi_si: Unable to create proc entry: %d\n",
2684 rv);
2685 goto out_err_stop_timer;
2686 }
2687
2393 list_add_tail(&new_smi->link, &smi_infos); 2688 list_add_tail(&new_smi->link, &smi_infos);
2394 2689
2395 mutex_unlock(&smi_infos_lock); 2690 mutex_unlock(&smi_infos_lock);
@@ -2483,7 +2778,12 @@ static __devinit int init_ipmi_si(void)
2483#endif 2778#endif
2484 2779
2485#ifdef CONFIG_PCI 2780#ifdef CONFIG_PCI
2486 pci_module_init(&ipmi_pci_driver); 2781 rv = pci_register_driver(&ipmi_pci_driver);
2782 if (rv){
2783 printk(KERN_ERR
2784 "init_ipmi_si: Unable to register PCI driver: %d\n",
2785 rv);
2786 }
2487#endif 2787#endif
2488 2788
2489 if (si_trydefaults) { 2789 if (si_trydefaults) {
@@ -2498,7 +2798,7 @@ static __devinit int init_ipmi_si(void)
2498 } 2798 }
2499 2799
2500 mutex_lock(&smi_infos_lock); 2800 mutex_lock(&smi_infos_lock);
2501 if (list_empty(&smi_infos)) { 2801 if (unload_when_empty && list_empty(&smi_infos)) {
2502 mutex_unlock(&smi_infos_lock); 2802 mutex_unlock(&smi_infos_lock);
2503#ifdef CONFIG_PCI 2803#ifdef CONFIG_PCI
2504 pci_unregister_driver(&ipmi_pci_driver); 2804 pci_unregister_driver(&ipmi_pci_driver);
@@ -2513,7 +2813,7 @@ static __devinit int init_ipmi_si(void)
2513} 2813}
2514module_init(init_ipmi_si); 2814module_init(init_ipmi_si);
2515 2815
2516static void __devexit cleanup_one_si(struct smi_info *to_clean) 2816static void cleanup_one_si(struct smi_info *to_clean)
2517{ 2817{
2518 int rv; 2818 int rv;
2519 unsigned long flags; 2819 unsigned long flags;
diff --git a/drivers/char/ipmi/ipmi_smic_sm.c b/drivers/char/ipmi/ipmi_smic_sm.c
index 39d7e5ef1a2b..e64ea7d25d24 100644
--- a/drivers/char/ipmi/ipmi_smic_sm.c
+++ b/drivers/char/ipmi/ipmi_smic_sm.c
@@ -141,12 +141,14 @@ static int start_smic_transaction(struct si_sm_data *smic,
141{ 141{
142 unsigned int i; 142 unsigned int i;
143 143
144 if ((size < 2) || (size > MAX_SMIC_WRITE_SIZE)) { 144 if (size < 2)
145 return -1; 145 return IPMI_REQ_LEN_INVALID_ERR;
146 } 146 if (size > MAX_SMIC_WRITE_SIZE)
147 if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED)) { 147 return IPMI_REQ_LEN_EXCEEDED_ERR;
148 return -2; 148
149 } 149 if ((smic->state != SMIC_IDLE) && (smic->state != SMIC_HOSED))
150 return IPMI_NOT_IN_MY_STATE_ERR;
151
150 if (smic_debug & SMIC_DEBUG_MSG) { 152 if (smic_debug & SMIC_DEBUG_MSG) {
151 printk(KERN_INFO "start_smic_transaction -"); 153 printk(KERN_INFO "start_smic_transaction -");
152 for (i = 0; i < size; i ++) { 154 for (i = 0; i < size; i ++) {
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
index 73f759eaa5a6..90fb2a541916 100644
--- a/drivers/char/ipmi/ipmi_watchdog.c
+++ b/drivers/char/ipmi/ipmi_watchdog.c
@@ -135,6 +135,7 @@
135static int nowayout = WATCHDOG_NOWAYOUT; 135static int nowayout = WATCHDOG_NOWAYOUT;
136 136
137static ipmi_user_t watchdog_user = NULL; 137static ipmi_user_t watchdog_user = NULL;
138static int watchdog_ifnum;
138 139
139/* Default the timeout to 10 seconds. */ 140/* Default the timeout to 10 seconds. */
140static int timeout = 10; 141static int timeout = 10;
@@ -161,6 +162,8 @@ static struct fasync_struct *fasync_q = NULL;
161static char pretimeout_since_last_heartbeat = 0; 162static char pretimeout_since_last_heartbeat = 0;
162static char expect_close; 163static char expect_close;
163 164
165static int ifnum_to_use = -1;
166
164static DECLARE_RWSEM(register_sem); 167static DECLARE_RWSEM(register_sem);
165 168
166/* Parameters to ipmi_set_timeout */ 169/* Parameters to ipmi_set_timeout */
@@ -169,6 +172,8 @@ static DECLARE_RWSEM(register_sem);
169#define IPMI_SET_TIMEOUT_FORCE_HB 2 172#define IPMI_SET_TIMEOUT_FORCE_HB 2
170 173
171static int ipmi_set_timeout(int do_heartbeat); 174static int ipmi_set_timeout(int do_heartbeat);
175static void ipmi_register_watchdog(int ipmi_intf);
176static void ipmi_unregister_watchdog(int ipmi_intf);
172 177
173/* If true, the driver will start running as soon as it is configured 178/* If true, the driver will start running as soon as it is configured
174 and ready. */ 179 and ready. */
@@ -245,6 +250,26 @@ static int get_param_str(char *buffer, struct kernel_param *kp)
245 return strlen(buffer); 250 return strlen(buffer);
246} 251}
247 252
253
254static int set_param_wdog_ifnum(const char *val, struct kernel_param *kp)
255{
256 int rv = param_set_int(val, kp);
257 if (rv)
258 return rv;
259 if ((ifnum_to_use < 0) || (ifnum_to_use == watchdog_ifnum))
260 return 0;
261
262 ipmi_unregister_watchdog(watchdog_ifnum);
263 ipmi_register_watchdog(ifnum_to_use);
264 return 0;
265}
266
267module_param_call(ifnum_to_use, set_param_wdog_ifnum, get_param_int,
268 &ifnum_to_use, 0644);
269MODULE_PARM_DESC(ifnum_to_use, "The interface number to use for the watchdog "
270 "timer. Setting to -1 defaults to the first registered "
271 "interface");
272
248module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644); 273module_param_call(timeout, set_param_int, get_param_int, &timeout, 0644);
249MODULE_PARM_DESC(timeout, "Timeout value in seconds."); 274MODULE_PARM_DESC(timeout, "Timeout value in seconds.");
250 275
@@ -263,12 +288,13 @@ module_param_call(preop, set_param_str, get_param_str, preop_op, 0644);
263MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: " 288MODULE_PARM_DESC(preop, "Pretimeout driver operation. One of: "
264 "preop_none, preop_panic, preop_give_data."); 289 "preop_none, preop_panic, preop_give_data.");
265 290
266module_param(start_now, int, 0); 291module_param(start_now, int, 0444);
267MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as" 292MODULE_PARM_DESC(start_now, "Set to 1 to start the watchdog as"
268 "soon as the driver is loaded."); 293 "soon as the driver is loaded.");
269 294
270module_param(nowayout, int, 0644); 295module_param(nowayout, int, 0644);
271MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 296MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
297 "(default=CONFIG_WATCHDOG_NOWAYOUT)");
272 298
273/* Default state of the timer. */ 299/* Default state of the timer. */
274static unsigned char ipmi_watchdog_state = WDOG_TIMEOUT_NONE; 300static unsigned char ipmi_watchdog_state = WDOG_TIMEOUT_NONE;
@@ -872,6 +898,11 @@ static void ipmi_register_watchdog(int ipmi_intf)
872 if (watchdog_user) 898 if (watchdog_user)
873 goto out; 899 goto out;
874 900
901 if ((ifnum_to_use >= 0) && (ifnum_to_use != ipmi_intf))
902 goto out;
903
904 watchdog_ifnum = ipmi_intf;
905
875 rv = ipmi_create_user(ipmi_intf, &ipmi_hndlrs, NULL, &watchdog_user); 906 rv = ipmi_create_user(ipmi_intf, &ipmi_hndlrs, NULL, &watchdog_user);
876 if (rv < 0) { 907 if (rv < 0) {
877 printk(KERN_CRIT PFX "Unable to register with ipmi\n"); 908 printk(KERN_CRIT PFX "Unable to register with ipmi\n");
@@ -901,6 +932,39 @@ static void ipmi_register_watchdog(int ipmi_intf)
901 } 932 }
902} 933}
903 934
935static void ipmi_unregister_watchdog(int ipmi_intf)
936{
937 int rv;
938
939 down_write(&register_sem);
940
941 if (!watchdog_user)
942 goto out;
943
944 if (watchdog_ifnum != ipmi_intf)
945 goto out;
946
947 /* Make sure no one can call us any more. */
948 misc_deregister(&ipmi_wdog_miscdev);
949
950 /* Wait to make sure the message makes it out. The lower layer has
951 pointers to our buffers, we want to make sure they are done before
952 we release our memory. */
953 while (atomic_read(&set_timeout_tofree))
954 schedule_timeout_uninterruptible(1);
955
956 /* Disconnect from IPMI. */
957 rv = ipmi_destroy_user(watchdog_user);
958 if (rv) {
959 printk(KERN_WARNING PFX "error unlinking from IPMI: %d\n",
960 rv);
961 }
962 watchdog_user = NULL;
963
964 out:
965 up_write(&register_sem);
966}
967
904#ifdef HAVE_NMI_HANDLER 968#ifdef HAVE_NMI_HANDLER
905static int 969static int
906ipmi_nmi(void *dev_id, int cpu, int handled) 970ipmi_nmi(void *dev_id, int cpu, int handled)
@@ -1004,9 +1068,7 @@ static void ipmi_new_smi(int if_num, struct device *device)
1004 1068
1005static void ipmi_smi_gone(int if_num) 1069static void ipmi_smi_gone(int if_num)
1006{ 1070{
1007 /* This can never be called, because once the watchdog is 1071 ipmi_unregister_watchdog(if_num);
1008 registered, the interface can't go away until the watchdog
1009 is unregistered. */
1010} 1072}
1011 1073
1012static struct ipmi_smi_watcher smi_watcher = 1074static struct ipmi_smi_watcher smi_watcher =
@@ -1148,30 +1210,32 @@ static int __init ipmi_wdog_init(void)
1148 1210
1149 check_parms(); 1211 check_parms();
1150 1212
1213 register_reboot_notifier(&wdog_reboot_notifier);
1214 atomic_notifier_chain_register(&panic_notifier_list,
1215 &wdog_panic_notifier);
1216
1151 rv = ipmi_smi_watcher_register(&smi_watcher); 1217 rv = ipmi_smi_watcher_register(&smi_watcher);
1152 if (rv) { 1218 if (rv) {
1153#ifdef HAVE_NMI_HANDLER 1219#ifdef HAVE_NMI_HANDLER
1154 if (preaction_val == WDOG_PRETIMEOUT_NMI) 1220 if (preaction_val == WDOG_PRETIMEOUT_NMI)
1155 release_nmi(&ipmi_nmi_handler); 1221 release_nmi(&ipmi_nmi_handler);
1156#endif 1222#endif
1223 atomic_notifier_chain_unregister(&panic_notifier_list,
1224 &wdog_panic_notifier);
1225 unregister_reboot_notifier(&wdog_reboot_notifier);
1157 printk(KERN_WARNING PFX "can't register smi watcher\n"); 1226 printk(KERN_WARNING PFX "can't register smi watcher\n");
1158 return rv; 1227 return rv;
1159 } 1228 }
1160 1229
1161 register_reboot_notifier(&wdog_reboot_notifier);
1162 atomic_notifier_chain_register(&panic_notifier_list,
1163 &wdog_panic_notifier);
1164
1165 printk(KERN_INFO PFX "driver initialized\n"); 1230 printk(KERN_INFO PFX "driver initialized\n");
1166 1231
1167 return 0; 1232 return 0;
1168} 1233}
1169 1234
1170static __exit void ipmi_unregister_watchdog(void) 1235static void __exit ipmi_wdog_exit(void)
1171{ 1236{
1172 int rv; 1237 ipmi_smi_watcher_unregister(&smi_watcher);
1173 1238 ipmi_unregister_watchdog(watchdog_ifnum);
1174 down_write(&register_sem);
1175 1239
1176#ifdef HAVE_NMI_HANDLER 1240#ifdef HAVE_NMI_HANDLER
1177 if (nmi_handler_registered) 1241 if (nmi_handler_registered)
@@ -1179,37 +1243,8 @@ static __exit void ipmi_unregister_watchdog(void)
1179#endif 1243#endif
1180 1244
1181 atomic_notifier_chain_unregister(&panic_notifier_list, 1245 atomic_notifier_chain_unregister(&panic_notifier_list,
1182 &wdog_panic_notifier); 1246 &wdog_panic_notifier);
1183 unregister_reboot_notifier(&wdog_reboot_notifier); 1247 unregister_reboot_notifier(&wdog_reboot_notifier);
1184
1185 if (! watchdog_user)
1186 goto out;
1187
1188 /* Make sure no one can call us any more. */
1189 misc_deregister(&ipmi_wdog_miscdev);
1190
1191 /* Wait to make sure the message makes it out. The lower layer has
1192 pointers to our buffers, we want to make sure they are done before
1193 we release our memory. */
1194 while (atomic_read(&set_timeout_tofree))
1195 schedule_timeout_uninterruptible(1);
1196
1197 /* Disconnect from IPMI. */
1198 rv = ipmi_destroy_user(watchdog_user);
1199 if (rv) {
1200 printk(KERN_WARNING PFX "error unlinking from IPMI: %d\n",
1201 rv);
1202 }
1203 watchdog_user = NULL;
1204
1205 out:
1206 up_write(&register_sem);
1207}
1208
1209static void __exit ipmi_wdog_exit(void)
1210{
1211 ipmi_smi_watcher_unregister(&smi_watcher);
1212 ipmi_unregister_watchdog();
1213} 1248}
1214module_exit(ipmi_wdog_exit); 1249module_exit(ipmi_wdog_exit);
1215module_init(ipmi_wdog_init); 1250module_init(ipmi_wdog_init);
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index bd9195e17956..8f591945ebd9 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -3476,6 +3476,8 @@ static int stli_initecp(stlibrd_t *brdp)
3476 if (sig.magic != cpu_to_le32(ECP_MAGIC)) 3476 if (sig.magic != cpu_to_le32(ECP_MAGIC))
3477 { 3477 {
3478 release_region(brdp->iobase, brdp->iosize); 3478 release_region(brdp->iobase, brdp->iosize);
3479 iounmap(brdp->membase);
3480 brdp->membase = NULL;
3479 return -ENODEV; 3481 return -ENODEV;
3480 } 3482 }
3481 3483
@@ -3632,6 +3634,8 @@ static int stli_initonb(stlibrd_t *brdp)
3632 sig.magic3 != cpu_to_le16(ONB_MAGIC3)) 3634 sig.magic3 != cpu_to_le16(ONB_MAGIC3))
3633 { 3635 {
3634 release_region(brdp->iobase, brdp->iosize); 3636 release_region(brdp->iobase, brdp->iosize);
3637 iounmap(brdp->membase);
3638 brdp->membase = NULL;
3635 return -ENODEV; 3639 return -ENODEV;
3636 } 3640 }
3637 3641
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index 7a484fc7cb9e..7e975f606924 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -199,6 +199,8 @@ int misc_register(struct miscdevice * misc)
199 dev_t dev; 199 dev_t dev;
200 int err = 0; 200 int err = 0;
201 201
202 INIT_LIST_HEAD(&misc->list);
203
202 down(&misc_sem); 204 down(&misc_sem);
203 list_for_each_entry(c, &misc_list, list) { 205 list_for_each_entry(c, &misc_list, list) {
204 if (c->minor == misc->minor) { 206 if (c->minor == misc->minor) {
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 22b9905c1e52..c09160383a53 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -680,7 +680,7 @@ static int __init mmtimer_init(void)
680 if (sn_rtc_cycles_per_second < 100000) { 680 if (sn_rtc_cycles_per_second < 100000) {
681 printk(KERN_ERR "%s: unable to determine clock frequency\n", 681 printk(KERN_ERR "%s: unable to determine clock frequency\n",
682 MMTIMER_NAME); 682 MMTIMER_NAME);
683 return -1; 683 goto out1;
684 } 684 }
685 685
686 mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second / 686 mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second /
@@ -689,13 +689,13 @@ static int __init mmtimer_init(void)
689 if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, IRQF_PERCPU, MMTIMER_NAME, NULL)) { 689 if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, IRQF_PERCPU, MMTIMER_NAME, NULL)) {
690 printk(KERN_WARNING "%s: unable to allocate interrupt.", 690 printk(KERN_WARNING "%s: unable to allocate interrupt.",
691 MMTIMER_NAME); 691 MMTIMER_NAME);
692 return -1; 692 goto out1;
693 } 693 }
694 694
695 if (misc_register(&mmtimer_miscdev)) { 695 if (misc_register(&mmtimer_miscdev)) {
696 printk(KERN_ERR "%s: failed to register device\n", 696 printk(KERN_ERR "%s: failed to register device\n",
697 MMTIMER_NAME); 697 MMTIMER_NAME);
698 return -1; 698 goto out2;
699 } 699 }
700 700
701 /* Get max numbered node, calculate slots needed */ 701 /* Get max numbered node, calculate slots needed */
@@ -709,16 +709,18 @@ static int __init mmtimer_init(void)
709 if (timers == NULL) { 709 if (timers == NULL) {
710 printk(KERN_ERR "%s: failed to allocate memory for device\n", 710 printk(KERN_ERR "%s: failed to allocate memory for device\n",
711 MMTIMER_NAME); 711 MMTIMER_NAME);
712 return -1; 712 goto out3;
713 } 713 }
714 714
715 memset(timers,0,(sizeof(mmtimer_t *)*maxn));
716
715 /* Allocate mmtimer_t's for each online node */ 717 /* Allocate mmtimer_t's for each online node */
716 for_each_online_node(node) { 718 for_each_online_node(node) {
717 timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node); 719 timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node);
718 if (timers[node] == NULL) { 720 if (timers[node] == NULL) {
719 printk(KERN_ERR "%s: failed to allocate memory for device\n", 721 printk(KERN_ERR "%s: failed to allocate memory for device\n",
720 MMTIMER_NAME); 722 MMTIMER_NAME);
721 return -1; 723 goto out4;
722 } 724 }
723 for (i=0; i< NUM_COMPARATORS; i++) { 725 for (i=0; i< NUM_COMPARATORS; i++) {
724 mmtimer_t * base = timers[node] + i; 726 mmtimer_t * base = timers[node] + i;
@@ -739,6 +741,17 @@ static int __init mmtimer_init(void)
739 sn_rtc_cycles_per_second/(unsigned long)1E6); 741 sn_rtc_cycles_per_second/(unsigned long)1E6);
740 742
741 return 0; 743 return 0;
744
745out4:
746 for_each_online_node(node) {
747 kfree(timers[node]);
748 }
749out3:
750 misc_deregister(&mmtimer_miscdev);
751out2:
752 free_irq(SGI_MMTIMER_VECTOR, NULL);
753out1:
754 return -1;
742} 755}
743 756
744module_init(mmtimer_init); 757module_init(mmtimer_init);
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index 2d025a9fd14d..8b316953173d 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -498,9 +498,12 @@ static void __exit moxa_exit(void)
498 printk("Couldn't unregister MOXA Intellio family serial driver\n"); 498 printk("Couldn't unregister MOXA Intellio family serial driver\n");
499 put_tty_driver(moxaDriver); 499 put_tty_driver(moxaDriver);
500 500
501 for (i = 0; i < MAX_BOARDS; i++) 501 for (i = 0; i < MAX_BOARDS; i++) {
502 if (moxaBaseAddr[i])
503 iounmap(moxaBaseAddr[i]);
502 if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI) 504 if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI)
503 pci_dev_put(moxa_boards[i].pciInfo.pdev); 505 pci_dev_put(moxa_boards[i].pciInfo.pdev);
506 }
504 507
505 if (verbose) 508 if (verbose)
506 printk("Done\n"); 509 printk("Done\n");
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 1bd12296dca5..74d21c1c104f 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -75,8 +75,10 @@
75#include <pcmcia/cisreg.h> 75#include <pcmcia/cisreg.h>
76#include <pcmcia/ds.h> 76#include <pcmcia/ds.h>
77 77
78#ifdef CONFIG_HDLC_MODULE 78#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_CS_MODULE))
79#define CONFIG_HDLC 1 79#define SYNCLINK_GENERIC_HDLC 1
80#else
81#define SYNCLINK_GENERIC_HDLC 0
80#endif 82#endif
81 83
82#define GET_USER(error,value,addr) error = get_user(value,addr) 84#define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -235,7 +237,7 @@ typedef struct _mgslpc_info {
235 int dosyncppp; 237 int dosyncppp;
236 spinlock_t netlock; 238 spinlock_t netlock;
237 239
238#ifdef CONFIG_HDLC 240#if SYNCLINK_GENERIC_HDLC
239 struct net_device *netdev; 241 struct net_device *netdev;
240#endif 242#endif
241 243
@@ -392,7 +394,7 @@ static void tx_timeout(unsigned long context);
392 394
393static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg); 395static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg);
394 396
395#ifdef CONFIG_HDLC 397#if SYNCLINK_GENERIC_HDLC
396#define dev_to_port(D) (dev_to_hdlc(D)->priv) 398#define dev_to_port(D) (dev_to_hdlc(D)->priv)
397static void hdlcdev_tx_done(MGSLPC_INFO *info); 399static void hdlcdev_tx_done(MGSLPC_INFO *info);
398static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size); 400static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size);
@@ -1053,7 +1055,7 @@ static void tx_done(MGSLPC_INFO *info)
1053 info->drop_rts_on_tx_done = 0; 1055 info->drop_rts_on_tx_done = 0;
1054 } 1056 }
1055 1057
1056#ifdef CONFIG_HDLC 1058#if SYNCLINK_GENERIC_HDLC
1057 if (info->netcount) 1059 if (info->netcount)
1058 hdlcdev_tx_done(info); 1060 hdlcdev_tx_done(info);
1059 else 1061 else
@@ -1164,7 +1166,7 @@ static void dcd_change(MGSLPC_INFO *info)
1164 } 1166 }
1165 else 1167 else
1166 info->input_signal_events.dcd_down++; 1168 info->input_signal_events.dcd_down++;
1167#ifdef CONFIG_HDLC 1169#if SYNCLINK_GENERIC_HDLC
1168 if (info->netcount) { 1170 if (info->netcount) {
1169 if (info->serial_signals & SerialSignal_DCD) 1171 if (info->serial_signals & SerialSignal_DCD)
1170 netif_carrier_on(info->netdev); 1172 netif_carrier_on(info->netdev);
@@ -2953,7 +2955,7 @@ static void mgslpc_add_device(MGSLPC_INFO *info)
2953 printk( "SyncLink PC Card %s:IO=%04X IRQ=%d\n", 2955 printk( "SyncLink PC Card %s:IO=%04X IRQ=%d\n",
2954 info->device_name, info->io_base, info->irq_level); 2956 info->device_name, info->io_base, info->irq_level);
2955 2957
2956#ifdef CONFIG_HDLC 2958#if SYNCLINK_GENERIC_HDLC
2957 hdlcdev_init(info); 2959 hdlcdev_init(info);
2958#endif 2960#endif
2959} 2961}
@@ -2969,7 +2971,7 @@ static void mgslpc_remove_device(MGSLPC_INFO *remove_info)
2969 last->next_device = info->next_device; 2971 last->next_device = info->next_device;
2970 else 2972 else
2971 mgslpc_device_list = info->next_device; 2973 mgslpc_device_list = info->next_device;
2972#ifdef CONFIG_HDLC 2974#if SYNCLINK_GENERIC_HDLC
2973 hdlcdev_exit(info); 2975 hdlcdev_exit(info);
2974#endif 2976#endif
2975 release_resources(info); 2977 release_resources(info);
@@ -3901,7 +3903,7 @@ static int rx_get_frame(MGSLPC_INFO *info)
3901 return_frame = 1; 3903 return_frame = 1;
3902 } 3904 }
3903 framesize = 0; 3905 framesize = 0;
3904#ifdef CONFIG_HDLC 3906#if SYNCLINK_GENERIC_HDLC
3905 { 3907 {
3906 struct net_device_stats *stats = hdlc_stats(info->netdev); 3908 struct net_device_stats *stats = hdlc_stats(info->netdev);
3907 stats->rx_errors++; 3909 stats->rx_errors++;
@@ -3935,7 +3937,7 @@ static int rx_get_frame(MGSLPC_INFO *info)
3935 ++framesize; 3937 ++framesize;
3936 } 3938 }
3937 3939
3938#ifdef CONFIG_HDLC 3940#if SYNCLINK_GENERIC_HDLC
3939 if (info->netcount) 3941 if (info->netcount)
3940 hdlcdev_rx(info, buf->data, framesize); 3942 hdlcdev_rx(info, buf->data, framesize);
3941 else 3943 else
@@ -4091,7 +4093,7 @@ static void tx_timeout(unsigned long context)
4091 4093
4092 spin_unlock_irqrestore(&info->lock,flags); 4094 spin_unlock_irqrestore(&info->lock,flags);
4093 4095
4094#ifdef CONFIG_HDLC 4096#if SYNCLINK_GENERIC_HDLC
4095 if (info->netcount) 4097 if (info->netcount)
4096 hdlcdev_tx_done(info); 4098 hdlcdev_tx_done(info);
4097 else 4099 else
@@ -4099,7 +4101,7 @@ static void tx_timeout(unsigned long context)
4099 bh_transmit(info); 4101 bh_transmit(info);
4100} 4102}
4101 4103
4102#ifdef CONFIG_HDLC 4104#if SYNCLINK_GENERIC_HDLC
4103 4105
4104/** 4106/**
4105 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 4107 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index 7ac68cb3bedd..e79b2ede8510 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -1026,6 +1026,7 @@ static int __init rio_init(void)
1026 found++; 1026 found++;
1027 } else { 1027 } else {
1028 iounmap(p->RIOHosts[p->RIONumHosts].Caddr); 1028 iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
1029 p->RIOHosts[p->RIONumHosts].Caddr = NULL;
1029 } 1030 }
1030 } 1031 }
1031 1032
@@ -1078,6 +1079,7 @@ static int __init rio_init(void)
1078 found++; 1079 found++;
1079 } else { 1080 } else {
1080 iounmap(p->RIOHosts[p->RIONumHosts].Caddr); 1081 iounmap(p->RIOHosts[p->RIONumHosts].Caddr);
1082 p->RIOHosts[p->RIONumHosts].Caddr = NULL;
1081 } 1083 }
1082#else 1084#else
1083 printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n"); 1085 printk(KERN_ERR "Found an older RIO PCI card, but the driver is not " "compiled to support it.\n");
@@ -1117,8 +1119,10 @@ static int __init rio_init(void)
1117 } 1119 }
1118 } 1120 }
1119 1121
1120 if (!okboard) 1122 if (!okboard) {
1121 iounmap(hp->Caddr); 1123 iounmap(hp->Caddr);
1124 hp->Caddr = NULL;
1125 }
1122 } 1126 }
1123 } 1127 }
1124 1128
@@ -1188,6 +1192,8 @@ static void __exit rio_exit(void)
1188 } 1192 }
1189 /* It is safe/allowed to del_timer a non-active timer */ 1193 /* It is safe/allowed to del_timer a non-active timer */
1190 del_timer(&hp->timer); 1194 del_timer(&hp->timer);
1195 if (hp->Caddr)
1196 iounmap(hp->Caddr);
1191 if (hp->Type == RIO_PCI) 1197 if (hp->Type == RIO_PCI)
1192 pci_dev_put(hp->pdev); 1198 pci_dev_put(hp->pdev);
1193 } 1199 }
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 722dd3e74185..0a77bfcd5b5e 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -82,11 +82,6 @@
82static struct riscom_board * IRQ_to_board[16]; 82static struct riscom_board * IRQ_to_board[16];
83static struct tty_driver *riscom_driver; 83static struct tty_driver *riscom_driver;
84 84
85static unsigned long baud_table[] = {
86 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
87 9600, 19200, 38400, 57600, 76800, 0,
88};
89
90static struct riscom_board rc_board[RC_NBOARD] = { 85static struct riscom_board rc_board[RC_NBOARD] = {
91 { 86 {
92 .base = RC_IOBASE1, 87 .base = RC_IOBASE1,
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 147c30da81ea..645187b9141e 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -101,8 +101,10 @@
101#include <linux/hdlc.h> 101#include <linux/hdlc.h>
102#include <linux/dma-mapping.h> 102#include <linux/dma-mapping.h>
103 103
104#ifdef CONFIG_HDLC_MODULE 104#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_MODULE))
105#define CONFIG_HDLC 1 105#define SYNCLINK_GENERIC_HDLC 1
106#else
107#define SYNCLINK_GENERIC_HDLC 0
106#endif 108#endif
107 109
108#define GET_USER(error,value,addr) error = get_user(value,addr) 110#define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -320,7 +322,7 @@ struct mgsl_struct {
320 int dosyncppp; 322 int dosyncppp;
321 spinlock_t netlock; 323 spinlock_t netlock;
322 324
323#ifdef CONFIG_HDLC 325#if SYNCLINK_GENERIC_HDLC
324 struct net_device *netdev; 326 struct net_device *netdev;
325#endif 327#endif
326}; 328};
@@ -728,7 +730,7 @@ static void usc_loopmode_send_done( struct mgsl_struct * info );
728 730
729static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg); 731static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg);
730 732
731#ifdef CONFIG_HDLC 733#if SYNCLINK_GENERIC_HDLC
732#define dev_to_port(D) (dev_to_hdlc(D)->priv) 734#define dev_to_port(D) (dev_to_hdlc(D)->priv)
733static void hdlcdev_tx_done(struct mgsl_struct *info); 735static void hdlcdev_tx_done(struct mgsl_struct *info);
734static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size); 736static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size);
@@ -1277,7 +1279,7 @@ static void mgsl_isr_transmit_status( struct mgsl_struct *info )
1277 info->drop_rts_on_tx_done = 0; 1279 info->drop_rts_on_tx_done = 0;
1278 } 1280 }
1279 1281
1280#ifdef CONFIG_HDLC 1282#if SYNCLINK_GENERIC_HDLC
1281 if (info->netcount) 1283 if (info->netcount)
1282 hdlcdev_tx_done(info); 1284 hdlcdev_tx_done(info);
1283 else 1285 else
@@ -1342,7 +1344,7 @@ static void mgsl_isr_io_pin( struct mgsl_struct *info )
1342 info->input_signal_events.dcd_up++; 1344 info->input_signal_events.dcd_up++;
1343 } else 1345 } else
1344 info->input_signal_events.dcd_down++; 1346 info->input_signal_events.dcd_down++;
1345#ifdef CONFIG_HDLC 1347#if SYNCLINK_GENERIC_HDLC
1346 if (info->netcount) { 1348 if (info->netcount) {
1347 if (status & MISCSTATUS_DCD) 1349 if (status & MISCSTATUS_DCD)
1348 netif_carrier_on(info->netdev); 1350 netif_carrier_on(info->netdev);
@@ -4313,7 +4315,7 @@ static void mgsl_add_device( struct mgsl_struct *info )
4313 info->max_frame_size ); 4315 info->max_frame_size );
4314 } 4316 }
4315 4317
4316#ifdef CONFIG_HDLC 4318#if SYNCLINK_GENERIC_HDLC
4317 hdlcdev_init(info); 4319 hdlcdev_init(info);
4318#endif 4320#endif
4319 4321
@@ -4471,7 +4473,7 @@ static void synclink_cleanup(void)
4471 4473
4472 info = mgsl_device_list; 4474 info = mgsl_device_list;
4473 while(info) { 4475 while(info) {
4474#ifdef CONFIG_HDLC 4476#if SYNCLINK_GENERIC_HDLC
4475 hdlcdev_exit(info); 4477 hdlcdev_exit(info);
4476#endif 4478#endif
4477 mgsl_release_resources(info); 4479 mgsl_release_resources(info);
@@ -6645,7 +6647,7 @@ static int mgsl_get_rx_frame(struct mgsl_struct *info)
6645 return_frame = 1; 6647 return_frame = 1;
6646 } 6648 }
6647 framesize = 0; 6649 framesize = 0;
6648#ifdef CONFIG_HDLC 6650#if SYNCLINK_GENERIC_HDLC
6649 { 6651 {
6650 struct net_device_stats *stats = hdlc_stats(info->netdev); 6652 struct net_device_stats *stats = hdlc_stats(info->netdev);
6651 stats->rx_errors++; 6653 stats->rx_errors++;
@@ -6721,7 +6723,7 @@ static int mgsl_get_rx_frame(struct mgsl_struct *info)
6721 *ptmp); 6723 *ptmp);
6722 } 6724 }
6723 6725
6724#ifdef CONFIG_HDLC 6726#if SYNCLINK_GENERIC_HDLC
6725 if (info->netcount) 6727 if (info->netcount)
6726 hdlcdev_rx(info,info->intermediate_rxbuffer,framesize); 6728 hdlcdev_rx(info,info->intermediate_rxbuffer,framesize);
6727 else 6729 else
@@ -7625,7 +7627,7 @@ static void mgsl_tx_timeout(unsigned long context)
7625 7627
7626 spin_unlock_irqrestore(&info->irq_spinlock,flags); 7628 spin_unlock_irqrestore(&info->irq_spinlock,flags);
7627 7629
7628#ifdef CONFIG_HDLC 7630#if SYNCLINK_GENERIC_HDLC
7629 if (info->netcount) 7631 if (info->netcount)
7630 hdlcdev_tx_done(info); 7632 hdlcdev_tx_done(info);
7631 else 7633 else
@@ -7701,7 +7703,7 @@ static int usc_loopmode_active( struct mgsl_struct * info)
7701 return usc_InReg( info, CCSR ) & BIT7 ? 1 : 0 ; 7703 return usc_InReg( info, CCSR ) & BIT7 ? 1 : 0 ;
7702} 7704}
7703 7705
7704#ifdef CONFIG_HDLC 7706#if SYNCLINK_GENERIC_HDLC
7705 7707
7706/** 7708/**
7707 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 7709 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 07f34d43dc7f..e4730a7312b5 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -83,8 +83,10 @@
83 83
84#include "linux/synclink.h" 84#include "linux/synclink.h"
85 85
86#ifdef CONFIG_HDLC_MODULE 86#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINK_GT_MODULE))
87#define CONFIG_HDLC 1 87#define SYNCLINK_GENERIC_HDLC 1
88#else
89#define SYNCLINK_GENERIC_HDLC 0
88#endif 90#endif
89 91
90/* 92/*
@@ -171,7 +173,7 @@ static void set_break(struct tty_struct *tty, int break_state);
171/* 173/*
172 * generic HDLC support and callbacks 174 * generic HDLC support and callbacks
173 */ 175 */
174#ifdef CONFIG_HDLC 176#if SYNCLINK_GENERIC_HDLC
175#define dev_to_port(D) (dev_to_hdlc(D)->priv) 177#define dev_to_port(D) (dev_to_hdlc(D)->priv)
176static void hdlcdev_tx_done(struct slgt_info *info); 178static void hdlcdev_tx_done(struct slgt_info *info);
177static void hdlcdev_rx(struct slgt_info *info, char *buf, int size); 179static void hdlcdev_rx(struct slgt_info *info, char *buf, int size);
@@ -359,7 +361,7 @@ struct slgt_info {
359 int netcount; 361 int netcount;
360 int dosyncppp; 362 int dosyncppp;
361 spinlock_t netlock; 363 spinlock_t netlock;
362#ifdef CONFIG_HDLC 364#if SYNCLINK_GENERIC_HDLC
363 struct net_device *netdev; 365 struct net_device *netdev;
364#endif 366#endif
365 367
@@ -1354,7 +1356,7 @@ static void set_break(struct tty_struct *tty, int break_state)
1354 spin_unlock_irqrestore(&info->lock,flags); 1356 spin_unlock_irqrestore(&info->lock,flags);
1355} 1357}
1356 1358
1357#ifdef CONFIG_HDLC 1359#if SYNCLINK_GENERIC_HDLC
1358 1360
1359/** 1361/**
1360 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 1362 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
@@ -2002,7 +2004,7 @@ static void dcd_change(struct slgt_info *info)
2002 } else { 2004 } else {
2003 info->input_signal_events.dcd_down++; 2005 info->input_signal_events.dcd_down++;
2004 } 2006 }
2005#ifdef CONFIG_HDLC 2007#if SYNCLINK_GENERIC_HDLC
2006 if (info->netcount) { 2008 if (info->netcount) {
2007 if (info->signals & SerialSignal_DCD) 2009 if (info->signals & SerialSignal_DCD)
2008 netif_carrier_on(info->netdev); 2010 netif_carrier_on(info->netdev);
@@ -2180,7 +2182,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
2180 set_signals(info); 2182 set_signals(info);
2181 } 2183 }
2182 2184
2183#ifdef CONFIG_HDLC 2185#if SYNCLINK_GENERIC_HDLC
2184 if (info->netcount) 2186 if (info->netcount)
2185 hdlcdev_tx_done(info); 2187 hdlcdev_tx_done(info);
2186 else 2188 else
@@ -3306,7 +3308,7 @@ static void add_device(struct slgt_info *info)
3306 devstr, info->device_name, info->phys_reg_addr, 3308 devstr, info->device_name, info->phys_reg_addr,
3307 info->irq_level, info->max_frame_size); 3309 info->irq_level, info->max_frame_size);
3308 3310
3309#ifdef CONFIG_HDLC 3311#if SYNCLINK_GENERIC_HDLC
3310 hdlcdev_init(info); 3312 hdlcdev_init(info);
3311#endif 3313#endif
3312} 3314}
@@ -3488,7 +3490,7 @@ static void slgt_cleanup(void)
3488 /* release devices */ 3490 /* release devices */
3489 info = slgt_device_list; 3491 info = slgt_device_list;
3490 while(info) { 3492 while(info) {
3491#ifdef CONFIG_HDLC 3493#if SYNCLINK_GENERIC_HDLC
3492 hdlcdev_exit(info); 3494 hdlcdev_exit(info);
3493#endif 3495#endif
3494 free_dma_bufs(info); 3496 free_dma_bufs(info);
@@ -3522,6 +3524,7 @@ static int __init slgt_init(void)
3522 3524
3523 if (!slgt_device_list) { 3525 if (!slgt_device_list) {
3524 printk("%s no devices found\n",driver_name); 3526 printk("%s no devices found\n",driver_name);
3527 pci_unregister_driver(&pci_driver);
3525 return -ENODEV; 3528 return -ENODEV;
3526 } 3529 }
3527 3530
@@ -4433,7 +4436,7 @@ check_again:
4433 framesize = 0; 4436 framesize = 0;
4434 } 4437 }
4435 4438
4436#ifdef CONFIG_HDLC 4439#if SYNCLINK_GENERIC_HDLC
4437 if (framesize == 0) { 4440 if (framesize == 0) {
4438 struct net_device_stats *stats = hdlc_stats(info->netdev); 4441 struct net_device_stats *stats = hdlc_stats(info->netdev);
4439 stats->rx_errors++; 4442 stats->rx_errors++;
@@ -4476,7 +4479,7 @@ check_again:
4476 framesize++; 4479 framesize++;
4477 } 4480 }
4478 4481
4479#ifdef CONFIG_HDLC 4482#if SYNCLINK_GENERIC_HDLC
4480 if (info->netcount) 4483 if (info->netcount)
4481 hdlcdev_rx(info,info->tmp_rbuf, framesize); 4484 hdlcdev_rx(info,info->tmp_rbuf, framesize);
4482 else 4485 else
@@ -4779,7 +4782,7 @@ static void tx_timeout(unsigned long context)
4779 info->tx_count = 0; 4782 info->tx_count = 0;
4780 spin_unlock_irqrestore(&info->lock,flags); 4783 spin_unlock_irqrestore(&info->lock,flags);
4781 4784
4782#ifdef CONFIG_HDLC 4785#if SYNCLINK_GENERIC_HDLC
4783 if (info->netcount) 4786 if (info->netcount)
4784 hdlcdev_tx_done(info); 4787 hdlcdev_tx_done(info);
4785 else 4788 else
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 13a57245cf2e..20a96ef250be 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -67,8 +67,10 @@
67#include <linux/workqueue.h> 67#include <linux/workqueue.h>
68#include <linux/hdlc.h> 68#include <linux/hdlc.h>
69 69
70#ifdef CONFIG_HDLC_MODULE 70#if defined(CONFIG_HDLC) || (defined(CONFIG_HDLC_MODULE) && defined(CONFIG_SYNCLINKMP_MODULE))
71#define CONFIG_HDLC 1 71#define SYNCLINK_GENERIC_HDLC 1
72#else
73#define SYNCLINK_GENERIC_HDLC 0
72#endif 74#endif
73 75
74#define GET_USER(error,value,addr) error = get_user(value,addr) 76#define GET_USER(error,value,addr) error = get_user(value,addr)
@@ -280,7 +282,7 @@ typedef struct _synclinkmp_info {
280 int dosyncppp; 282 int dosyncppp;
281 spinlock_t netlock; 283 spinlock_t netlock;
282 284
283#ifdef CONFIG_HDLC 285#if SYNCLINK_GENERIC_HDLC
284 struct net_device *netdev; 286 struct net_device *netdev;
285#endif 287#endif
286 288
@@ -536,7 +538,7 @@ static void throttle(struct tty_struct * tty);
536static void unthrottle(struct tty_struct * tty); 538static void unthrottle(struct tty_struct * tty);
537static void set_break(struct tty_struct *tty, int break_state); 539static void set_break(struct tty_struct *tty, int break_state);
538 540
539#ifdef CONFIG_HDLC 541#if SYNCLINK_GENERIC_HDLC
540#define dev_to_port(D) (dev_to_hdlc(D)->priv) 542#define dev_to_port(D) (dev_to_hdlc(D)->priv)
541static void hdlcdev_tx_done(SLMP_INFO *info); 543static void hdlcdev_tx_done(SLMP_INFO *info);
542static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size); 544static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size);
@@ -1607,7 +1609,7 @@ static void set_break(struct tty_struct *tty, int break_state)
1607 spin_unlock_irqrestore(&info->lock,flags); 1609 spin_unlock_irqrestore(&info->lock,flags);
1608} 1610}
1609 1611
1610#ifdef CONFIG_HDLC 1612#if SYNCLINK_GENERIC_HDLC
1611 1613
1612/** 1614/**
1613 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.) 1615 * called by generic HDLC layer when protocol selected (PPP, frame relay, etc.)
@@ -2339,7 +2341,7 @@ static void isr_txeom(SLMP_INFO * info, unsigned char status)
2339 set_signals(info); 2341 set_signals(info);
2340 } 2342 }
2341 2343
2342#ifdef CONFIG_HDLC 2344#if SYNCLINK_GENERIC_HDLC
2343 if (info->netcount) 2345 if (info->netcount)
2344 hdlcdev_tx_done(info); 2346 hdlcdev_tx_done(info);
2345 else 2347 else
@@ -2523,7 +2525,7 @@ void isr_io_pin( SLMP_INFO *info, u16 status )
2523 info->input_signal_events.dcd_up++; 2525 info->input_signal_events.dcd_up++;
2524 } else 2526 } else
2525 info->input_signal_events.dcd_down++; 2527 info->input_signal_events.dcd_down++;
2526#ifdef CONFIG_HDLC 2528#if SYNCLINK_GENERIC_HDLC
2527 if (info->netcount) { 2529 if (info->netcount) {
2528 if (status & SerialSignal_DCD) 2530 if (status & SerialSignal_DCD)
2529 netif_carrier_on(info->netdev); 2531 netif_carrier_on(info->netdev);
@@ -3783,7 +3785,7 @@ void add_device(SLMP_INFO *info)
3783 info->irq_level, 3785 info->irq_level,
3784 info->max_frame_size ); 3786 info->max_frame_size );
3785 3787
3786#ifdef CONFIG_HDLC 3788#if SYNCLINK_GENERIC_HDLC
3787 hdlcdev_init(info); 3789 hdlcdev_init(info);
3788#endif 3790#endif
3789} 3791}
@@ -3977,7 +3979,7 @@ static void synclinkmp_cleanup(void)
3977 /* release devices */ 3979 /* release devices */
3978 info = synclinkmp_device_list; 3980 info = synclinkmp_device_list;
3979 while(info) { 3981 while(info) {
3980#ifdef CONFIG_HDLC 3982#if SYNCLINK_GENERIC_HDLC
3981 hdlcdev_exit(info); 3983 hdlcdev_exit(info);
3982#endif 3984#endif
3983 free_dma_bufs(info); 3985 free_dma_bufs(info);
@@ -4979,7 +4981,7 @@ CheckAgain:
4979 info->icount.rxcrc++; 4981 info->icount.rxcrc++;
4980 4982
4981 framesize = 0; 4983 framesize = 0;
4982#ifdef CONFIG_HDLC 4984#if SYNCLINK_GENERIC_HDLC
4983 { 4985 {
4984 struct net_device_stats *stats = hdlc_stats(info->netdev); 4986 struct net_device_stats *stats = hdlc_stats(info->netdev);
4985 stats->rx_errors++; 4987 stats->rx_errors++;
@@ -5020,7 +5022,7 @@ CheckAgain:
5020 index = 0; 5022 index = 0;
5021 } 5023 }
5022 5024
5023#ifdef CONFIG_HDLC 5025#if SYNCLINK_GENERIC_HDLC
5024 if (info->netcount) 5026 if (info->netcount)
5025 hdlcdev_rx(info,info->tmp_rx_buf,framesize); 5027 hdlcdev_rx(info,info->tmp_rx_buf,framesize);
5026 else 5028 else
@@ -5531,7 +5533,7 @@ void tx_timeout(unsigned long context)
5531 5533
5532 spin_unlock_irqrestore(&info->lock,flags); 5534 spin_unlock_irqrestore(&info->lock,flags);
5533 5535
5534#ifdef CONFIG_HDLC 5536#if SYNCLINK_GENERIC_HDLC
5535 if (info->netcount) 5537 if (info->netcount)
5536 hdlcdev_tx_done(info); 5538 hdlcdev_tx_done(info);
5537 else 5539 else
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index c64f5bcff947..05810c8d20bc 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -182,6 +182,18 @@ static struct sysrq_key_op sysrq_showstate_op = {
182 .enable_mask = SYSRQ_ENABLE_DUMP, 182 .enable_mask = SYSRQ_ENABLE_DUMP,
183}; 183};
184 184
185static void sysrq_handle_showstate_blocked(int key, struct tty_struct *tty)
186{
187 show_state_filter(TASK_UNINTERRUPTIBLE);
188}
189static struct sysrq_key_op sysrq_showstate_blocked_op = {
190 .handler = sysrq_handle_showstate_blocked,
191 .help_msg = "showBlockedTasks",
192 .action_msg = "Show Blocked State",
193 .enable_mask = SYSRQ_ENABLE_DUMP,
194};
195
196
185static void sysrq_handle_showmem(int key, struct tty_struct *tty) 197static void sysrq_handle_showmem(int key, struct tty_struct *tty)
186{ 198{
187 show_mem(); 199 show_mem();
@@ -304,7 +316,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
304 /* May be assigned at init time by SMP VOYAGER */ 316 /* May be assigned at init time by SMP VOYAGER */
305 NULL, /* v */ 317 NULL, /* v */
306 NULL, /* w */ 318 NULL, /* w */
307 NULL, /* x */ 319 &sysrq_showstate_blocked_op, /* x */
308 NULL, /* y */ 320 NULL, /* y */
309 NULL /* z */ 321 NULL /* z */
310}; 322};
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index dd36fd04a842..07067c31c4ec 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -249,6 +249,7 @@ int tosh_smm(SMMRegisters *regs)
249 249
250 return eax; 250 return eax;
251} 251}
252EXPORT_SYMBOL(tosh_smm);
252 253
253 254
254static int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd, 255static int tosh_ioctl(struct inode *ip, struct file *fp, unsigned int cmd,
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 774fa861169a..33e1f66e39cb 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -1155,6 +1155,7 @@ struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vend
1155 1155
1156 if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) { 1156 if (sysfs_create_group(&dev->kobj, chip->vendor.attr_group)) {
1157 list_del(&chip->list); 1157 list_del(&chip->list);
1158 misc_deregister(&chip->vendor.miscdev);
1158 put_device(dev); 1159 put_device(dev);
1159 clear_bit(chip->dev_num, dev_mask); 1160 clear_bit(chip->dev_num, dev_mask);
1160 kfree(chip); 1161 kfree(chip);
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 75ff0286e1ad..a8239dac994f 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -152,7 +152,7 @@ static void gotoxy(struct vc_data *vc, int new_x, int new_y);
152static void save_cur(struct vc_data *vc); 152static void save_cur(struct vc_data *vc);
153static void reset_terminal(struct vc_data *vc, int do_clear); 153static void reset_terminal(struct vc_data *vc, int do_clear);
154static void con_flush_chars(struct tty_struct *tty); 154static void con_flush_chars(struct tty_struct *tty);
155static void set_vesa_blanking(char __user *p); 155static int set_vesa_blanking(char __user *p);
156static void set_cursor(struct vc_data *vc); 156static void set_cursor(struct vc_data *vc);
157static void hide_cursor(struct vc_data *vc); 157static void hide_cursor(struct vc_data *vc);
158static void console_callback(struct work_struct *ignored); 158static void console_callback(struct work_struct *ignored);
@@ -2369,7 +2369,7 @@ int tioclinux(struct tty_struct *tty, unsigned long arg)
2369 ret = __put_user(data, p); 2369 ret = __put_user(data, p);
2370 break; 2370 break;
2371 case TIOCL_SETVESABLANK: 2371 case TIOCL_SETVESABLANK:
2372 set_vesa_blanking(p); 2372 ret = set_vesa_blanking(p);
2373 break; 2373 break;
2374 case TIOCL_GETKMSGREDIRECT: 2374 case TIOCL_GETKMSGREDIRECT:
2375 data = kmsg_redirect; 2375 data = kmsg_redirect;
@@ -3313,11 +3313,15 @@ postcore_initcall(vtconsole_class_init);
3313 * Screen blanking 3313 * Screen blanking
3314 */ 3314 */
3315 3315
3316static void set_vesa_blanking(char __user *p) 3316static int set_vesa_blanking(char __user *p)
3317{ 3317{
3318 unsigned int mode; 3318 unsigned int mode;
3319 get_user(mode, p + 1); 3319
3320 vesa_blank_mode = (mode < 4) ? mode : 0; 3320 if (get_user(mode, p + 1))
3321 return -EFAULT;
3322
3323 vesa_blank_mode = (mode < 4) ? mode : 0;
3324 return 0;
3321} 3325}
3322 3326
3323void do_blank_screen(int entering_gfx) 3327void do_blank_screen(int entering_gfx)
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index e275dd4a705d..61138726b501 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -634,7 +634,7 @@ static int usb_pcwd_probe(struct usb_interface *interface, const struct usb_devi
634 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8); 634 usb_pcwd->intr_size = (le16_to_cpu(endpoint->wMaxPacketSize) > 8 ? le16_to_cpu(endpoint->wMaxPacketSize) : 8);
635 635
636 /* set up the memory buffer's */ 636 /* set up the memory buffer's */
637 if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, SLAB_ATOMIC, &usb_pcwd->intr_dma))) { 637 if (!(usb_pcwd->intr_buffer = usb_buffer_alloc(udev, usb_pcwd->intr_size, GFP_ATOMIC, &usb_pcwd->intr_dma))) {
638 printk(KERN_ERR PFX "Out of memory\n"); 638 printk(KERN_ERR PFX "Out of memory\n");
639 goto error; 639 goto error;
640 } 640 }
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 7a7c6e6dfe4f..47ab42db122a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1537,7 +1537,6 @@ int cpufreq_update_policy(unsigned int cpu)
1537} 1537}
1538EXPORT_SYMBOL(cpufreq_update_policy); 1538EXPORT_SYMBOL(cpufreq_update_policy);
1539 1539
1540#ifdef CONFIG_HOTPLUG_CPU
1541static int cpufreq_cpu_callback(struct notifier_block *nfb, 1540static int cpufreq_cpu_callback(struct notifier_block *nfb,
1542 unsigned long action, void *hcpu) 1541 unsigned long action, void *hcpu)
1543{ 1542{
@@ -1577,7 +1576,6 @@ static struct notifier_block __cpuinitdata cpufreq_cpu_notifier =
1577{ 1576{
1578 .notifier_call = cpufreq_cpu_callback, 1577 .notifier_call = cpufreq_cpu_callback,
1579}; 1578};
1580#endif /* CONFIG_HOTPLUG_CPU */
1581 1579
1582/********************************************************************* 1580/*********************************************************************
1583 * REGISTER / UNREGISTER CPUFREQ DRIVER * 1581 * REGISTER / UNREGISTER CPUFREQ DRIVER *
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index adb554153f67..e816535ab305 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -51,4 +51,17 @@ config CRYPTO_DEV_PADLOCK_SHA
51 If unsure say M. The compiled module will be 51 If unsure say M. The compiled module will be
52 called padlock-sha.ko 52 called padlock-sha.ko
53 53
54config CRYPTO_DEV_GEODE
55 tristate "Support for the Geode LX AES engine"
56 depends on CRYPTO && X86_32
57 select CRYPTO_ALGAPI
58 select CRYPTO_BLKCIPHER
59 default m
60 help
61 Say 'Y' here to use the AMD Geode LX processor on-board AES
62 engine for the CryptoAPI AES alogrithm.
63
64 To compile this driver as a module, choose M here: the module
65 will be called geode-aes.
66
54endmenu 67endmenu
diff --git a/drivers/crypto/Makefile b/drivers/crypto/Makefile
index 4c3d0ec1cf80..6059cf869414 100644
--- a/drivers/crypto/Makefile
+++ b/drivers/crypto/Makefile
@@ -1,3 +1,4 @@
1obj-$(CONFIG_CRYPTO_DEV_PADLOCK) += padlock.o 1obj-$(CONFIG_CRYPTO_DEV_PADLOCK) += padlock.o
2obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o 2obj-$(CONFIG_CRYPTO_DEV_PADLOCK_AES) += padlock-aes.o
3obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o 3obj-$(CONFIG_CRYPTO_DEV_PADLOCK_SHA) += padlock-sha.o
4obj-$(CONFIG_CRYPTO_DEV_GEODE) += geode-aes.o
diff --git a/drivers/crypto/geode-aes.c b/drivers/crypto/geode-aes.c
new file mode 100644
index 000000000000..43a68398656f
--- /dev/null
+++ b/drivers/crypto/geode-aes.c
@@ -0,0 +1,474 @@
1 /* Copyright (C) 2004-2006, Advanced Micro Devices, Inc.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 */
8
9#include <linux/module.h>
10#include <linux/kernel.h>
11#include <linux/sched.h>
12#include <linux/pci.h>
13#include <linux/pci_ids.h>
14#include <linux/crypto.h>
15#include <linux/spinlock.h>
16#include <crypto/algapi.h>
17
18#include <asm/io.h>
19#include <asm/delay.h>
20
21#include "geode-aes.h"
22
23/* Register definitions */
24
25#define AES_CTRLA_REG 0x0000
26
27#define AES_CTRL_START 0x01
28#define AES_CTRL_DECRYPT 0x00
29#define AES_CTRL_ENCRYPT 0x02
30#define AES_CTRL_WRKEY 0x04
31#define AES_CTRL_DCA 0x08
32#define AES_CTRL_SCA 0x10
33#define AES_CTRL_CBC 0x20
34
35#define AES_INTR_REG 0x0008
36
37#define AES_INTRA_PENDING (1 << 16)
38#define AES_INTRB_PENDING (1 << 17)
39
40#define AES_INTR_PENDING (AES_INTRA_PENDING | AES_INTRB_PENDING)
41#define AES_INTR_MASK 0x07
42
43#define AES_SOURCEA_REG 0x0010
44#define AES_DSTA_REG 0x0014
45#define AES_LENA_REG 0x0018
46#define AES_WRITEKEY0_REG 0x0030
47#define AES_WRITEIV0_REG 0x0040
48
49/* A very large counter that is used to gracefully bail out of an
50 * operation in case of trouble
51 */
52
53#define AES_OP_TIMEOUT 0x50000
54
55/* Static structures */
56
57static void __iomem * _iobase;
58static spinlock_t lock;
59
60/* Write a 128 bit field (either a writable key or IV) */
61static inline void
62_writefield(u32 offset, void *value)
63{
64 int i;
65 for(i = 0; i < 4; i++)
66 iowrite32(((u32 *) value)[i], _iobase + offset + (i * 4));
67}
68
69/* Read a 128 bit field (either a writable key or IV) */
70static inline void
71_readfield(u32 offset, void *value)
72{
73 int i;
74 for(i = 0; i < 4; i++)
75 ((u32 *) value)[i] = ioread32(_iobase + offset + (i * 4));
76}
77
78static int
79do_crypt(void *src, void *dst, int len, u32 flags)
80{
81 u32 status;
82 u32 counter = AES_OP_TIMEOUT;
83
84 iowrite32(virt_to_phys(src), _iobase + AES_SOURCEA_REG);
85 iowrite32(virt_to_phys(dst), _iobase + AES_DSTA_REG);
86 iowrite32(len, _iobase + AES_LENA_REG);
87
88 /* Start the operation */
89 iowrite32(AES_CTRL_START | flags, _iobase + AES_CTRLA_REG);
90
91 do
92 status = ioread32(_iobase + AES_INTR_REG);
93 while(!(status & AES_INTRA_PENDING) && --counter);
94
95 /* Clear the event */
96 iowrite32((status & 0xFF) | AES_INTRA_PENDING, _iobase + AES_INTR_REG);
97 return counter ? 0 : 1;
98}
99
100static unsigned int
101geode_aes_crypt(struct geode_aes_op *op)
102{
103
104 u32 flags = 0;
105 int iflags;
106
107 if (op->len == 0 || op->src == op->dst)
108 return 0;
109
110 if (op->flags & AES_FLAGS_COHERENT)
111 flags |= (AES_CTRL_DCA | AES_CTRL_SCA);
112
113 if (op->dir == AES_DIR_ENCRYPT)
114 flags |= AES_CTRL_ENCRYPT;
115
116 /* Start the critical section */
117
118 spin_lock_irqsave(&lock, iflags);
119
120 if (op->mode == AES_MODE_CBC) {
121 flags |= AES_CTRL_CBC;
122 _writefield(AES_WRITEIV0_REG, op->iv);
123 }
124
125 if (op->flags & AES_FLAGS_USRKEY) {
126 flags |= AES_CTRL_WRKEY;
127 _writefield(AES_WRITEKEY0_REG, op->key);
128 }
129
130 do_crypt(op->src, op->dst, op->len, flags);
131
132 if (op->mode == AES_MODE_CBC)
133 _readfield(AES_WRITEIV0_REG, op->iv);
134
135 spin_unlock_irqrestore(&lock, iflags);
136
137 return op->len;
138}
139
140/* CRYPTO-API Functions */
141
142static int
143geode_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int len)
144{
145 struct geode_aes_op *op = crypto_tfm_ctx(tfm);
146
147 if (len != AES_KEY_LENGTH) {
148 tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
149 return -EINVAL;
150 }
151
152 memcpy(op->key, key, len);
153 return 0;
154}
155
156static void
157geode_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
158{
159 struct geode_aes_op *op = crypto_tfm_ctx(tfm);
160
161 if ((out == NULL) || (in == NULL))
162 return;
163
164 op->src = (void *) in;
165 op->dst = (void *) out;
166 op->mode = AES_MODE_ECB;
167 op->flags = 0;
168 op->len = AES_MIN_BLOCK_SIZE;
169 op->dir = AES_DIR_ENCRYPT;
170
171 geode_aes_crypt(op);
172}
173
174
175static void
176geode_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
177{
178 struct geode_aes_op *op = crypto_tfm_ctx(tfm);
179
180 if ((out == NULL) || (in == NULL))
181 return;
182
183 op->src = (void *) in;
184 op->dst = (void *) out;
185 op->mode = AES_MODE_ECB;
186 op->flags = 0;
187 op->len = AES_MIN_BLOCK_SIZE;
188 op->dir = AES_DIR_DECRYPT;
189
190 geode_aes_crypt(op);
191}
192
193
194static struct crypto_alg geode_alg = {
195 .cra_name = "aes",
196 .cra_driver_name = "geode-aes-128",
197 .cra_priority = 300,
198 .cra_alignmask = 15,
199 .cra_flags = CRYPTO_ALG_TYPE_CIPHER,
200 .cra_blocksize = AES_MIN_BLOCK_SIZE,
201 .cra_ctxsize = sizeof(struct geode_aes_op),
202 .cra_module = THIS_MODULE,
203 .cra_list = LIST_HEAD_INIT(geode_alg.cra_list),
204 .cra_u = {
205 .cipher = {
206 .cia_min_keysize = AES_KEY_LENGTH,
207 .cia_max_keysize = AES_KEY_LENGTH,
208 .cia_setkey = geode_setkey,
209 .cia_encrypt = geode_encrypt,
210 .cia_decrypt = geode_decrypt
211 }
212 }
213};
214
215static int
216geode_cbc_decrypt(struct blkcipher_desc *desc,
217 struct scatterlist *dst, struct scatterlist *src,
218 unsigned int nbytes)
219{
220 struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
221 struct blkcipher_walk walk;
222 int err, ret;
223
224 blkcipher_walk_init(&walk, dst, src, nbytes);
225 err = blkcipher_walk_virt(desc, &walk);
226
227 while((nbytes = walk.nbytes)) {
228 op->src = walk.src.virt.addr,
229 op->dst = walk.dst.virt.addr;
230 op->mode = AES_MODE_CBC;
231 op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
232 op->dir = AES_DIR_DECRYPT;
233
234 memcpy(op->iv, walk.iv, AES_IV_LENGTH);
235
236 ret = geode_aes_crypt(op);
237
238 memcpy(walk.iv, op->iv, AES_IV_LENGTH);
239 nbytes -= ret;
240
241 err = blkcipher_walk_done(desc, &walk, nbytes);
242 }
243
244 return err;
245}
246
247static int
248geode_cbc_encrypt(struct blkcipher_desc *desc,
249 struct scatterlist *dst, struct scatterlist *src,
250 unsigned int nbytes)
251{
252 struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
253 struct blkcipher_walk walk;
254 int err, ret;
255
256 blkcipher_walk_init(&walk, dst, src, nbytes);
257 err = blkcipher_walk_virt(desc, &walk);
258
259 while((nbytes = walk.nbytes)) {
260 op->src = walk.src.virt.addr,
261 op->dst = walk.dst.virt.addr;
262 op->mode = AES_MODE_CBC;
263 op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
264 op->dir = AES_DIR_ENCRYPT;
265
266 memcpy(op->iv, walk.iv, AES_IV_LENGTH);
267
268 ret = geode_aes_crypt(op);
269 nbytes -= ret;
270 err = blkcipher_walk_done(desc, &walk, nbytes);
271 }
272
273 return err;
274}
275
276static struct crypto_alg geode_cbc_alg = {
277 .cra_name = "cbc(aes)",
278 .cra_driver_name = "cbc-aes-geode-128",
279 .cra_priority = 400,
280 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
281 .cra_blocksize = AES_MIN_BLOCK_SIZE,
282 .cra_ctxsize = sizeof(struct geode_aes_op),
283 .cra_alignmask = 15,
284 .cra_type = &crypto_blkcipher_type,
285 .cra_module = THIS_MODULE,
286 .cra_list = LIST_HEAD_INIT(geode_cbc_alg.cra_list),
287 .cra_u = {
288 .blkcipher = {
289 .min_keysize = AES_KEY_LENGTH,
290 .max_keysize = AES_KEY_LENGTH,
291 .setkey = geode_setkey,
292 .encrypt = geode_cbc_encrypt,
293 .decrypt = geode_cbc_decrypt,
294 }
295 }
296};
297
298static int
299geode_ecb_decrypt(struct blkcipher_desc *desc,
300 struct scatterlist *dst, struct scatterlist *src,
301 unsigned int nbytes)
302{
303 struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
304 struct blkcipher_walk walk;
305 int err, ret;
306
307 blkcipher_walk_init(&walk, dst, src, nbytes);
308 err = blkcipher_walk_virt(desc, &walk);
309
310 while((nbytes = walk.nbytes)) {
311 op->src = walk.src.virt.addr,
312 op->dst = walk.dst.virt.addr;
313 op->mode = AES_MODE_ECB;
314 op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
315 op->dir = AES_DIR_DECRYPT;
316
317 ret = geode_aes_crypt(op);
318 nbytes -= ret;
319 err = blkcipher_walk_done(desc, &walk, nbytes);
320 }
321
322 return err;
323}
324
325static int
326geode_ecb_encrypt(struct blkcipher_desc *desc,
327 struct scatterlist *dst, struct scatterlist *src,
328 unsigned int nbytes)
329{
330 struct geode_aes_op *op = crypto_blkcipher_ctx(desc->tfm);
331 struct blkcipher_walk walk;
332 int err, ret;
333
334 blkcipher_walk_init(&walk, dst, src, nbytes);
335 err = blkcipher_walk_virt(desc, &walk);
336
337 while((nbytes = walk.nbytes)) {
338 op->src = walk.src.virt.addr,
339 op->dst = walk.dst.virt.addr;
340 op->mode = AES_MODE_ECB;
341 op->len = nbytes - (nbytes % AES_MIN_BLOCK_SIZE);
342 op->dir = AES_DIR_ENCRYPT;
343
344 ret = geode_aes_crypt(op);
345 nbytes -= ret;
346 ret = blkcipher_walk_done(desc, &walk, nbytes);
347 }
348
349 return err;
350}
351
352static struct crypto_alg geode_ecb_alg = {
353 .cra_name = "ecb(aes)",
354 .cra_driver_name = "ecb-aes-geode-128",
355 .cra_priority = 400,
356 .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER,
357 .cra_blocksize = AES_MIN_BLOCK_SIZE,
358 .cra_ctxsize = sizeof(struct geode_aes_op),
359 .cra_alignmask = 15,
360 .cra_type = &crypto_blkcipher_type,
361 .cra_module = THIS_MODULE,
362 .cra_list = LIST_HEAD_INIT(geode_ecb_alg.cra_list),
363 .cra_u = {
364 .blkcipher = {
365 .min_keysize = AES_KEY_LENGTH,
366 .max_keysize = AES_KEY_LENGTH,
367 .setkey = geode_setkey,
368 .encrypt = geode_ecb_encrypt,
369 .decrypt = geode_ecb_decrypt,
370 }
371 }
372};
373
374static void
375geode_aes_remove(struct pci_dev *dev)
376{
377 crypto_unregister_alg(&geode_alg);
378 crypto_unregister_alg(&geode_ecb_alg);
379 crypto_unregister_alg(&geode_cbc_alg);
380
381 pci_iounmap(dev, _iobase);
382 _iobase = NULL;
383
384 pci_release_regions(dev);
385 pci_disable_device(dev);
386}
387
388
389static int
390geode_aes_probe(struct pci_dev *dev, const struct pci_device_id *id)
391{
392 int ret;
393
394 if ((ret = pci_enable_device(dev)))
395 return ret;
396
397 if ((ret = pci_request_regions(dev, "geode-aes-128")))
398 goto eenable;
399
400 _iobase = pci_iomap(dev, 0, 0);
401
402 if (_iobase == NULL) {
403 ret = -ENOMEM;
404 goto erequest;
405 }
406
407 spin_lock_init(&lock);
408
409 /* Clear any pending activity */
410 iowrite32(AES_INTR_PENDING | AES_INTR_MASK, _iobase + AES_INTR_REG);
411
412 if ((ret = crypto_register_alg(&geode_alg)))
413 goto eiomap;
414
415 if ((ret = crypto_register_alg(&geode_ecb_alg)))
416 goto ealg;
417
418 if ((ret = crypto_register_alg(&geode_cbc_alg)))
419 goto eecb;
420
421 printk(KERN_NOTICE "geode-aes: GEODE AES engine enabled.\n");
422 return 0;
423
424 eecb:
425 crypto_unregister_alg(&geode_ecb_alg);
426
427 ealg:
428 crypto_unregister_alg(&geode_alg);
429
430 eiomap:
431 pci_iounmap(dev, _iobase);
432
433 erequest:
434 pci_release_regions(dev);
435
436 eenable:
437 pci_disable_device(dev);
438
439 printk(KERN_ERR "geode-aes: GEODE AES initialization failed.\n");
440 return ret;
441}
442
443static struct pci_device_id geode_aes_tbl[] = {
444 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_AES, PCI_ANY_ID, PCI_ANY_ID} ,
445 { 0, }
446};
447
448MODULE_DEVICE_TABLE(pci, geode_aes_tbl);
449
450static struct pci_driver geode_aes_driver = {
451 .name = "Geode LX AES",
452 .id_table = geode_aes_tbl,
453 .probe = geode_aes_probe,
454 .remove = __devexit_p(geode_aes_remove)
455};
456
457static int __init
458geode_aes_init(void)
459{
460 return pci_module_init(&geode_aes_driver);
461}
462
463static void __exit
464geode_aes_exit(void)
465{
466 pci_unregister_driver(&geode_aes_driver);
467}
468
469MODULE_AUTHOR("Advanced Micro Devices, Inc.");
470MODULE_DESCRIPTION("Geode LX Hardware AES driver");
471MODULE_LICENSE("GPL");
472
473module_init(geode_aes_init);
474module_exit(geode_aes_exit);
diff --git a/drivers/crypto/geode-aes.h b/drivers/crypto/geode-aes.h
new file mode 100644
index 000000000000..8003a36f3a83
--- /dev/null
+++ b/drivers/crypto/geode-aes.h
@@ -0,0 +1,40 @@
1/* Copyright (C) 2003-2006, Advanced Micro Devices, Inc.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 */
8
9#ifndef _GEODE_AES_H_
10#define _GEODE_AES_H_
11
12#define AES_KEY_LENGTH 16
13#define AES_IV_LENGTH 16
14
15#define AES_MIN_BLOCK_SIZE 16
16
17#define AES_MODE_ECB 0
18#define AES_MODE_CBC 1
19
20#define AES_DIR_DECRYPT 0
21#define AES_DIR_ENCRYPT 1
22
23#define AES_FLAGS_USRKEY (1 << 0)
24#define AES_FLAGS_COHERENT (1 << 1)
25
26struct geode_aes_op {
27
28 void *src;
29 void *dst;
30
31 u32 mode;
32 u32 dir;
33 u32 flags;
34 int len;
35
36 u8 key[AES_KEY_LENGTH];
37 u8 iv[AES_IV_LENGTH];
38};
39
40#endif
diff --git a/drivers/dma/ioatdma.c b/drivers/dma/ioatdma.c
index 0358419a0e48..8e8726104619 100644
--- a/drivers/dma/ioatdma.c
+++ b/drivers/dma/ioatdma.c
@@ -636,10 +636,10 @@ static int ioat_self_test(struct ioat_device *device)
636 dma_cookie_t cookie; 636 dma_cookie_t cookie;
637 int err = 0; 637 int err = 0;
638 638
639 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL); 639 src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
640 if (!src) 640 if (!src)
641 return -ENOMEM; 641 return -ENOMEM;
642 dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, SLAB_KERNEL); 642 dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
643 if (!dest) { 643 if (!dest) {
644 kfree(src); 644 kfree(src);
645 return -ENOMEM; 645 return -ENOMEM;
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index 75e9e38330ff..1b4fc9221803 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -28,6 +28,7 @@
28#include <linux/sysdev.h> 28#include <linux/sysdev.h>
29#include <linux/ctype.h> 29#include <linux/ctype.h>
30#include <linux/kthread.h> 30#include <linux/kthread.h>
31#include <linux/freezer.h>
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/page.h> 33#include <asm/page.h>
33#include <asm/edac.h> 34#include <asm/edac.h>
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 0c68d0f0d8e5..e23bc0d62159 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -389,14 +389,6 @@ config BLK_DEV_RZ1000
389 Linux. This may slow disk throughput by a few percent, but at least 389 Linux. This may slow disk throughput by a few percent, but at least
390 things will operate 100% reliably. 390 things will operate 100% reliably.
391 391
392config BLK_DEV_SL82C105
393 tristate "Winbond SL82c105 support"
394 depends on PCI && (PPC || ARM) && BLK_DEV_IDEPCI
395 help
396 If you have a Winbond SL82c105 IDE controller, say Y here to enable
397 special configuration for this chip. This is common on various CHRP
398 motherboards, but could be used elsewhere. If in doubt, say Y.
399
400config BLK_DEV_IDEDMA_PCI 392config BLK_DEV_IDEDMA_PCI
401 bool "Generic PCI bus-master DMA support" 393 bool "Generic PCI bus-master DMA support"
402 depends on PCI && BLK_DEV_IDEPCI 394 depends on PCI && BLK_DEV_IDEPCI
@@ -712,6 +704,14 @@ config BLK_DEV_SIS5513
712 704
713 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>. 705 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>.
714 706
707config BLK_DEV_SL82C105
708 tristate "Winbond SL82c105 support"
709 depends on (PPC || ARM)
710 help
711 If you have a Winbond SL82c105 IDE controller, say Y here to enable
712 special configuration for this chip. This is common on various CHRP
713 motherboards, but could be used elsewhere. If in doubt, say Y.
714
715config BLK_DEV_SLC90E66 715config BLK_DEV_SLC90E66
716 tristate "SLC90E66 chipset support" 716 tristate "SLC90E66 chipset support"
717 help 717 help
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 287a66201150..16890769dca6 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -973,8 +973,8 @@ ide_settings_t *ide_find_setting_by_name (ide_drive_t *drive, char *name)
973 * @drive: drive 973 * @drive: drive
974 * 974 *
975 * Automatically remove all the driver specific settings for this 975 * Automatically remove all the driver specific settings for this
976 * drive. This function may sleep and must not be called from IRQ 976 * drive. This function may not be called from IRQ context. The
977 * context. The caller must hold ide_setting_sem. 977 * caller must hold ide_setting_sem.
978 */ 978 */
979 979
980static void auto_remove_settings (ide_drive_t *drive) 980static void auto_remove_settings (ide_drive_t *drive)
@@ -1874,11 +1874,22 @@ void ide_unregister_subdriver(ide_drive_t *drive, ide_driver_t *driver)
1874{ 1874{
1875 unsigned long flags; 1875 unsigned long flags;
1876 1876
1877 down(&ide_setting_sem);
1878 spin_lock_irqsave(&ide_lock, flags);
1879#ifdef CONFIG_PROC_FS 1877#ifdef CONFIG_PROC_FS
1880 ide_remove_proc_entries(drive->proc, driver->proc); 1878 ide_remove_proc_entries(drive->proc, driver->proc);
1881#endif 1879#endif
1880 down(&ide_setting_sem);
1881 spin_lock_irqsave(&ide_lock, flags);
1882 /*
1883 * ide_setting_sem protects the settings list
1884 * ide_lock protects the use of settings
1885 *
1886 * so we need to hold both, ide_settings_sem because we want to
1887 * modify the settings list, and ide_lock because we cannot take
1888 * a setting out that is being used.
1889 *
1890 * OTOH both ide_{read,write}_setting are only ever used under
1891 * ide_setting_sem.
1892 */
1882 auto_remove_settings(drive); 1893 auto_remove_settings(drive);
1883 spin_unlock_irqrestore(&ide_lock, flags); 1894 spin_unlock_irqrestore(&ide_lock, flags);
1884 up(&ide_setting_sem); 1895 up(&ide_setting_sem);
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index eb7ab112c050..61f1a9665a7f 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -282,11 +282,11 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
282 * Find the ISA bridge to see how good the IDE is. 282 * Find the ISA bridge to see how good the IDE is.
283 */ 283 */
284 via_config = via_config_find(&isa); 284 via_config = via_config_find(&isa);
285 if (!via_config->id) { 285
286 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); 286 /* We checked this earlier so if it fails here deeep badness
287 pci_dev_put(isa); 287 is involved */
288 return -ENODEV; 288
289 } 289 BUG_ON(!via_config->id);
290 290
291 /* 291 /*
292 * Setup or disable Clk66 if appropriate 292 * Setup or disable Clk66 if appropriate
@@ -494,6 +494,17 @@ static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
494 494
495static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id) 495static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
496{ 496{
497 struct pci_dev *isa = NULL;
498 struct via_isa_bridge *via_config;
499 /*
500 * Find the ISA bridge and check we know what it is.
501 */
502 via_config = via_config_find(&isa);
503 pci_dev_put(isa);
504 if (!via_config->id) {
505 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n");
506 return -ENODEV;
507 }
497 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]); 508 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]);
498} 509}
499 510
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 31e5cc49d61a..27d6c642415d 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -133,7 +133,7 @@ struct eth1394_node_info {
133#define ETH1394_DRIVER_NAME "eth1394" 133#define ETH1394_DRIVER_NAME "eth1394"
134static const char driver_name[] = ETH1394_DRIVER_NAME; 134static const char driver_name[] = ETH1394_DRIVER_NAME;
135 135
136static kmem_cache_t *packet_task_cache; 136static struct kmem_cache *packet_task_cache;
137 137
138static struct hpsb_highlevel eth1394_highlevel; 138static struct hpsb_highlevel eth1394_highlevel;
139 139
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index 8f4378a1631c..b935e08695a9 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -123,7 +123,7 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
123 int i; 123 int i;
124 int hostnum = 0; 124 int hostnum = 0;
125 125
126 h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); 126 h = kzalloc(sizeof(*h) + extra, GFP_KERNEL);
127 if (!h) 127 if (!h)
128 return NULL; 128 return NULL;
129 129
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 8e7b83f84485..e829c9336b3c 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -15,6 +15,7 @@
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/kthread.h> 16#include <linux/kthread.h>
17#include <linux/moduleparam.h> 17#include <linux/moduleparam.h>
18#include <linux/freezer.h>
18#include <asm/atomic.h> 19#include <asm/atomic.h>
19 20
20#include "csr.h" 21#include "csr.h"
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 6e8ea9110c46..eae97d8dcf03 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -1225,7 +1225,7 @@ static int ohci_iso_recv_init(struct hpsb_iso *iso)
1225 int ctx; 1225 int ctx;
1226 int ret = -ENOMEM; 1226 int ret = -ENOMEM;
1227 1227
1228 recv = kmalloc(sizeof(*recv), SLAB_KERNEL); 1228 recv = kmalloc(sizeof(*recv), GFP_KERNEL);
1229 if (!recv) 1229 if (!recv)
1230 return -ENOMEM; 1230 return -ENOMEM;
1231 1231
@@ -1918,7 +1918,7 @@ static int ohci_iso_xmit_init(struct hpsb_iso *iso)
1918 int ctx; 1918 int ctx;
1919 int ret = -ENOMEM; 1919 int ret = -ENOMEM;
1920 1920
1921 xmit = kmalloc(sizeof(*xmit), SLAB_KERNEL); 1921 xmit = kmalloc(sizeof(*xmit), GFP_KERNEL);
1922 if (!xmit) 1922 if (!xmit)
1923 return -ENOMEM; 1923 return -ENOMEM;
1924 1924
@@ -3021,7 +3021,7 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
3021 return -ENOMEM; 3021 return -ENOMEM;
3022 } 3022 }
3023 3023
3024 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i); 3024 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i);
3025 OHCI_DMA_ALLOC("pool dma_rcv prg[%d]", i); 3025 OHCI_DMA_ALLOC("pool dma_rcv prg[%d]", i);
3026 3026
3027 if (d->prg_cpu[i] != NULL) { 3027 if (d->prg_cpu[i] != NULL) {
@@ -3117,7 +3117,7 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
3117 OHCI_DMA_ALLOC("dma_rcv prg pool"); 3117 OHCI_DMA_ALLOC("dma_rcv prg pool");
3118 3118
3119 for (i = 0; i < d->num_desc; i++) { 3119 for (i = 0; i < d->num_desc; i++) {
3120 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, SLAB_KERNEL, d->prg_bus+i); 3120 d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i);
3121 OHCI_DMA_ALLOC("pool dma_trm prg[%d]", i); 3121 OHCI_DMA_ALLOC("pool dma_trm prg[%d]", i);
3122 3122
3123 if (d->prg_cpu[i] != NULL) { 3123 if (d->prg_cpu[i] != NULL) {
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index 0a7412e27eb4..9cab1d661472 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -1428,7 +1428,7 @@ static int __devinit add_card(struct pci_dev *dev,
1428 struct i2c_algo_bit_data i2c_adapter_data; 1428 struct i2c_algo_bit_data i2c_adapter_data;
1429 1429
1430 error = -ENOMEM; 1430 error = -ENOMEM;
1431 i2c_ad = kmalloc(sizeof(*i2c_ad), SLAB_KERNEL); 1431 i2c_ad = kmalloc(sizeof(*i2c_ad), GFP_KERNEL);
1432 if (!i2c_ad) FAIL("failed to allocate I2C adapter memory"); 1432 if (!i2c_ad) FAIL("failed to allocate I2C adapter memory");
1433 1433
1434 memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter)); 1434 memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter));
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 5ec4f5eb6b19..bf71e069eaf5 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -112,7 +112,7 @@ static struct pending_request *__alloc_pending_request(gfp_t flags)
112 112
113static inline struct pending_request *alloc_pending_request(void) 113static inline struct pending_request *alloc_pending_request(void)
114{ 114{
115 return __alloc_pending_request(SLAB_KERNEL); 115 return __alloc_pending_request(GFP_KERNEL);
116} 116}
117 117
118static void free_pending_request(struct pending_request *req) 118static void free_pending_request(struct pending_request *req)
@@ -259,7 +259,7 @@ static void host_reset(struct hpsb_host *host)
259 if (hi != NULL) { 259 if (hi != NULL) {
260 list_for_each_entry(fi, &hi->file_info_list, list) { 260 list_for_each_entry(fi, &hi->file_info_list, list) {
261 if (fi->notification == RAW1394_NOTIFY_ON) { 261 if (fi->notification == RAW1394_NOTIFY_ON) {
262 req = __alloc_pending_request(SLAB_ATOMIC); 262 req = __alloc_pending_request(GFP_ATOMIC);
263 263
264 if (req != NULL) { 264 if (req != NULL) {
265 req->file_info = fi; 265 req->file_info = fi;
@@ -306,13 +306,13 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t * data,
306 if (!(fi->listen_channels & (1ULL << channel))) 306 if (!(fi->listen_channels & (1ULL << channel)))
307 continue; 307 continue;
308 308
309 req = __alloc_pending_request(SLAB_ATOMIC); 309 req = __alloc_pending_request(GFP_ATOMIC);
310 if (!req) 310 if (!req)
311 break; 311 break;
312 312
313 if (!ibs) { 313 if (!ibs) {
314 ibs = kmalloc(sizeof(*ibs) + length, 314 ibs = kmalloc(sizeof(*ibs) + length,
315 SLAB_ATOMIC); 315 GFP_ATOMIC);
316 if (!ibs) { 316 if (!ibs) {
317 kfree(req); 317 kfree(req);
318 break; 318 break;
@@ -367,13 +367,13 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
367 if (!fi->fcp_buffer) 367 if (!fi->fcp_buffer)
368 continue; 368 continue;
369 369
370 req = __alloc_pending_request(SLAB_ATOMIC); 370 req = __alloc_pending_request(GFP_ATOMIC);
371 if (!req) 371 if (!req)
372 break; 372 break;
373 373
374 if (!ibs) { 374 if (!ibs) {
375 ibs = kmalloc(sizeof(*ibs) + length, 375 ibs = kmalloc(sizeof(*ibs) + length,
376 SLAB_ATOMIC); 376 GFP_ATOMIC);
377 if (!ibs) { 377 if (!ibs) {
378 kfree(req); 378 kfree(req);
379 break; 379 break;
@@ -593,7 +593,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
593 switch (req->req.type) { 593 switch (req->req.type) {
594 case RAW1394_REQ_LIST_CARDS: 594 case RAW1394_REQ_LIST_CARDS:
595 spin_lock_irqsave(&host_info_lock, flags); 595 spin_lock_irqsave(&host_info_lock, flags);
596 khl = kmalloc(sizeof(*khl) * host_count, SLAB_ATOMIC); 596 khl = kmalloc(sizeof(*khl) * host_count, GFP_ATOMIC);
597 597
598 if (khl) { 598 if (khl) {
599 req->req.misc = host_count; 599 req->req.misc = host_count;
@@ -1045,7 +1045,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
1045 } 1045 }
1046 if (arm_addr->notification_options & ARM_READ) { 1046 if (arm_addr->notification_options & ARM_READ) {
1047 DBGMSG("arm_read -> entering notification-section"); 1047 DBGMSG("arm_read -> entering notification-section");
1048 req = __alloc_pending_request(SLAB_ATOMIC); 1048 req = __alloc_pending_request(GFP_ATOMIC);
1049 if (!req) { 1049 if (!req) {
1050 DBGMSG("arm_read -> rcode_conflict_error"); 1050 DBGMSG("arm_read -> rcode_conflict_error");
1051 spin_unlock_irqrestore(&host_info_lock, irqflags); 1051 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1064,7 +1064,7 @@ static int arm_read(struct hpsb_host *host, int nodeid, quadlet_t * buffer,
1064 sizeof(struct arm_response) + 1064 sizeof(struct arm_response) +
1065 sizeof(struct arm_request_response); 1065 sizeof(struct arm_request_response);
1066 } 1066 }
1067 req->data = kmalloc(size, SLAB_ATOMIC); 1067 req->data = kmalloc(size, GFP_ATOMIC);
1068 if (!(req->data)) { 1068 if (!(req->data)) {
1069 free_pending_request(req); 1069 free_pending_request(req);
1070 DBGMSG("arm_read -> rcode_conflict_error"); 1070 DBGMSG("arm_read -> rcode_conflict_error");
@@ -1198,7 +1198,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1198 } 1198 }
1199 if (arm_addr->notification_options & ARM_WRITE) { 1199 if (arm_addr->notification_options & ARM_WRITE) {
1200 DBGMSG("arm_write -> entering notification-section"); 1200 DBGMSG("arm_write -> entering notification-section");
1201 req = __alloc_pending_request(SLAB_ATOMIC); 1201 req = __alloc_pending_request(GFP_ATOMIC);
1202 if (!req) { 1202 if (!req) {
1203 DBGMSG("arm_write -> rcode_conflict_error"); 1203 DBGMSG("arm_write -> rcode_conflict_error");
1204 spin_unlock_irqrestore(&host_info_lock, irqflags); 1204 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1209,7 +1209,7 @@ static int arm_write(struct hpsb_host *host, int nodeid, int destid,
1209 sizeof(struct arm_request) + sizeof(struct arm_response) + 1209 sizeof(struct arm_request) + sizeof(struct arm_response) +
1210 (length) * sizeof(byte_t) + 1210 (length) * sizeof(byte_t) +
1211 sizeof(struct arm_request_response); 1211 sizeof(struct arm_request_response);
1212 req->data = kmalloc(size, SLAB_ATOMIC); 1212 req->data = kmalloc(size, GFP_ATOMIC);
1213 if (!(req->data)) { 1213 if (!(req->data)) {
1214 free_pending_request(req); 1214 free_pending_request(req);
1215 DBGMSG("arm_write -> rcode_conflict_error"); 1215 DBGMSG("arm_write -> rcode_conflict_error");
@@ -1400,7 +1400,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1400 if (arm_addr->notification_options & ARM_LOCK) { 1400 if (arm_addr->notification_options & ARM_LOCK) {
1401 byte_t *buf1, *buf2; 1401 byte_t *buf1, *buf2;
1402 DBGMSG("arm_lock -> entering notification-section"); 1402 DBGMSG("arm_lock -> entering notification-section");
1403 req = __alloc_pending_request(SLAB_ATOMIC); 1403 req = __alloc_pending_request(GFP_ATOMIC);
1404 if (!req) { 1404 if (!req) {
1405 DBGMSG("arm_lock -> rcode_conflict_error"); 1405 DBGMSG("arm_lock -> rcode_conflict_error");
1406 spin_unlock_irqrestore(&host_info_lock, irqflags); 1406 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1408,7 +1408,7 @@ static int arm_lock(struct hpsb_host *host, int nodeid, quadlet_t * store,
1408 The request may be retried */ 1408 The request may be retried */
1409 } 1409 }
1410 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */ 1410 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */
1411 req->data = kmalloc(size, SLAB_ATOMIC); 1411 req->data = kmalloc(size, GFP_ATOMIC);
1412 if (!(req->data)) { 1412 if (!(req->data)) {
1413 free_pending_request(req); 1413 free_pending_request(req);
1414 DBGMSG("arm_lock -> rcode_conflict_error"); 1414 DBGMSG("arm_lock -> rcode_conflict_error");
@@ -1628,7 +1628,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1628 if (arm_addr->notification_options & ARM_LOCK) { 1628 if (arm_addr->notification_options & ARM_LOCK) {
1629 byte_t *buf1, *buf2; 1629 byte_t *buf1, *buf2;
1630 DBGMSG("arm_lock64 -> entering notification-section"); 1630 DBGMSG("arm_lock64 -> entering notification-section");
1631 req = __alloc_pending_request(SLAB_ATOMIC); 1631 req = __alloc_pending_request(GFP_ATOMIC);
1632 if (!req) { 1632 if (!req) {
1633 spin_unlock_irqrestore(&host_info_lock, irqflags); 1633 spin_unlock_irqrestore(&host_info_lock, irqflags);
1634 DBGMSG("arm_lock64 -> rcode_conflict_error"); 1634 DBGMSG("arm_lock64 -> rcode_conflict_error");
@@ -1636,7 +1636,7 @@ static int arm_lock64(struct hpsb_host *host, int nodeid, octlet_t * store,
1636 The request may be retried */ 1636 The request may be retried */
1637 } 1637 }
1638 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */ 1638 size = sizeof(struct arm_request) + sizeof(struct arm_response) + 3 * sizeof(*store) + sizeof(struct arm_request_response); /* maximum */
1639 req->data = kmalloc(size, SLAB_ATOMIC); 1639 req->data = kmalloc(size, GFP_ATOMIC);
1640 if (!(req->data)) { 1640 if (!(req->data)) {
1641 free_pending_request(req); 1641 free_pending_request(req);
1642 spin_unlock_irqrestore(&host_info_lock, irqflags); 1642 spin_unlock_irqrestore(&host_info_lock, irqflags);
@@ -1737,7 +1737,7 @@ static int arm_register(struct file_info *fi, struct pending_request *req)
1737 return (-EINVAL); 1737 return (-EINVAL);
1738 } 1738 }
1739 /* addr-list-entry for fileinfo */ 1739 /* addr-list-entry for fileinfo */
1740 addr = kmalloc(sizeof(*addr), SLAB_KERNEL); 1740 addr = kmalloc(sizeof(*addr), GFP_KERNEL);
1741 if (!addr) { 1741 if (!addr) {
1742 req->req.length = 0; 1742 req->req.length = 0;
1743 return (-ENOMEM); 1743 return (-ENOMEM);
@@ -2103,7 +2103,7 @@ static int write_phypacket(struct file_info *fi, struct pending_request *req)
2103static int get_config_rom(struct file_info *fi, struct pending_request *req) 2103static int get_config_rom(struct file_info *fi, struct pending_request *req)
2104{ 2104{
2105 int ret = sizeof(struct raw1394_request); 2105 int ret = sizeof(struct raw1394_request);
2106 quadlet_t *data = kmalloc(req->req.length, SLAB_KERNEL); 2106 quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
2107 int status; 2107 int status;
2108 2108
2109 if (!data) 2109 if (!data)
@@ -2133,7 +2133,7 @@ static int get_config_rom(struct file_info *fi, struct pending_request *req)
2133static int update_config_rom(struct file_info *fi, struct pending_request *req) 2133static int update_config_rom(struct file_info *fi, struct pending_request *req)
2134{ 2134{
2135 int ret = sizeof(struct raw1394_request); 2135 int ret = sizeof(struct raw1394_request);
2136 quadlet_t *data = kmalloc(req->req.length, SLAB_KERNEL); 2136 quadlet_t *data = kmalloc(req->req.length, GFP_KERNEL);
2137 if (!data) 2137 if (!data)
2138 return -ENOMEM; 2138 return -ENOMEM;
2139 if (copy_from_user(data, int2ptr(req->req.sendb), req->req.length)) { 2139 if (copy_from_user(data, int2ptr(req->req.sendb), req->req.length)) {
@@ -2443,7 +2443,7 @@ static void queue_rawiso_event(struct file_info *fi)
2443 /* only one ISO activity event may be in the queue */ 2443 /* only one ISO activity event may be in the queue */
2444 if (!__rawiso_event_in_queue(fi)) { 2444 if (!__rawiso_event_in_queue(fi)) {
2445 struct pending_request *req = 2445 struct pending_request *req =
2446 __alloc_pending_request(SLAB_ATOMIC); 2446 __alloc_pending_request(GFP_ATOMIC);
2447 2447
2448 if (req) { 2448 if (req) {
2449 req->file_info = fi; 2449 req->file_info = fi;
@@ -2779,7 +2779,7 @@ static int raw1394_open(struct inode *inode, struct file *file)
2779{ 2779{
2780 struct file_info *fi; 2780 struct file_info *fi;
2781 2781
2782 fi = kzalloc(sizeof(*fi), SLAB_KERNEL); 2782 fi = kzalloc(sizeof(*fi), GFP_KERNEL);
2783 if (!fi) 2783 if (!fi)
2784 return -ENOMEM; 2784 return -ENOMEM;
2785 2785
diff --git a/drivers/infiniband/hw/amso1100/c2_vq.c b/drivers/infiniband/hw/amso1100/c2_vq.c
index 40caeb5f41b4..36620a22413c 100644
--- a/drivers/infiniband/hw/amso1100/c2_vq.c
+++ b/drivers/infiniband/hw/amso1100/c2_vq.c
@@ -164,7 +164,7 @@ void vq_req_put(struct c2_dev *c2dev, struct c2_vq_req *r)
164 */ 164 */
165void *vq_repbuf_alloc(struct c2_dev *c2dev) 165void *vq_repbuf_alloc(struct c2_dev *c2dev)
166{ 166{
167 return kmem_cache_alloc(c2dev->host_msg_cache, SLAB_ATOMIC); 167 return kmem_cache_alloc(c2dev->host_msg_cache, GFP_ATOMIC);
168} 168}
169 169
170/* 170/*
diff --git a/drivers/infiniband/hw/ehca/ehca_av.c b/drivers/infiniband/hw/ehca/ehca_av.c
index 214e2fdddeef..0d6e2c4bb245 100644
--- a/drivers/infiniband/hw/ehca/ehca_av.c
+++ b/drivers/infiniband/hw/ehca/ehca_av.c
@@ -57,7 +57,7 @@ struct ib_ah *ehca_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
57 struct ehca_shca *shca = container_of(pd->device, struct ehca_shca, 57 struct ehca_shca *shca = container_of(pd->device, struct ehca_shca,
58 ib_device); 58 ib_device);
59 59
60 av = kmem_cache_alloc(av_cache, SLAB_KERNEL); 60 av = kmem_cache_alloc(av_cache, GFP_KERNEL);
61 if (!av) { 61 if (!av) {
62 ehca_err(pd->device, "Out of memory pd=%p ah_attr=%p", 62 ehca_err(pd->device, "Out of memory pd=%p ah_attr=%p",
63 pd, ah_attr); 63 pd, ah_attr);
diff --git a/drivers/infiniband/hw/ehca/ehca_cq.c b/drivers/infiniband/hw/ehca/ehca_cq.c
index 458fe19648a1..93995b658d94 100644
--- a/drivers/infiniband/hw/ehca/ehca_cq.c
+++ b/drivers/infiniband/hw/ehca/ehca_cq.c
@@ -134,7 +134,7 @@ struct ib_cq *ehca_create_cq(struct ib_device *device, int cqe,
134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe) 134 if (cqe >= 0xFFFFFFFF - 64 - additional_cqe)
135 return ERR_PTR(-EINVAL); 135 return ERR_PTR(-EINVAL);
136 136
137 my_cq = kmem_cache_alloc(cq_cache, SLAB_KERNEL); 137 my_cq = kmem_cache_alloc(cq_cache, GFP_KERNEL);
138 if (!my_cq) { 138 if (!my_cq) {
139 ehca_err(device, "Out of memory for ehca_cq struct device=%p", 139 ehca_err(device, "Out of memory for ehca_cq struct device=%p",
140 device); 140 device);
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 3d1c1c535038..cc47e4c13a18 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -108,7 +108,7 @@ static struct kmem_cache *ctblk_cache = NULL;
108 108
109void *ehca_alloc_fw_ctrlblock(void) 109void *ehca_alloc_fw_ctrlblock(void)
110{ 110{
111 void *ret = kmem_cache_zalloc(ctblk_cache, SLAB_KERNEL); 111 void *ret = kmem_cache_zalloc(ctblk_cache, GFP_KERNEL);
112 if (!ret) 112 if (!ret)
113 ehca_gen_err("Out of memory for ctblk"); 113 ehca_gen_err("Out of memory for ctblk");
114 return ret; 114 return ret;
diff --git a/drivers/infiniband/hw/ehca/ehca_mrmw.c b/drivers/infiniband/hw/ehca/ehca_mrmw.c
index abce676c0ae0..0a5e2214cc5f 100644
--- a/drivers/infiniband/hw/ehca/ehca_mrmw.c
+++ b/drivers/infiniband/hw/ehca/ehca_mrmw.c
@@ -53,7 +53,7 @@ static struct ehca_mr *ehca_mr_new(void)
53{ 53{
54 struct ehca_mr *me; 54 struct ehca_mr *me;
55 55
56 me = kmem_cache_alloc(mr_cache, SLAB_KERNEL); 56 me = kmem_cache_alloc(mr_cache, GFP_KERNEL);
57 if (me) { 57 if (me) {
58 memset(me, 0, sizeof(struct ehca_mr)); 58 memset(me, 0, sizeof(struct ehca_mr));
59 spin_lock_init(&me->mrlock); 59 spin_lock_init(&me->mrlock);
@@ -72,7 +72,7 @@ static struct ehca_mw *ehca_mw_new(void)
72{ 72{
73 struct ehca_mw *me; 73 struct ehca_mw *me;
74 74
75 me = kmem_cache_alloc(mw_cache, SLAB_KERNEL); 75 me = kmem_cache_alloc(mw_cache, GFP_KERNEL);
76 if (me) { 76 if (me) {
77 memset(me, 0, sizeof(struct ehca_mw)); 77 memset(me, 0, sizeof(struct ehca_mw));
78 spin_lock_init(&me->mwlock); 78 spin_lock_init(&me->mwlock);
diff --git a/drivers/infiniband/hw/ehca/ehca_pd.c b/drivers/infiniband/hw/ehca/ehca_pd.c
index 2c3cdc6f7b39..d5345e5b3cd6 100644
--- a/drivers/infiniband/hw/ehca/ehca_pd.c
+++ b/drivers/infiniband/hw/ehca/ehca_pd.c
@@ -50,7 +50,7 @@ struct ib_pd *ehca_alloc_pd(struct ib_device *device,
50{ 50{
51 struct ehca_pd *pd; 51 struct ehca_pd *pd;
52 52
53 pd = kmem_cache_alloc(pd_cache, SLAB_KERNEL); 53 pd = kmem_cache_alloc(pd_cache, GFP_KERNEL);
54 if (!pd) { 54 if (!pd) {
55 ehca_err(device, "device=%p context=%p out of memory", 55 ehca_err(device, "device=%p context=%p out of memory",
56 device, context); 56 device, context);
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 8682aa50c707..c6c9cef203e3 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -450,7 +450,7 @@ struct ib_qp *ehca_create_qp(struct ib_pd *pd,
450 if (pd->uobject && udata) 450 if (pd->uobject && udata)
451 context = pd->uobject->context; 451 context = pd->uobject->context;
452 452
453 my_qp = kmem_cache_alloc(qp_cache, SLAB_KERNEL); 453 my_qp = kmem_cache_alloc(qp_cache, GFP_KERNEL);
454 if (!my_qp) { 454 if (!my_qp) {
455 ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd); 455 ehca_err(pd->device, "pd=%p not enough memory to alloc qp", pd);
456 return ERR_PTR(-ENOMEM); 456 return ERR_PTR(-ENOMEM);
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c
index 57cdc1bc5f50..27caf3b0648a 100644
--- a/drivers/infiniband/hw/mthca/mthca_av.c
+++ b/drivers/infiniband/hw/mthca/mthca_av.c
@@ -189,7 +189,7 @@ int mthca_create_ah(struct mthca_dev *dev,
189on_hca_fail: 189on_hca_fail:
190 if (ah->type == MTHCA_AH_PCI_POOL) { 190 if (ah->type == MTHCA_AH_PCI_POOL) {
191 ah->av = pci_pool_alloc(dev->av_table.pool, 191 ah->av = pci_pool_alloc(dev->av_table.pool,
192 SLAB_ATOMIC, &ah->avdma); 192 GFP_ATOMIC, &ah->avdma);
193 if (!ah->av) 193 if (!ah->av)
194 return -ENOMEM; 194 return -ENOMEM;
195 195
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index a0af97efe6ac..79dfb4b25c97 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -23,6 +23,7 @@
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/sched.h> /* HZ */ 24#include <linux/sched.h> /* HZ */
25#include <linux/mutex.h> 25#include <linux/mutex.h>
26#include <linux/freezer.h>
26 27
27/*#include <asm/io.h>*/ 28/*#include <asm/io.h>*/
28 29
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c
index ab4da79ee560..31d5a13bfd6b 100644
--- a/drivers/input/misc/hp_sdc_rtc.c
+++ b/drivers/input/misc/hp_sdc_rtc.c
@@ -695,7 +695,9 @@ static int __init hp_sdc_rtc_init(void)
695 695
696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr))) 696 if ((ret = hp_sdc_request_timer_irq(&hp_sdc_rtc_isr)))
697 return ret; 697 return ret;
698 misc_register(&hp_sdc_rtc_dev); 698 if (misc_register(&hp_sdc_rtc_dev) != 0)
699 printk(KERN_INFO "Could not register misc. dev for i8042 rtc\n");
700
699 create_proc_read_entry ("driver/rtc", 0, NULL, 701 create_proc_read_entry ("driver/rtc", 0, NULL,
700 hp_sdc_rtc_read_proc, NULL); 702 hp_sdc_rtc_read_proc, NULL);
701 703
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 211943f85cb6..5f1d4032fd57 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -35,6 +35,7 @@
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/mutex.h> 37#include <linux/mutex.h>
38#include <linux/freezer.h>
38 39
39MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 40MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
40MODULE_DESCRIPTION("Serio abstraction core"); 41MODULE_DESCRIPTION("Serio abstraction core");
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index f56d6a0f0624..0517c7387d67 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -189,7 +189,7 @@ static int ads7846_read12_ser(struct device *dev, unsigned command)
189{ 189{
190 struct spi_device *spi = to_spi_device(dev); 190 struct spi_device *spi = to_spi_device(dev);
191 struct ads7846 *ts = dev_get_drvdata(dev); 191 struct ads7846 *ts = dev_get_drvdata(dev);
192 struct ser_req *req = kzalloc(sizeof *req, SLAB_KERNEL); 192 struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL);
193 int status; 193 int status;
194 int sample; 194 int sample;
195 int i; 195 int i;
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 0c937325a1b3..63b629b1cdb2 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -572,7 +572,7 @@ static int atread_submit(struct cardstate *cs, int timeout)
572 ucs->rcvbuf, ucs->rcvbuf_size, 572 ucs->rcvbuf, ucs->rcvbuf_size,
573 read_ctrl_callback, cs->inbuf); 573 read_ctrl_callback, cs->inbuf);
574 574
575 if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) { 575 if ((ret = usb_submit_urb(ucs->urb_cmd_in, GFP_ATOMIC)) != 0) {
576 update_basstate(ucs, 0, BS_ATRDPEND); 576 update_basstate(ucs, 0, BS_ATRDPEND);
577 dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n", 577 dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n",
578 get_usb_rcmsg(ret)); 578 get_usb_rcmsg(ret));
@@ -747,7 +747,7 @@ static void read_int_callback(struct urb *urb)
747 check_pending(ucs); 747 check_pending(ucs);
748 748
749resubmit: 749resubmit:
750 rc = usb_submit_urb(urb, SLAB_ATOMIC); 750 rc = usb_submit_urb(urb, GFP_ATOMIC);
751 if (unlikely(rc != 0 && rc != -ENODEV)) { 751 if (unlikely(rc != 0 && rc != -ENODEV)) {
752 dev_err(cs->dev, "could not resubmit interrupt URB: %s\n", 752 dev_err(cs->dev, "could not resubmit interrupt URB: %s\n",
753 get_usb_rcmsg(rc)); 753 get_usb_rcmsg(rc));
@@ -807,7 +807,7 @@ static void read_iso_callback(struct urb *urb)
807 urb->number_of_packets = BAS_NUMFRAMES; 807 urb->number_of_packets = BAS_NUMFRAMES;
808 gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit", 808 gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit",
809 __func__); 809 __func__);
810 rc = usb_submit_urb(urb, SLAB_ATOMIC); 810 rc = usb_submit_urb(urb, GFP_ATOMIC);
811 if (unlikely(rc != 0 && rc != -ENODEV)) { 811 if (unlikely(rc != 0 && rc != -ENODEV)) {
812 dev_err(bcs->cs->dev, 812 dev_err(bcs->cs->dev,
813 "could not resubmit isochronous read " 813 "could not resubmit isochronous read "
@@ -900,7 +900,7 @@ static int starturbs(struct bc_state *bcs)
900 } 900 }
901 901
902 dump_urb(DEBUG_ISO, "Initial isoc read", urb); 902 dump_urb(DEBUG_ISO, "Initial isoc read", urb);
903 if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) 903 if ((rc = usb_submit_urb(urb, GFP_ATOMIC)) != 0)
904 goto error; 904 goto error;
905 } 905 }
906 906
@@ -935,7 +935,7 @@ static int starturbs(struct bc_state *bcs)
935 /* submit two URBs, keep third one */ 935 /* submit two URBs, keep third one */
936 for (k = 0; k < 2; ++k) { 936 for (k = 0; k < 2; ++k) {
937 dump_urb(DEBUG_ISO, "Initial isoc write", urb); 937 dump_urb(DEBUG_ISO, "Initial isoc write", urb);
938 rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC); 938 rc = usb_submit_urb(ubc->isoouturbs[k].urb, GFP_ATOMIC);
939 if (rc != 0) 939 if (rc != 0)
940 goto error; 940 goto error;
941 } 941 }
@@ -1042,7 +1042,7 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx)
1042 return 0; /* no data to send */ 1042 return 0; /* no data to send */
1043 urb->number_of_packets = nframe; 1043 urb->number_of_packets = nframe;
1044 1044
1045 rc = usb_submit_urb(urb, SLAB_ATOMIC); 1045 rc = usb_submit_urb(urb, GFP_ATOMIC);
1046 if (unlikely(rc)) { 1046 if (unlikely(rc)) {
1047 if (rc == -ENODEV) 1047 if (rc == -ENODEV)
1048 /* device removed - give up silently */ 1048 /* device removed - give up silently */
@@ -1341,7 +1341,7 @@ static void read_iso_tasklet(unsigned long data)
1341 urb->dev = bcs->cs->hw.bas->udev; 1341 urb->dev = bcs->cs->hw.bas->udev;
1342 urb->transfer_flags = URB_ISO_ASAP; 1342 urb->transfer_flags = URB_ISO_ASAP;
1343 urb->number_of_packets = BAS_NUMFRAMES; 1343 urb->number_of_packets = BAS_NUMFRAMES;
1344 rc = usb_submit_urb(urb, SLAB_ATOMIC); 1344 rc = usb_submit_urb(urb, GFP_ATOMIC);
1345 if (unlikely(rc != 0 && rc != -ENODEV)) { 1345 if (unlikely(rc != 0 && rc != -ENODEV)) {
1346 dev_err(cs->dev, 1346 dev_err(cs->dev,
1347 "could not resubmit isochronous read URB: %s\n", 1347 "could not resubmit isochronous read URB: %s\n",
@@ -1458,7 +1458,7 @@ static void write_ctrl_callback(struct urb *urb)
1458 ucs->retry_ctrl); 1458 ucs->retry_ctrl);
1459 /* urb->dev is clobbered by USB subsystem */ 1459 /* urb->dev is clobbered by USB subsystem */
1460 urb->dev = ucs->udev; 1460 urb->dev = ucs->udev;
1461 rc = usb_submit_urb(urb, SLAB_ATOMIC); 1461 rc = usb_submit_urb(urb, GFP_ATOMIC);
1462 if (unlikely(rc)) { 1462 if (unlikely(rc)) {
1463 dev_err(&ucs->interface->dev, 1463 dev_err(&ucs->interface->dev,
1464 "could not resubmit request 0x%02x: %s\n", 1464 "could not resubmit request 0x%02x: %s\n",
@@ -1517,7 +1517,7 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout)
1517 (unsigned char*) &ucs->dr_ctrl, NULL, 0, 1517 (unsigned char*) &ucs->dr_ctrl, NULL, 0,
1518 write_ctrl_callback, ucs); 1518 write_ctrl_callback, ucs);
1519 ucs->retry_ctrl = 0; 1519 ucs->retry_ctrl = 0;
1520 ret = usb_submit_urb(ucs->urb_ctrl, SLAB_ATOMIC); 1520 ret = usb_submit_urb(ucs->urb_ctrl, GFP_ATOMIC);
1521 if (unlikely(ret)) { 1521 if (unlikely(ret)) {
1522 dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n", 1522 dev_err(bcs->cs->dev, "could not submit request 0x%02x: %s\n",
1523 req, get_usb_rcmsg(ret)); 1523 req, get_usb_rcmsg(ret));
@@ -1763,7 +1763,7 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len)
1763 usb_sndctrlpipe(ucs->udev, 0), 1763 usb_sndctrlpipe(ucs->udev, 0),
1764 (unsigned char*) &ucs->dr_cmd_out, buf, len, 1764 (unsigned char*) &ucs->dr_cmd_out, buf, len,
1765 write_command_callback, cs); 1765 write_command_callback, cs);
1766 rc = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC); 1766 rc = usb_submit_urb(ucs->urb_cmd_out, GFP_ATOMIC);
1767 if (unlikely(rc)) { 1767 if (unlikely(rc)) {
1768 update_basstate(ucs, 0, BS_ATWRPEND); 1768 update_basstate(ucs, 0, BS_ATWRPEND);
1769 dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n", 1769 dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n",
@@ -2218,21 +2218,21 @@ static int gigaset_probe(struct usb_interface *interface,
2218 * - three for the different uses of the default control pipe 2218 * - three for the different uses of the default control pipe
2219 * - three for each isochronous pipe 2219 * - three for each isochronous pipe
2220 */ 2220 */
2221 if (!(ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL)) || 2221 if (!(ucs->urb_int_in = usb_alloc_urb(0, GFP_KERNEL)) ||
2222 !(ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL)) || 2222 !(ucs->urb_cmd_in = usb_alloc_urb(0, GFP_KERNEL)) ||
2223 !(ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL)) || 2223 !(ucs->urb_cmd_out = usb_alloc_urb(0, GFP_KERNEL)) ||
2224 !(ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL))) 2224 !(ucs->urb_ctrl = usb_alloc_urb(0, GFP_KERNEL)))
2225 goto allocerr; 2225 goto allocerr;
2226 2226
2227 for (j = 0; j < 2; ++j) { 2227 for (j = 0; j < 2; ++j) {
2228 ubc = cs->bcs[j].hw.bas; 2228 ubc = cs->bcs[j].hw.bas;
2229 for (i = 0; i < BAS_OUTURBS; ++i) 2229 for (i = 0; i < BAS_OUTURBS; ++i)
2230 if (!(ubc->isoouturbs[i].urb = 2230 if (!(ubc->isoouturbs[i].urb =
2231 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL))) 2231 usb_alloc_urb(BAS_NUMFRAMES, GFP_KERNEL)))
2232 goto allocerr; 2232 goto allocerr;
2233 for (i = 0; i < BAS_INURBS; ++i) 2233 for (i = 0; i < BAS_INURBS; ++i)
2234 if (!(ubc->isoinurbs[i] = 2234 if (!(ubc->isoinurbs[i] =
2235 usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL))) 2235 usb_alloc_urb(BAS_NUMFRAMES, GFP_KERNEL)))
2236 goto allocerr; 2236 goto allocerr;
2237 } 2237 }
2238 2238
@@ -2246,7 +2246,7 @@ static int gigaset_probe(struct usb_interface *interface,
2246 (endpoint->bEndpointAddress) & 0x0f), 2246 (endpoint->bEndpointAddress) & 0x0f),
2247 ucs->int_in_buf, 3, read_int_callback, cs, 2247 ucs->int_in_buf, 3, read_int_callback, cs,
2248 endpoint->bInterval); 2248 endpoint->bInterval);
2249 if ((rc = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL)) != 0) { 2249 if ((rc = usb_submit_urb(ucs->urb_int_in, GFP_KERNEL)) != 0) {
2250 dev_err(cs->dev, "could not submit interrupt URB: %s\n", 2250 dev_err(cs->dev, "could not submit interrupt URB: %s\n",
2251 get_usb_rcmsg(rc)); 2251 get_usb_rcmsg(rc));
2252 goto error; 2252 goto error;
diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
index 5ebf49ac9b23..04f2ad7ba8b0 100644
--- a/drivers/isdn/gigaset/usb-gigaset.c
+++ b/drivers/isdn/gigaset/usb-gigaset.c
@@ -410,7 +410,7 @@ static void gigaset_read_int_callback(struct urb *urb)
410 410
411 if (resubmit) { 411 if (resubmit) {
412 spin_lock_irqsave(&cs->lock, flags); 412 spin_lock_irqsave(&cs->lock, flags);
413 r = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV; 413 r = cs->connected ? usb_submit_urb(urb, GFP_ATOMIC) : -ENODEV;
414 spin_unlock_irqrestore(&cs->lock, flags); 414 spin_unlock_irqrestore(&cs->lock, flags);
415 if (r) 415 if (r)
416 dev_err(cs->dev, "error %d when resubmitting urb.\n", 416 dev_err(cs->dev, "error %d when resubmitting urb.\n",
@@ -486,7 +486,7 @@ static int send_cb(struct cardstate *cs, struct cmdbuf_t *cb)
486 atomic_set(&ucs->busy, 1); 486 atomic_set(&ucs->busy, 1);
487 487
488 spin_lock_irqsave(&cs->lock, flags); 488 spin_lock_irqsave(&cs->lock, flags);
489 status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC) : -ENODEV; 489 status = cs->connected ? usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC) : -ENODEV;
490 spin_unlock_irqrestore(&cs->lock, flags); 490 spin_unlock_irqrestore(&cs->lock, flags);
491 491
492 if (status) { 492 if (status) {
@@ -664,7 +664,7 @@ static int write_modem(struct cardstate *cs)
664 ucs->bulk_out_endpointAddr & 0x0f), 664 ucs->bulk_out_endpointAddr & 0x0f),
665 ucs->bulk_out_buffer, count, 665 ucs->bulk_out_buffer, count,
666 gigaset_write_bulk_callback, cs); 666 gigaset_write_bulk_callback, cs);
667 ret = usb_submit_urb(ucs->bulk_out_urb, SLAB_ATOMIC); 667 ret = usb_submit_urb(ucs->bulk_out_urb, GFP_ATOMIC);
668 } else { 668 } else {
669 ret = -ENODEV; 669 ret = -ENODEV;
670 } 670 }
@@ -763,7 +763,7 @@ static int gigaset_probe(struct usb_interface *interface,
763 goto error; 763 goto error;
764 } 764 }
765 765
766 ucs->bulk_out_urb = usb_alloc_urb(0, SLAB_KERNEL); 766 ucs->bulk_out_urb = usb_alloc_urb(0, GFP_KERNEL);
767 if (!ucs->bulk_out_urb) { 767 if (!ucs->bulk_out_urb) {
768 dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n"); 768 dev_err(cs->dev, "Couldn't allocate bulk_out_urb\n");
769 retval = -ENOMEM; 769 retval = -ENOMEM;
@@ -774,7 +774,7 @@ static int gigaset_probe(struct usb_interface *interface,
774 774
775 atomic_set(&ucs->busy, 0); 775 atomic_set(&ucs->busy, 0);
776 776
777 ucs->read_urb = usb_alloc_urb(0, SLAB_KERNEL); 777 ucs->read_urb = usb_alloc_urb(0, GFP_KERNEL);
778 if (!ucs->read_urb) { 778 if (!ucs->read_urb) {
779 dev_err(cs->dev, "No free urbs available\n"); 779 dev_err(cs->dev, "No free urbs available\n");
780 retval = -ENOMEM; 780 retval = -ENOMEM;
@@ -797,7 +797,7 @@ static int gigaset_probe(struct usb_interface *interface,
797 gigaset_read_int_callback, 797 gigaset_read_int_callback,
798 cs->inbuf + 0, endpoint->bInterval); 798 cs->inbuf + 0, endpoint->bInterval);
799 799
800 retval = usb_submit_urb(ucs->read_urb, SLAB_KERNEL); 800 retval = usb_submit_urb(ucs->read_urb, GFP_KERNEL);
801 if (retval) { 801 if (retval) {
802 dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval); 802 dev_err(cs->dev, "Could not submit URB (error %d)\n", -retval);
803 goto error; 803 goto error;
diff --git a/drivers/isdn/hisax/isdnhdlc.h b/drivers/isdn/hisax/isdnhdlc.h
index 269315988dc8..5655b5f9c48e 100644
--- a/drivers/isdn/hisax/isdnhdlc.h
+++ b/drivers/isdn/hisax/isdnhdlc.h
@@ -41,10 +41,10 @@ struct isdnhdlc_vars {
41 unsigned char shift_reg; 41 unsigned char shift_reg;
42 unsigned char ffvalue; 42 unsigned char ffvalue;
43 43
44 int data_received:1; // set if transferring data 44 unsigned int data_received:1; // set if transferring data
45 int dchannel:1; // set if D channel (send idle instead of flags) 45 unsigned int dchannel:1; // set if D channel (send idle instead of flags)
46 int do_adapt56:1; // set if 56K adaptation 46 unsigned int do_adapt56:1; // set if 56K adaptation
47 int do_closing:1; // set if in closing phase (need to send CRC + flag 47 unsigned int do_closing:1; // set if in closing phase (need to send CRC + flag
48}; 48};
49 49
50 50
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 9c39b98d5a5b..176142c61492 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -76,6 +76,12 @@ config LEDS_NET48XX
76 This option enables support for the Soekris net4801 and net4826 error 76 This option enables support for the Soekris net4801 and net4826 error
77 LED. 77 LED.
78 78
79config LEDS_WRAP
80 tristate "LED Support for the WRAP series LEDs"
81 depends on LEDS_CLASS && SCx200_GPIO
82 help
83 This option enables support for the PCEngines WRAP programmable LEDs.
84
79comment "LED Triggers" 85comment "LED Triggers"
80 86
81config LEDS_TRIGGERS 87config LEDS_TRIGGERS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 6aa2aed7539d..500de3dc962a 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o
13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o 13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
14obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o 14obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o
15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o 15obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
16obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
16 17
17# LED Triggers 18# LED Triggers
18obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o 19obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
diff --git a/drivers/leds/leds-wrap.c b/drivers/leds/leds-wrap.c
new file mode 100644
index 000000000000..27fb2d8e991f
--- /dev/null
+++ b/drivers/leds/leds-wrap.c
@@ -0,0 +1,142 @@
1/*
2 * LEDs driver for PCEngines WRAP
3 *
4 * Copyright (C) 2006 Kristian Kielhofner <kris@krisk.org>
5 *
6 * Based on leds-net48xx.c
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/platform_device.h>
16#include <linux/leds.h>
17#include <linux/err.h>
18#include <asm/io.h>
19#include <linux/scx200_gpio.h>
20
21#define DRVNAME "wrap-led"
22#define WRAP_ERROR_LED_GPIO 3
23#define WRAP_EXTRA_LED_GPIO 18
24
25static struct platform_device *pdev;
26
27static void wrap_error_led_set(struct led_classdev *led_cdev,
28 enum led_brightness value)
29{
30 if (value)
31 scx200_gpio_set_low(WRAP_ERROR_LED_GPIO);
32 else
33 scx200_gpio_set_high(WRAP_ERROR_LED_GPIO);
34}
35
36static void wrap_extra_led_set(struct led_classdev *led_cdev,
37 enum led_brightness value)
38{
39 if (value)
40 scx200_gpio_set_low(WRAP_EXTRA_LED_GPIO);
41 else
42 scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO);
43}
44
45static struct led_classdev wrap_error_led = {
46 .name = "wrap:error",
47 .brightness_set = wrap_error_led_set,
48};
49
50static struct led_classdev wrap_extra_led = {
51 .name = "wrap:extra",
52 .brightness_set = wrap_extra_led_set,
53};
54
55#ifdef CONFIG_PM
56static int wrap_led_suspend(struct platform_device *dev,
57 pm_message_t state)
58{
59 led_classdev_suspend(&wrap_error_led);
60 led_classdev_suspend(&wrap_extra_led);
61 return 0;
62}
63
64static int wrap_led_resume(struct platform_device *dev)
65{
66 led_classdev_resume(&wrap_error_led);
67 led_classdev_resume(&wrap_extra_led);
68 return 0;
69}
70#else
71#define wrap_led_suspend NULL
72#define wrap_led_resume NULL
73#endif
74
75static int wrap_led_probe(struct platform_device *pdev)
76{
77 int ret;
78
79 ret = led_classdev_register(&pdev->dev, &wrap_error_led);
80 if (ret == 0) {
81 ret = led_classdev_register(&pdev->dev, &wrap_extra_led);
82 if (ret < 0)
83 led_classdev_unregister(&wrap_error_led);
84 }
85 return ret;
86}
87
88static int wrap_led_remove(struct platform_device *pdev)
89{
90 led_classdev_unregister(&wrap_error_led);
91 led_classdev_unregister(&wrap_extra_led);
92 return 0;
93}
94
95static struct platform_driver wrap_led_driver = {
96 .probe = wrap_led_probe,
97 .remove = wrap_led_remove,
98 .suspend = wrap_led_suspend,
99 .resume = wrap_led_resume,
100 .driver = {
101 .name = DRVNAME,
102 .owner = THIS_MODULE,
103 },
104};
105
106static int __init wrap_led_init(void)
107{
108 int ret;
109
110 if (!scx200_gpio_present()) {
111 ret = -ENODEV;
112 goto out;
113 }
114
115 ret = platform_driver_register(&wrap_led_driver);
116 if (ret < 0)
117 goto out;
118
119 pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
120 if (IS_ERR(pdev)) {
121 ret = PTR_ERR(pdev);
122 platform_driver_unregister(&wrap_led_driver);
123 goto out;
124 }
125
126out:
127 return ret;
128}
129
130static void __exit wrap_led_exit(void)
131{
132 platform_device_unregister(pdev);
133 platform_driver_unregister(&wrap_led_driver);
134}
135
136module_init(wrap_led_init);
137module_exit(wrap_led_exit);
138
139MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
140MODULE_DESCRIPTION("PCEngines WRAP LED driver");
141MODULE_LICENSE("GPL");
142
diff --git a/drivers/macintosh/apm_emu.c b/drivers/macintosh/apm_emu.c
index 1293876a2ebd..8862a83b8d84 100644
--- a/drivers/macintosh/apm_emu.c
+++ b/drivers/macintosh/apm_emu.c
@@ -529,7 +529,8 @@ static int __init apm_emu_init(void)
529 if (apm_proc) 529 if (apm_proc)
530 apm_proc->owner = THIS_MODULE; 530 apm_proc->owner = THIS_MODULE;
531 531
532 misc_register(&apm_device); 532 if (misc_register(&apm_device) != 0)
533 printk(KERN_INFO "Could not create misc. device for apm\n");
533 534
534 pmu_register_sleep_notifier(&apm_sleep_notifier); 535 pmu_register_sleep_notifier(&apm_sleep_notifier);
535 536
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index 13b953ae8ebc..3d3bf1643e73 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -24,6 +24,7 @@
24#include <linux/suspend.h> 24#include <linux/suspend.h>
25#include <linux/kthread.h> 25#include <linux/kthread.h>
26#include <linux/moduleparam.h> 26#include <linux/moduleparam.h>
27#include <linux/freezer.h>
27 28
28#include <asm/prom.h> 29#include <asm/prom.h>
29#include <asm/machdep.h> 30#include <asm/machdep.h>
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index e63ea1c1f3c1..c8558d4ed506 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -42,7 +42,7 @@
42#include <linux/interrupt.h> 42#include <linux/interrupt.h>
43#include <linux/device.h> 43#include <linux/device.h>
44#include <linux/sysdev.h> 44#include <linux/sysdev.h>
45#include <linux/suspend.h> 45#include <linux/freezer.h>
46#include <linux/syscalls.h> 46#include <linux/syscalls.h>
47#include <linux/cpu.h> 47#include <linux/cpu.h>
48#include <asm/prom.h> 48#include <asm/prom.h>
diff --git a/drivers/macintosh/windfarm_core.c b/drivers/macintosh/windfarm_core.c
index ab3faa702d58..e947af982f93 100644
--- a/drivers/macintosh/windfarm_core.c
+++ b/drivers/macintosh/windfarm_core.c
@@ -34,6 +34,7 @@
34#include <linux/device.h> 34#include <linux/device.h>
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/freezer.h>
37 38
38#include <asm/prom.h> 39#include <asm/prom.h>
39 40
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index ed2d4ef27fd8..a1086ee8cccd 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -20,6 +20,7 @@
20#include <asm/atomic.h> 20#include <asm/atomic.h>
21#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
22#include <asm/page.h> 22#include <asm/page.h>
23#include <asm/unaligned.h>
23 24
24#include "dm.h" 25#include "dm.h"
25 26
@@ -85,7 +86,10 @@ struct crypt_config {
85 */ 86 */
86 struct crypt_iv_operations *iv_gen_ops; 87 struct crypt_iv_operations *iv_gen_ops;
87 char *iv_mode; 88 char *iv_mode;
88 struct crypto_cipher *iv_gen_private; 89 union {
90 struct crypto_cipher *essiv_tfm;
91 int benbi_shift;
92 } iv_gen_private;
89 sector_t iv_offset; 93 sector_t iv_offset;
90 unsigned int iv_size; 94 unsigned int iv_size;
91 95
@@ -101,7 +105,7 @@ struct crypt_config {
101#define MIN_POOL_PAGES 32 105#define MIN_POOL_PAGES 32
102#define MIN_BIO_PAGES 8 106#define MIN_BIO_PAGES 8
103 107
104static kmem_cache_t *_crypt_io_pool; 108static struct kmem_cache *_crypt_io_pool;
105 109
106/* 110/*
107 * Different IV generation algorithms: 111 * Different IV generation algorithms:
@@ -113,6 +117,9 @@ static kmem_cache_t *_crypt_io_pool;
113 * encrypted with the bulk cipher using a salt as key. The salt 117 * encrypted with the bulk cipher using a salt as key. The salt
114 * should be derived from the bulk cipher's key via hashing. 118 * should be derived from the bulk cipher's key via hashing.
115 * 119 *
120 * benbi: the 64-bit "big-endian 'narrow block'-count", starting at 1
121 * (needed for LRW-32-AES and possible other narrow block modes)
122 *
116 * plumb: unimplemented, see: 123 * plumb: unimplemented, see:
117 * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454 124 * http://article.gmane.org/gmane.linux.kernel.device-mapper.dm-crypt/454
118 */ 125 */
@@ -191,21 +198,61 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
191 } 198 }
192 kfree(salt); 199 kfree(salt);
193 200
194 cc->iv_gen_private = essiv_tfm; 201 cc->iv_gen_private.essiv_tfm = essiv_tfm;
195 return 0; 202 return 0;
196} 203}
197 204
198static void crypt_iv_essiv_dtr(struct crypt_config *cc) 205static void crypt_iv_essiv_dtr(struct crypt_config *cc)
199{ 206{
200 crypto_free_cipher(cc->iv_gen_private); 207 crypto_free_cipher(cc->iv_gen_private.essiv_tfm);
201 cc->iv_gen_private = NULL; 208 cc->iv_gen_private.essiv_tfm = NULL;
202} 209}
203 210
204static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector) 211static int crypt_iv_essiv_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
205{ 212{
206 memset(iv, 0, cc->iv_size); 213 memset(iv, 0, cc->iv_size);
207 *(u64 *)iv = cpu_to_le64(sector); 214 *(u64 *)iv = cpu_to_le64(sector);
208 crypto_cipher_encrypt_one(cc->iv_gen_private, iv, iv); 215 crypto_cipher_encrypt_one(cc->iv_gen_private.essiv_tfm, iv, iv);
216 return 0;
217}
218
219static int crypt_iv_benbi_ctr(struct crypt_config *cc, struct dm_target *ti,
220 const char *opts)
221{
222 unsigned int bs = crypto_blkcipher_blocksize(cc->tfm);
223 int log = long_log2(bs);
224
225 /* we need to calculate how far we must shift the sector count
226 * to get the cipher block count, we use this shift in _gen */
227
228 if (1 << log != bs) {
229 ti->error = "cypher blocksize is not a power of 2";
230 return -EINVAL;
231 }
232
233 if (log > 9) {
234 ti->error = "cypher blocksize is > 512";
235 return -EINVAL;
236 }
237
238 cc->iv_gen_private.benbi_shift = 9 - log;
239
240 return 0;
241}
242
243static void crypt_iv_benbi_dtr(struct crypt_config *cc)
244{
245}
246
247static int crypt_iv_benbi_gen(struct crypt_config *cc, u8 *iv, sector_t sector)
248{
249 __be64 val;
250
251 memset(iv, 0, cc->iv_size - sizeof(u64)); /* rest is cleared below */
252
253 val = cpu_to_be64(((u64)sector << cc->iv_gen_private.benbi_shift) + 1);
254 put_unaligned(val, (__be64 *)(iv + cc->iv_size - sizeof(u64)));
255
209 return 0; 256 return 0;
210} 257}
211 258
@@ -219,13 +266,18 @@ static struct crypt_iv_operations crypt_iv_essiv_ops = {
219 .generator = crypt_iv_essiv_gen 266 .generator = crypt_iv_essiv_gen
220}; 267};
221 268
269static struct crypt_iv_operations crypt_iv_benbi_ops = {
270 .ctr = crypt_iv_benbi_ctr,
271 .dtr = crypt_iv_benbi_dtr,
272 .generator = crypt_iv_benbi_gen
273};
222 274
223static int 275static int
224crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out, 276crypt_convert_scatterlist(struct crypt_config *cc, struct scatterlist *out,
225 struct scatterlist *in, unsigned int length, 277 struct scatterlist *in, unsigned int length,
226 int write, sector_t sector) 278 int write, sector_t sector)
227{ 279{
228 u8 iv[cc->iv_size]; 280 u8 iv[cc->iv_size] __attribute__ ((aligned(__alignof__(u64))));
229 struct blkcipher_desc desc = { 281 struct blkcipher_desc desc = {
230 .tfm = cc->tfm, 282 .tfm = cc->tfm,
231 .info = iv, 283 .info = iv,
@@ -768,7 +820,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
768 cc->tfm = tfm; 820 cc->tfm = tfm;
769 821
770 /* 822 /*
771 * Choose ivmode. Valid modes: "plain", "essiv:<esshash>". 823 * Choose ivmode. Valid modes: "plain", "essiv:<esshash>", "benbi".
772 * See comments at iv code 824 * See comments at iv code
773 */ 825 */
774 826
@@ -778,6 +830,8 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
778 cc->iv_gen_ops = &crypt_iv_plain_ops; 830 cc->iv_gen_ops = &crypt_iv_plain_ops;
779 else if (strcmp(ivmode, "essiv") == 0) 831 else if (strcmp(ivmode, "essiv") == 0)
780 cc->iv_gen_ops = &crypt_iv_essiv_ops; 832 cc->iv_gen_ops = &crypt_iv_essiv_ops;
833 else if (strcmp(ivmode, "benbi") == 0)
834 cc->iv_gen_ops = &crypt_iv_benbi_ops;
781 else { 835 else {
782 ti->error = "Invalid IV mode"; 836 ti->error = "Invalid IV mode";
783 goto bad2; 837 goto bad2;
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index e77ee6fd1044..cf8bf052138e 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -101,7 +101,7 @@ typedef int (*action_fn) (struct pgpath *pgpath);
101 101
102#define MIN_IOS 256 /* Mempool size */ 102#define MIN_IOS 256 /* Mempool size */
103 103
104static kmem_cache_t *_mpio_cache; 104static struct kmem_cache *_mpio_cache;
105 105
106struct workqueue_struct *kmultipathd; 106struct workqueue_struct *kmultipathd;
107static void process_queued_ios(struct work_struct *work); 107static void process_queued_ios(struct work_struct *work);
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 91c7aa1fed0e..b0ce2ce82278 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -88,8 +88,8 @@ struct pending_exception {
88 * Hash table mapping origin volumes to lists of snapshots and 88 * Hash table mapping origin volumes to lists of snapshots and
89 * a lock to protect it 89 * a lock to protect it
90 */ 90 */
91static kmem_cache_t *exception_cache; 91static struct kmem_cache *exception_cache;
92static kmem_cache_t *pending_cache; 92static struct kmem_cache *pending_cache;
93static mempool_t *pending_pool; 93static mempool_t *pending_pool;
94 94
95/* 95/*
@@ -228,7 +228,7 @@ static int init_exception_table(struct exception_table *et, uint32_t size)
228 return 0; 228 return 0;
229} 229}
230 230
231static void exit_exception_table(struct exception_table *et, kmem_cache_t *mem) 231static void exit_exception_table(struct exception_table *et, struct kmem_cache *mem)
232{ 232{
233 struct list_head *slot; 233 struct list_head *slot;
234 struct exception *ex, *next; 234 struct exception *ex, *next;
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index fc4f743f3b53..7ec1b112a6d5 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -121,8 +121,8 @@ struct mapped_device {
121}; 121};
122 122
123#define MIN_IOS 256 123#define MIN_IOS 256
124static kmem_cache_t *_io_cache; 124static struct kmem_cache *_io_cache;
125static kmem_cache_t *_tio_cache; 125static struct kmem_cache *_tio_cache;
126 126
127static int __init local_init(void) 127static int __init local_init(void)
128{ 128{
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c
index b3c01496c737..b46f6c575f7e 100644
--- a/drivers/md/kcopyd.c
+++ b/drivers/md/kcopyd.c
@@ -203,7 +203,7 @@ struct kcopyd_job {
203/* FIXME: this should scale with the number of pages */ 203/* FIXME: this should scale with the number of pages */
204#define MIN_JOBS 512 204#define MIN_JOBS 512
205 205
206static kmem_cache_t *_job_cache; 206static struct kmem_cache *_job_cache;
207static mempool_t *_job_pool; 207static mempool_t *_job_pool;
208 208
209/* 209/*
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 8cbf9c9df1c3..6c4345bde07e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -39,10 +39,10 @@
39#include <linux/raid/bitmap.h> 39#include <linux/raid/bitmap.h>
40#include <linux/sysctl.h> 40#include <linux/sysctl.h>
41#include <linux/buffer_head.h> /* for invalidate_bdev */ 41#include <linux/buffer_head.h> /* for invalidate_bdev */
42#include <linux/suspend.h>
43#include <linux/poll.h> 42#include <linux/poll.h>
44#include <linux/mutex.h> 43#include <linux/mutex.h>
45#include <linux/ctype.h> 44#include <linux/ctype.h>
45#include <linux/freezer.h>
46 46
47#include <linux/init.h> 47#include <linux/init.h>
48 48
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 69c3e201fa3b..52914d5cec76 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -348,7 +348,7 @@ static int grow_one_stripe(raid5_conf_t *conf)
348 348
349static int grow_stripes(raid5_conf_t *conf, int num) 349static int grow_stripes(raid5_conf_t *conf, int num)
350{ 350{
351 kmem_cache_t *sc; 351 struct kmem_cache *sc;
352 int devs = conf->raid_disks; 352 int devs = conf->raid_disks;
353 353
354 sprintf(conf->cache_name[0], "raid5/%s", mdname(conf->mddev)); 354 sprintf(conf->cache_name[0], "raid5/%s", mdname(conf->mddev));
@@ -397,7 +397,7 @@ static int resize_stripes(raid5_conf_t *conf, int newsize)
397 LIST_HEAD(newstripes); 397 LIST_HEAD(newstripes);
398 struct disk_info *ndisks; 398 struct disk_info *ndisks;
399 int err = 0; 399 int err = 0;
400 kmem_cache_t *sc; 400 struct kmem_cache *sc;
401 int i; 401 int i;
402 402
403 if (newsize <= conf->pool_size) 403 if (newsize <= conf->pool_size)
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 206c13e47a06..9123147e376f 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -287,7 +287,7 @@ static int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
287 int i; 287 int i;
288 288
289 cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE, 289 cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
290 SLAB_KERNEL, &cinergyt2->streambuf_dmahandle); 290 GFP_KERNEL, &cinergyt2->streambuf_dmahandle);
291 if (!cinergyt2->streambuf) { 291 if (!cinergyt2->streambuf) {
292 dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n"); 292 dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n");
293 return -ENOMEM; 293 return -ENOMEM;
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index a2ab2eebfc68..e85972222ab4 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -34,7 +34,7 @@
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/list.h> 36#include <linux/list.h>
37#include <linux/suspend.h> 37#include <linux/freezer.h>
38#include <linux/jiffies.h> 38#include <linux/jiffies.h>
39#include <asm/processor.h> 39#include <asm/processor.h>
40 40
diff --git a/drivers/media/dvb/dvb-usb/usb-urb.c b/drivers/media/dvb/dvb-usb/usb-urb.c
index 78035ee824ca..397f51a7b2ad 100644
--- a/drivers/media/dvb/dvb-usb/usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/usb-urb.c
@@ -116,7 +116,7 @@ static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num,
116 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { 116 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) {
117 deb_mem("allocating buffer %d\n",stream->buf_num); 117 deb_mem("allocating buffer %d\n",stream->buf_num);
118 if (( stream->buf_list[stream->buf_num] = 118 if (( stream->buf_list[stream->buf_num] =
119 usb_buffer_alloc(stream->udev, size, SLAB_ATOMIC, 119 usb_buffer_alloc(stream->udev, size, GFP_ATOMIC,
120 &stream->dma_addr[stream->buf_num]) ) == NULL) { 120 &stream->dma_addr[stream->buf_num]) ) == NULL) {
121 deb_mem("not enough memory for urb-buffer allocation.\n"); 121 deb_mem("not enough memory for urb-buffer allocation.\n");
122 usb_free_stream_buffers(stream); 122 usb_free_stream_buffers(stream);
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
index f3bc82e44a28..1aeacb1c4af7 100644
--- a/drivers/media/dvb/frontends/l64781.c
+++ b/drivers/media/dvb/frontends/l64781.c
@@ -36,7 +36,7 @@ struct l64781_state {
36 struct dvb_frontend frontend; 36 struct dvb_frontend frontend;
37 37
38 /* private demodulator data */ 38 /* private demodulator data */
39 int first:1; 39 unsigned int first:1;
40}; 40};
41 41
42#define dprintk(args...) \ 42#define dprintk(args...) \
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 8135f3e76aeb..10b121ada833 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1244,7 +1244,7 @@ static int ttusb_dec_init_usb(struct ttusb_dec *dec)
1244 return -ENOMEM; 1244 return -ENOMEM;
1245 } 1245 }
1246 dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE, 1246 dec->irq_buffer = usb_buffer_alloc(dec->udev,IRQ_PACKET_SIZE,
1247 SLAB_ATOMIC, &dec->irq_dma_handle); 1247 GFP_ATOMIC, &dec->irq_dma_handle);
1248 if(!dec->irq_buffer) { 1248 if(!dec->irq_buffer) {
1249 return -ENOMEM; 1249 return -ENOMEM;
1250 } 1250 }
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index 6d96b17a7f81..920b63f8cf05 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -173,38 +173,6 @@ config RADIO_MAESTRO
173 To compile this driver as a module, choose M here: the 173 To compile this driver as a module, choose M here: the
174 module will be called radio-maestro. 174 module will be called radio-maestro.
175 175
176config RADIO_MIROPCM20
177 tristate "miroSOUND PCM20 radio"
178 depends on ISA && VIDEO_V4L1 && SOUND_ACI_MIXER
179 ---help---
180 Choose Y here if you have this FM radio card. You also need to say Y
181 to "ACI mixer (miroSOUND PCM1-pro/PCM12/PCM20 radio)" (in "Sound")
182 for this to work.
183
184 In order to control your radio card, you will need to use programs
185 that are compatible with the Video For Linux API. Information on
186 this API and pointers to "v4l" programs may be found at
187 <file:Documentation/video4linux/API.html>.
188
189 To compile this driver as a module, choose M here: the
190 module will be called miropcm20.
191
192config RADIO_MIROPCM20_RDS
193 tristate "miroSOUND PCM20 radio RDS user interface (EXPERIMENTAL)"
194 depends on RADIO_MIROPCM20 && EXPERIMENTAL
195 ---help---
196 Choose Y here if you want to see RDS/RBDS information like
197 RadioText, Programme Service name, Clock Time and date, Programme
198 Type and Traffic Announcement/Programme identification.
199
200 It's not possible to read the raw RDS packets from the device, so
201 the driver cant provide an V4L interface for this. But the
202 availability of RDS is reported over V4L by the basic driver
203 already. Here RDS can be read from files in /dev/v4l/rds.
204
205 To compile this driver as a module, choose M here: the
206 module will be called miropcm20-rds.
207
208config RADIO_SF16FMI 176config RADIO_SF16FMI
209 tristate "SF16FMI Radio" 177 tristate "SF16FMI Radio"
210 depends on ISA && VIDEO_V4L2 178 depends on ISA && VIDEO_V4L2
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index cf43df3fe708..e1b56dc13c3f 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -56,7 +56,7 @@
56#include <media/tvaudio.h> 56#include <media/tvaudio.h>
57#include <media/msp3400.h> 57#include <media/msp3400.h>
58#include <linux/kthread.h> 58#include <linux/kthread.h>
59#include <linux/suspend.h> 59#include <linux/freezer.h>
60#include "msp3400-driver.h" 60#include "msp3400-driver.h"
61 61
62/* ---------------------------------------------------------------------- */ 62/* ---------------------------------------------------------------------- */
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index fcaef4bf8289..d506dfaa45a9 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/smp_lock.h> 30#include <linux/smp_lock.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/freezer.h>
32 33
33#include <media/tvaudio.h> 34#include <media/tvaudio.h>
34#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index f53edf1923b7..fcc5467e7636 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -20,7 +20,7 @@
20#include <linux/fs.h> 20#include <linux/fs.h>
21#include <linux/kthread.h> 21#include <linux/kthread.h>
22#include <linux/file.h> 22#include <linux/file.h>
23#include <linux/suspend.h> 23#include <linux/freezer.h>
24 24
25#include <media/video-buf.h> 25#include <media/video-buf.h>
26#include <media/video-buf-dvb.h> 26#include <media/video-buf-dvb.h>
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
index 3c8dc72dc8e9..9986de5cb3d6 100644
--- a/drivers/media/video/vivi.c
+++ b/drivers/media/video/vivi.c
@@ -36,6 +36,7 @@
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <linux/kthread.h> 37#include <linux/kthread.h>
38#include <linux/highmem.h> 38#include <linux/highmem.h>
39#include <linux/freezer.h>
39 40
40/* Wake up at about 30 fps */ 41/* Wake up at about 30 fps */
41#define WAKE_NUMERATOR 30 42#define WAKE_NUMERATOR 30
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 051b7c5b8f03..6e068cf1049b 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -347,7 +347,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
347} 347}
348 348
349/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 349/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
350/* 350/**
351 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler. 351 * mpt_interrupt - MPT adapter (IOC) specific interrupt handler.
352 * @irq: irq number (not used) 352 * @irq: irq number (not used)
353 * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure 353 * @bus_id: bus identifier cookie == pointer to MPT_ADAPTER structure
@@ -387,14 +387,16 @@ mpt_interrupt(int irq, void *bus_id)
387} 387}
388 388
389/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 389/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
390/* 390/**
391 * mpt_base_reply - MPT base driver's callback routine; all base driver 391 * mpt_base_reply - MPT base driver's callback routine
392 * "internal" request/reply processing is routed here.
393 * Currently used for EventNotification and EventAck handling.
394 * @ioc: Pointer to MPT_ADAPTER structure 392 * @ioc: Pointer to MPT_ADAPTER structure
395 * @mf: Pointer to original MPT request frame 393 * @mf: Pointer to original MPT request frame
396 * @reply: Pointer to MPT reply frame (NULL if TurboReply) 394 * @reply: Pointer to MPT reply frame (NULL if TurboReply)
397 * 395 *
396 * MPT base driver's callback routine; all base driver
397 * "internal" request/reply processing is routed here.
398 * Currently used for EventNotification and EventAck handling.
399 *
398 * Returns 1 indicating original alloc'd request frame ptr 400 * Returns 1 indicating original alloc'd request frame ptr
399 * should be freed, or 0 if it shouldn't. 401 * should be freed, or 0 if it shouldn't.
400 */ 402 */
@@ -530,7 +532,7 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *reply)
530 * @dclass: Protocol driver's class (%MPT_DRIVER_CLASS enum value) 532 * @dclass: Protocol driver's class (%MPT_DRIVER_CLASS enum value)
531 * 533 *
532 * This routine is called by a protocol-specific driver (SCSI host, 534 * This routine is called by a protocol-specific driver (SCSI host,
533 * LAN, SCSI target) to register it's reply callback routine. Each 535 * LAN, SCSI target) to register its reply callback routine. Each
534 * protocol-specific driver must do this before it will be able to 536 * protocol-specific driver must do this before it will be able to
535 * use any IOC resources, such as obtaining request frames. 537 * use any IOC resources, such as obtaining request frames.
536 * 538 *
@@ -572,7 +574,7 @@ mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
572 * mpt_deregister - Deregister a protocol drivers resources. 574 * mpt_deregister - Deregister a protocol drivers resources.
573 * @cb_idx: previously registered callback handle 575 * @cb_idx: previously registered callback handle
574 * 576 *
575 * Each protocol-specific driver should call this routine when it's 577 * Each protocol-specific driver should call this routine when its
576 * module is unloaded. 578 * module is unloaded.
577 */ 579 */
578void 580void
@@ -617,7 +619,7 @@ mpt_event_register(int cb_idx, MPT_EVHANDLER ev_cbfunc)
617 * 619 *
618 * Each protocol-specific driver should call this routine 620 * Each protocol-specific driver should call this routine
619 * when it does not (or can no longer) handle events, 621 * when it does not (or can no longer) handle events,
620 * or when it's module is unloaded. 622 * or when its module is unloaded.
621 */ 623 */
622void 624void
623mpt_event_deregister(int cb_idx) 625mpt_event_deregister(int cb_idx)
@@ -656,7 +658,7 @@ mpt_reset_register(int cb_idx, MPT_RESETHANDLER reset_func)
656 * 658 *
657 * Each protocol-specific driver should call this routine 659 * Each protocol-specific driver should call this routine
658 * when it does not (or can no longer) handle IOC reset handling, 660 * when it does not (or can no longer) handle IOC reset handling,
659 * or when it's module is unloaded. 661 * or when its module is unloaded.
660 */ 662 */
661void 663void
662mpt_reset_deregister(int cb_idx) 664mpt_reset_deregister(int cb_idx)
@@ -670,6 +672,8 @@ mpt_reset_deregister(int cb_idx)
670/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 672/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
671/** 673/**
672 * mpt_device_driver_register - Register device driver hooks 674 * mpt_device_driver_register - Register device driver hooks
675 * @dd_cbfunc: driver callbacks struct
676 * @cb_idx: MPT protocol driver index
673 */ 677 */
674int 678int
675mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx) 679mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
@@ -696,6 +700,7 @@ mpt_device_driver_register(struct mpt_pci_driver * dd_cbfunc, int cb_idx)
696/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 700/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
697/** 701/**
698 * mpt_device_driver_deregister - DeRegister device driver hooks 702 * mpt_device_driver_deregister - DeRegister device driver hooks
703 * @cb_idx: MPT protocol driver index
699 */ 704 */
700void 705void
701mpt_device_driver_deregister(int cb_idx) 706mpt_device_driver_deregister(int cb_idx)
@@ -887,8 +892,7 @@ mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr)
887 892
888/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 893/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
889/** 894/**
890 * mpt_send_handshake_request - Send MPT request via doorbell 895 * mpt_send_handshake_request - Send MPT request via doorbell handshake method.
891 * handshake method.
892 * @handle: Handle of registered MPT protocol driver 896 * @handle: Handle of registered MPT protocol driver
893 * @ioc: Pointer to MPT adapter structure 897 * @ioc: Pointer to MPT adapter structure
894 * @reqBytes: Size of the request in bytes 898 * @reqBytes: Size of the request in bytes
@@ -981,10 +985,13 @@ mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int reqBytes, u32 *req,
981 985
982/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 986/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
983/** 987/**
984 * mpt_host_page_access_control - provides mechanism for the host 988 * mpt_host_page_access_control - control the IOC's Host Page Buffer access
985 * driver to control the IOC's Host Page Buffer access.
986 * @ioc: Pointer to MPT adapter structure 989 * @ioc: Pointer to MPT adapter structure
987 * @access_control_value: define bits below 990 * @access_control_value: define bits below
991 * @sleepFlag: Specifies whether the process can sleep
992 *
993 * Provides mechanism for the host driver to control the IOC's
994 * Host Page Buffer access.
988 * 995 *
989 * Access Control Value - bits[15:12] 996 * Access Control Value - bits[15:12]
990 * 0h Reserved 997 * 0h Reserved
@@ -1022,10 +1029,10 @@ mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int slee
1022/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1029/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1023/** 1030/**
1024 * mpt_host_page_alloc - allocate system memory for the fw 1031 * mpt_host_page_alloc - allocate system memory for the fw
1025 * If we already allocated memory in past, then resend the same pointer. 1032 * @ioc: Pointer to pointer to IOC adapter
1026 * ioc@: Pointer to pointer to IOC adapter 1033 * @ioc_init: Pointer to ioc init config page
1027 * ioc_init@: Pointer to ioc init config page
1028 * 1034 *
1035 * If we already allocated memory in past, then resend the same pointer.
1029 * Returns 0 for success, non-zero for failure. 1036 * Returns 0 for success, non-zero for failure.
1030 */ 1037 */
1031static int 1038static int
@@ -1091,12 +1098,15 @@ return 0;
1091 1098
1092/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1099/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1093/** 1100/**
1094 * mpt_verify_adapter - Given a unique IOC identifier, set pointer to 1101 * mpt_verify_adapter - Given IOC identifier, set pointer to its adapter structure.
1095 * the associated MPT adapter structure.
1096 * @iocid: IOC unique identifier (integer) 1102 * @iocid: IOC unique identifier (integer)
1097 * @iocpp: Pointer to pointer to IOC adapter 1103 * @iocpp: Pointer to pointer to IOC adapter
1098 * 1104 *
1099 * Returns iocid and sets iocpp. 1105 * Given a unique IOC identifier, set pointer to the associated MPT
1106 * adapter structure.
1107 *
1108 * Returns iocid and sets iocpp if iocid is found.
1109 * Returns -1 if iocid is not found.
1100 */ 1110 */
1101int 1111int
1102mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp) 1112mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
@@ -1115,9 +1125,10 @@ mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
1115} 1125}
1116 1126
1117/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1127/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1118/* 1128/**
1119 * mpt_attach - Install a PCI intelligent MPT adapter. 1129 * mpt_attach - Install a PCI intelligent MPT adapter.
1120 * @pdev: Pointer to pci_dev structure 1130 * @pdev: Pointer to pci_dev structure
1131 * @id: PCI device ID information
1121 * 1132 *
1122 * This routine performs all the steps necessary to bring the IOC of 1133 * This routine performs all the steps necessary to bring the IOC of
1123 * a MPT adapter to a OPERATIONAL state. This includes registering 1134 * a MPT adapter to a OPERATIONAL state. This includes registering
@@ -1417,10 +1428,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1417} 1428}
1418 1429
1419/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1430/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1420/* 1431/**
1421 * mpt_detach - Remove a PCI intelligent MPT adapter. 1432 * mpt_detach - Remove a PCI intelligent MPT adapter.
1422 * @pdev: Pointer to pci_dev structure 1433 * @pdev: Pointer to pci_dev structure
1423 *
1424 */ 1434 */
1425 1435
1426void 1436void
@@ -1466,10 +1476,10 @@ mpt_detach(struct pci_dev *pdev)
1466 */ 1476 */
1467#ifdef CONFIG_PM 1477#ifdef CONFIG_PM
1468/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1478/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1469/* 1479/**
1470 * mpt_suspend - Fusion MPT base driver suspend routine. 1480 * mpt_suspend - Fusion MPT base driver suspend routine.
1471 * 1481 * @pdev: Pointer to pci_dev structure
1472 * 1482 * @state: new state to enter
1473 */ 1483 */
1474int 1484int
1475mpt_suspend(struct pci_dev *pdev, pm_message_t state) 1485mpt_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -1505,10 +1515,9 @@ mpt_suspend(struct pci_dev *pdev, pm_message_t state)
1505} 1515}
1506 1516
1507/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1517/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1508/* 1518/**
1509 * mpt_resume - Fusion MPT base driver resume routine. 1519 * mpt_resume - Fusion MPT base driver resume routine.
1510 * 1520 * @pdev: Pointer to pci_dev structure
1511 *
1512 */ 1521 */
1513int 1522int
1514mpt_resume(struct pci_dev *pdev) 1523mpt_resume(struct pci_dev *pdev)
@@ -1566,7 +1575,7 @@ mpt_signal_reset(int index, MPT_ADAPTER *ioc, int reset_phase)
1566} 1575}
1567 1576
1568/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1577/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1569/* 1578/**
1570 * mpt_do_ioc_recovery - Initialize or recover MPT adapter. 1579 * mpt_do_ioc_recovery - Initialize or recover MPT adapter.
1571 * @ioc: Pointer to MPT adapter structure 1580 * @ioc: Pointer to MPT adapter structure
1572 * @reason: Event word / reason 1581 * @reason: Event word / reason
@@ -1892,13 +1901,15 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1892} 1901}
1893 1902
1894/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1895/* 1904/**
1896 * mpt_detect_bound_ports - Search for PCI bus/dev_function 1905 * mpt_detect_bound_ports - Search for matching PCI bus/dev_function
1897 * which matches PCI bus/dev_function (+/-1) for newly discovered 929,
1898 * 929X, 1030 or 1035.
1899 * @ioc: Pointer to MPT adapter structure 1906 * @ioc: Pointer to MPT adapter structure
1900 * @pdev: Pointer to (struct pci_dev) structure 1907 * @pdev: Pointer to (struct pci_dev) structure
1901 * 1908 *
1909 * Search for PCI bus/dev_function which matches
1910 * PCI bus/dev_function (+/-1) for newly discovered 929,
1911 * 929X, 1030 or 1035.
1912 *
1902 * If match on PCI dev_function +/-1 is found, bind the two MPT adapters 1913 * If match on PCI dev_function +/-1 is found, bind the two MPT adapters
1903 * using alt_ioc pointer fields in their %MPT_ADAPTER structures. 1914 * using alt_ioc pointer fields in their %MPT_ADAPTER structures.
1904 */ 1915 */
@@ -1945,9 +1956,9 @@ mpt_detect_bound_ports(MPT_ADAPTER *ioc, struct pci_dev *pdev)
1945} 1956}
1946 1957
1947/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1958/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1948/* 1959/**
1949 * mpt_adapter_disable - Disable misbehaving MPT adapter. 1960 * mpt_adapter_disable - Disable misbehaving MPT adapter.
1950 * @this: Pointer to MPT adapter structure 1961 * @ioc: Pointer to MPT adapter structure
1951 */ 1962 */
1952static void 1963static void
1953mpt_adapter_disable(MPT_ADAPTER *ioc) 1964mpt_adapter_disable(MPT_ADAPTER *ioc)
@@ -2046,9 +2057,8 @@ mpt_adapter_disable(MPT_ADAPTER *ioc)
2046} 2057}
2047 2058
2048/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2059/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2049/* 2060/**
2050 * mpt_adapter_dispose - Free all resources associated with a MPT 2061 * mpt_adapter_dispose - Free all resources associated with an MPT adapter
2051 * adapter.
2052 * @ioc: Pointer to MPT adapter structure 2062 * @ioc: Pointer to MPT adapter structure
2053 * 2063 *
2054 * This routine unregisters h/w resources and frees all alloc'd memory 2064 * This routine unregisters h/w resources and frees all alloc'd memory
@@ -2099,8 +2109,8 @@ mpt_adapter_dispose(MPT_ADAPTER *ioc)
2099} 2109}
2100 2110
2101/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2111/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2102/* 2112/**
2103 * MptDisplayIocCapabilities - Disply IOC's capacilities. 2113 * MptDisplayIocCapabilities - Disply IOC's capabilities.
2104 * @ioc: Pointer to MPT adapter structure 2114 * @ioc: Pointer to MPT adapter structure
2105 */ 2115 */
2106static void 2116static void
@@ -2142,7 +2152,7 @@ MptDisplayIocCapabilities(MPT_ADAPTER *ioc)
2142} 2152}
2143 2153
2144/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2154/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2145/* 2155/**
2146 * MakeIocReady - Get IOC to a READY state, using KickStart if needed. 2156 * MakeIocReady - Get IOC to a READY state, using KickStart if needed.
2147 * @ioc: Pointer to MPT_ADAPTER structure 2157 * @ioc: Pointer to MPT_ADAPTER structure
2148 * @force: Force hard KickStart of IOC 2158 * @force: Force hard KickStart of IOC
@@ -2279,7 +2289,7 @@ MakeIocReady(MPT_ADAPTER *ioc, int force, int sleepFlag)
2279} 2289}
2280 2290
2281/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2291/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2282/* 2292/**
2283 * mpt_GetIocState - Get the current state of a MPT adapter. 2293 * mpt_GetIocState - Get the current state of a MPT adapter.
2284 * @ioc: Pointer to MPT_ADAPTER structure 2294 * @ioc: Pointer to MPT_ADAPTER structure
2285 * @cooked: Request raw or cooked IOC state 2295 * @cooked: Request raw or cooked IOC state
@@ -2304,7 +2314,7 @@ mpt_GetIocState(MPT_ADAPTER *ioc, int cooked)
2304} 2314}
2305 2315
2306/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2316/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2307/* 2317/**
2308 * GetIocFacts - Send IOCFacts request to MPT adapter. 2318 * GetIocFacts - Send IOCFacts request to MPT adapter.
2309 * @ioc: Pointer to MPT_ADAPTER structure 2319 * @ioc: Pointer to MPT_ADAPTER structure
2310 * @sleepFlag: Specifies whether the process can sleep 2320 * @sleepFlag: Specifies whether the process can sleep
@@ -2478,7 +2488,7 @@ GetIocFacts(MPT_ADAPTER *ioc, int sleepFlag, int reason)
2478} 2488}
2479 2489
2480/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2490/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2481/* 2491/**
2482 * GetPortFacts - Send PortFacts request to MPT adapter. 2492 * GetPortFacts - Send PortFacts request to MPT adapter.
2483 * @ioc: Pointer to MPT_ADAPTER structure 2493 * @ioc: Pointer to MPT_ADAPTER structure
2484 * @portnum: Port number 2494 * @portnum: Port number
@@ -2545,7 +2555,7 @@ GetPortFacts(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2545} 2555}
2546 2556
2547/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2557/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2548/* 2558/**
2549 * SendIocInit - Send IOCInit request to MPT adapter. 2559 * SendIocInit - Send IOCInit request to MPT adapter.
2550 * @ioc: Pointer to MPT_ADAPTER structure 2560 * @ioc: Pointer to MPT_ADAPTER structure
2551 * @sleepFlag: Specifies whether the process can sleep 2561 * @sleepFlag: Specifies whether the process can sleep
@@ -2630,7 +2640,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2630 } 2640 }
2631 2641
2632 /* No need to byte swap the multibyte fields in the reply 2642 /* No need to byte swap the multibyte fields in the reply
2633 * since we don't even look at it's contents. 2643 * since we don't even look at its contents.
2634 */ 2644 */
2635 2645
2636 dhsprintk((MYIOC_s_INFO_FMT "Sending PortEnable (req @ %p)\n", 2646 dhsprintk((MYIOC_s_INFO_FMT "Sending PortEnable (req @ %p)\n",
@@ -2672,7 +2682,7 @@ SendIocInit(MPT_ADAPTER *ioc, int sleepFlag)
2672} 2682}
2673 2683
2674/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2684/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2675/* 2685/**
2676 * SendPortEnable - Send PortEnable request to MPT adapter port. 2686 * SendPortEnable - Send PortEnable request to MPT adapter port.
2677 * @ioc: Pointer to MPT_ADAPTER structure 2687 * @ioc: Pointer to MPT_ADAPTER structure
2678 * @portnum: Port number to enable 2688 * @portnum: Port number to enable
@@ -2723,9 +2733,13 @@ SendPortEnable(MPT_ADAPTER *ioc, int portnum, int sleepFlag)
2723 return rc; 2733 return rc;
2724} 2734}
2725 2735
2726/* 2736/**
2727 * ioc: Pointer to MPT_ADAPTER structure 2737 * mpt_alloc_fw_memory - allocate firmware memory
2728 * size - total FW bytes 2738 * @ioc: Pointer to MPT_ADAPTER structure
2739 * @size: total FW bytes
2740 *
2741 * If memory has already been allocated, the same (cached) value
2742 * is returned.
2729 */ 2743 */
2730void 2744void
2731mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size) 2745mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
@@ -2742,9 +2756,12 @@ mpt_alloc_fw_memory(MPT_ADAPTER *ioc, int size)
2742 ioc->alloc_total += size; 2756 ioc->alloc_total += size;
2743 } 2757 }
2744} 2758}
2745/* 2759/**
2746 * If alt_img is NULL, delete from ioc structure. 2760 * mpt_free_fw_memory - free firmware memory
2747 * Else, delete a secondary image in same format. 2761 * @ioc: Pointer to MPT_ADAPTER structure
2762 *
2763 * If alt_img is NULL, delete from ioc structure.
2764 * Else, delete a secondary image in same format.
2748 */ 2765 */
2749void 2766void
2750mpt_free_fw_memory(MPT_ADAPTER *ioc) 2767mpt_free_fw_memory(MPT_ADAPTER *ioc)
@@ -2763,7 +2780,7 @@ mpt_free_fw_memory(MPT_ADAPTER *ioc)
2763 2780
2764 2781
2765/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2782/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2766/* 2783/**
2767 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port. 2784 * mpt_do_upload - Construct and Send FWUpload request to MPT adapter port.
2768 * @ioc: Pointer to MPT_ADAPTER structure 2785 * @ioc: Pointer to MPT_ADAPTER structure
2769 * @sleepFlag: Specifies whether the process can sleep 2786 * @sleepFlag: Specifies whether the process can sleep
@@ -2865,10 +2882,10 @@ mpt_do_upload(MPT_ADAPTER *ioc, int sleepFlag)
2865} 2882}
2866 2883
2867/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2884/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2868/* 2885/**
2869 * mpt_downloadboot - DownloadBoot code 2886 * mpt_downloadboot - DownloadBoot code
2870 * @ioc: Pointer to MPT_ADAPTER structure 2887 * @ioc: Pointer to MPT_ADAPTER structure
2871 * @flag: Specify which part of IOC memory is to be uploaded. 2888 * @pFwHeader: Pointer to firmware header info
2872 * @sleepFlag: Specifies whether the process can sleep 2889 * @sleepFlag: Specifies whether the process can sleep
2873 * 2890 *
2874 * FwDownloadBoot requires Programmed IO access. 2891 * FwDownloadBoot requires Programmed IO access.
@@ -3071,7 +3088,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3071} 3088}
3072 3089
3073/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3090/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3074/* 3091/**
3075 * KickStart - Perform hard reset of MPT adapter. 3092 * KickStart - Perform hard reset of MPT adapter.
3076 * @ioc: Pointer to MPT_ADAPTER structure 3093 * @ioc: Pointer to MPT_ADAPTER structure
3077 * @force: Force hard reset 3094 * @force: Force hard reset
@@ -3145,12 +3162,12 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3145} 3162}
3146 3163
3147/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3164/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3148/* 3165/**
3149 * mpt_diag_reset - Perform hard reset of the adapter. 3166 * mpt_diag_reset - Perform hard reset of the adapter.
3150 * @ioc: Pointer to MPT_ADAPTER structure 3167 * @ioc: Pointer to MPT_ADAPTER structure
3151 * @ignore: Set if to honor and clear to ignore 3168 * @ignore: Set if to honor and clear to ignore
3152 * the reset history bit 3169 * the reset history bit
3153 * @sleepflag: CAN_SLEEP if called in a non-interrupt thread, 3170 * @sleepFlag: CAN_SLEEP if called in a non-interrupt thread,
3154 * else set to NO_SLEEP (use mdelay instead) 3171 * else set to NO_SLEEP (use mdelay instead)
3155 * 3172 *
3156 * This routine places the adapter in diagnostic mode via the 3173 * This routine places the adapter in diagnostic mode via the
@@ -3436,11 +3453,12 @@ mpt_diag_reset(MPT_ADAPTER *ioc, int ignore, int sleepFlag)
3436} 3453}
3437 3454
3438/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3455/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3439/* 3456/**
3440 * SendIocReset - Send IOCReset request to MPT adapter. 3457 * SendIocReset - Send IOCReset request to MPT adapter.
3441 * @ioc: Pointer to MPT_ADAPTER structure 3458 * @ioc: Pointer to MPT_ADAPTER structure
3442 * @reset_type: reset type, expected values are 3459 * @reset_type: reset type, expected values are
3443 * %MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET or %MPI_FUNCTION_IO_UNIT_RESET 3460 * %MPI_FUNCTION_IOC_MESSAGE_UNIT_RESET or %MPI_FUNCTION_IO_UNIT_RESET
3461 * @sleepFlag: Specifies whether the process can sleep
3444 * 3462 *
3445 * Send IOCReset request to the MPT adapter. 3463 * Send IOCReset request to the MPT adapter.
3446 * 3464 *
@@ -3494,11 +3512,12 @@ SendIocReset(MPT_ADAPTER *ioc, u8 reset_type, int sleepFlag)
3494} 3512}
3495 3513
3496/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3514/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3497/* 3515/**
3498 * initChainBuffers - Allocate memory for and initialize 3516 * initChainBuffers - Allocate memory for and initialize chain buffers
3499 * chain buffers, chain buffer control arrays and spinlock. 3517 * @ioc: Pointer to MPT_ADAPTER structure
3500 * @hd: Pointer to MPT_SCSI_HOST structure 3518 *
3501 * @init: If set, initialize the spin lock. 3519 * Allocates memory for and initializes chain buffers,
3520 * chain buffer control arrays and spinlock.
3502 */ 3521 */
3503static int 3522static int
3504initChainBuffers(MPT_ADAPTER *ioc) 3523initChainBuffers(MPT_ADAPTER *ioc)
@@ -3594,7 +3613,7 @@ initChainBuffers(MPT_ADAPTER *ioc)
3594} 3613}
3595 3614
3596/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3615/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3597/* 3616/**
3598 * PrimeIocFifos - Initialize IOC request and reply FIFOs. 3617 * PrimeIocFifos - Initialize IOC request and reply FIFOs.
3599 * @ioc: Pointer to MPT_ADAPTER structure 3618 * @ioc: Pointer to MPT_ADAPTER structure
3600 * 3619 *
@@ -3891,15 +3910,15 @@ mpt_handshake_req_reply_wait(MPT_ADAPTER *ioc, int reqBytes, u32 *req,
3891} 3910}
3892 3911
3893/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3912/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3894/* 3913/**
3895 * WaitForDoorbellAck - Wait for IOC to clear the IOP_DOORBELL_STATUS bit 3914 * WaitForDoorbellAck - Wait for IOC doorbell handshake acknowledge
3896 * in it's IntStatus register.
3897 * @ioc: Pointer to MPT_ADAPTER structure 3915 * @ioc: Pointer to MPT_ADAPTER structure
3898 * @howlong: How long to wait (in seconds) 3916 * @howlong: How long to wait (in seconds)
3899 * @sleepFlag: Specifies whether the process can sleep 3917 * @sleepFlag: Specifies whether the process can sleep
3900 * 3918 *
3901 * This routine waits (up to ~2 seconds max) for IOC doorbell 3919 * This routine waits (up to ~2 seconds max) for IOC doorbell
3902 * handshake ACKnowledge. 3920 * handshake ACKnowledge, indicated by the IOP_DOORBELL_STATUS
3921 * bit in its IntStatus register being clear.
3903 * 3922 *
3904 * Returns a negative value on failure, else wait loop count. 3923 * Returns a negative value on failure, else wait loop count.
3905 */ 3924 */
@@ -3942,14 +3961,14 @@ WaitForDoorbellAck(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3942} 3961}
3943 3962
3944/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3963/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3945/* 3964/**
3946 * WaitForDoorbellInt - Wait for IOC to set the HIS_DOORBELL_INTERRUPT bit 3965 * WaitForDoorbellInt - Wait for IOC to set its doorbell interrupt bit
3947 * in it's IntStatus register.
3948 * @ioc: Pointer to MPT_ADAPTER structure 3966 * @ioc: Pointer to MPT_ADAPTER structure
3949 * @howlong: How long to wait (in seconds) 3967 * @howlong: How long to wait (in seconds)
3950 * @sleepFlag: Specifies whether the process can sleep 3968 * @sleepFlag: Specifies whether the process can sleep
3951 * 3969 *
3952 * This routine waits (up to ~2 seconds max) for IOC doorbell interrupt. 3970 * This routine waits (up to ~2 seconds max) for IOC doorbell interrupt
3971 * (MPI_HIS_DOORBELL_INTERRUPT) to be set in the IntStatus register.
3953 * 3972 *
3954 * Returns a negative value on failure, else wait loop count. 3973 * Returns a negative value on failure, else wait loop count.
3955 */ 3974 */
@@ -3991,8 +4010,8 @@ WaitForDoorbellInt(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
3991} 4010}
3992 4011
3993/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4012/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3994/* 4013/**
3995 * WaitForDoorbellReply - Wait for and capture a IOC handshake reply. 4014 * WaitForDoorbellReply - Wait for and capture an IOC handshake reply.
3996 * @ioc: Pointer to MPT_ADAPTER structure 4015 * @ioc: Pointer to MPT_ADAPTER structure
3997 * @howlong: How long to wait (in seconds) 4016 * @howlong: How long to wait (in seconds)
3998 * @sleepFlag: Specifies whether the process can sleep 4017 * @sleepFlag: Specifies whether the process can sleep
@@ -4077,7 +4096,7 @@ WaitForDoorbellReply(MPT_ADAPTER *ioc, int howlong, int sleepFlag)
4077} 4096}
4078 4097
4079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4098/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4080/* 4099/**
4081 * GetLanConfigPages - Fetch LANConfig pages. 4100 * GetLanConfigPages - Fetch LANConfig pages.
4082 * @ioc: Pointer to MPT_ADAPTER structure 4101 * @ioc: Pointer to MPT_ADAPTER structure
4083 * 4102 *
@@ -4188,12 +4207,9 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
4188} 4207}
4189 4208
4190/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4209/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4191/* 4210/**
4192 * mptbase_sas_persist_operation - Perform operation on SAS Persitent Table 4211 * mptbase_sas_persist_operation - Perform operation on SAS Persistent Table
4193 * @ioc: Pointer to MPT_ADAPTER structure 4212 * @ioc: Pointer to MPT_ADAPTER structure
4194 * @sas_address: 64bit SAS Address for operation.
4195 * @target_id: specified target for operation
4196 * @bus: specified bus for operation
4197 * @persist_opcode: see below 4213 * @persist_opcode: see below
4198 * 4214 *
4199 * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for 4215 * MPI_SAS_OP_CLEAR_NOT_PRESENT - Free all persist TargetID mappings for
@@ -4202,7 +4218,7 @@ GetLanConfigPages(MPT_ADAPTER *ioc)
4202 * 4218 *
4203 * NOTE: Don't use not this function during interrupt time. 4219 * NOTE: Don't use not this function during interrupt time.
4204 * 4220 *
4205 * Returns: 0 for success, non-zero error 4221 * Returns 0 for success, non-zero error
4206 */ 4222 */
4207 4223
4208/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4224/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -4399,7 +4415,7 @@ mptbase_raid_process_event_data(MPT_ADAPTER *ioc,
4399} 4415}
4400 4416
4401/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4417/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4402/* 4418/**
4403 * GetIoUnitPage2 - Retrieve BIOS version and boot order information. 4419 * GetIoUnitPage2 - Retrieve BIOS version and boot order information.
4404 * @ioc: Pointer to MPT_ADAPTER structure 4420 * @ioc: Pointer to MPT_ADAPTER structure
4405 * 4421 *
@@ -4457,7 +4473,8 @@ GetIoUnitPage2(MPT_ADAPTER *ioc)
4457} 4473}
4458 4474
4459/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4475/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4460/* mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2 4476/**
4477 * mpt_GetScsiPortSettings - read SCSI Port Page 0 and 2
4461 * @ioc: Pointer to a Adapter Strucutre 4478 * @ioc: Pointer to a Adapter Strucutre
4462 * @portnum: IOC port number 4479 * @portnum: IOC port number
4463 * 4480 *
@@ -4644,7 +4661,8 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
4644} 4661}
4645 4662
4646/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 4663/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4647/* mpt_readScsiDevicePageHeaders - save version and length of SDP1 4664/**
4665 * mpt_readScsiDevicePageHeaders - save version and length of SDP1
4648 * @ioc: Pointer to a Adapter Strucutre 4666 * @ioc: Pointer to a Adapter Strucutre
4649 * @portnum: IOC port number 4667 * @portnum: IOC port number
4650 * 4668 *
@@ -4996,9 +5014,8 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
4996} 5014}
4997 5015
4998/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5016/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4999/* 5017/**
5000 * SendEventNotification - Send EventNotification (on or off) request 5018 * SendEventNotification - Send EventNotification (on or off) request to adapter
5001 * to MPT adapter.
5002 * @ioc: Pointer to MPT_ADAPTER structure 5019 * @ioc: Pointer to MPT_ADAPTER structure
5003 * @EvSwitch: Event switch flags 5020 * @EvSwitch: Event switch flags
5004 */ 5021 */
@@ -5062,8 +5079,8 @@ SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp)
5062/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5063/** 5080/**
5064 * mpt_config - Generic function to issue config message 5081 * mpt_config - Generic function to issue config message
5065 * @ioc - Pointer to an adapter structure 5082 * @ioc: Pointer to an adapter structure
5066 * @cfg - Pointer to a configuration structure. Struct contains 5083 * @pCfg: Pointer to a configuration structure. Struct contains
5067 * action, page address, direction, physical address 5084 * action, page address, direction, physical address
5068 * and pointer to a configuration page header 5085 * and pointer to a configuration page header
5069 * Page header is updated. 5086 * Page header is updated.
@@ -5188,8 +5205,8 @@ mpt_config(MPT_ADAPTER *ioc, CONFIGPARMS *pCfg)
5188} 5205}
5189 5206
5190/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5207/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5191/* 5208/**
5192 * mpt_timer_expired - Call back for timer process. 5209 * mpt_timer_expired - Callback for timer process.
5193 * Used only internal config functionality. 5210 * Used only internal config functionality.
5194 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long 5211 * @data: Pointer to MPT_SCSI_HOST recast as an unsigned long
5195 */ 5212 */
@@ -5214,12 +5231,12 @@ mpt_timer_expired(unsigned long data)
5214} 5231}
5215 5232
5216/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5233/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5217/* 5234/**
5218 * mpt_ioc_reset - Base cleanup for hard reset 5235 * mpt_ioc_reset - Base cleanup for hard reset
5219 * @ioc: Pointer to the adapter structure 5236 * @ioc: Pointer to the adapter structure
5220 * @reset_phase: Indicates pre- or post-reset functionality 5237 * @reset_phase: Indicates pre- or post-reset functionality
5221 * 5238 *
5222 * Remark: Free's resources with internally generated commands. 5239 * Remark: Frees resources with internally generated commands.
5223 */ 5240 */
5224static int 5241static int
5225mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase) 5242mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
@@ -5271,7 +5288,7 @@ mpt_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
5271 * procfs (%MPT_PROCFS_MPTBASEDIR/...) support stuff... 5288 * procfs (%MPT_PROCFS_MPTBASEDIR/...) support stuff...
5272 */ 5289 */
5273/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5290/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5274/* 5291/**
5275 * procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries. 5292 * procmpt_create - Create %MPT_PROCFS_MPTBASEDIR entries.
5276 * 5293 *
5277 * Returns 0 for success, non-zero for failure. 5294 * Returns 0 for success, non-zero for failure.
@@ -5297,7 +5314,7 @@ procmpt_create(void)
5297} 5314}
5298 5315
5299/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5316/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5300/* 5317/**
5301 * procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries. 5318 * procmpt_destroy - Tear down %MPT_PROCFS_MPTBASEDIR entries.
5302 * 5319 *
5303 * Returns 0 for success, non-zero for failure. 5320 * Returns 0 for success, non-zero for failure.
@@ -5311,16 +5328,16 @@ procmpt_destroy(void)
5311} 5328}
5312 5329
5313/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5330/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5314/* 5331/**
5315 * procmpt_summary_read - Handle read request from /proc/mpt/summary 5332 * procmpt_summary_read - Handle read request of a summary file
5316 * or from /proc/mpt/iocN/summary.
5317 * @buf: Pointer to area to write information 5333 * @buf: Pointer to area to write information
5318 * @start: Pointer to start pointer 5334 * @start: Pointer to start pointer
5319 * @offset: Offset to start writing 5335 * @offset: Offset to start writing
5320 * @request: 5336 * @request: Amount of read data requested
5321 * @eof: Pointer to EOF integer 5337 * @eof: Pointer to EOF integer
5322 * @data: Pointer 5338 * @data: Pointer
5323 * 5339 *
5340 * Handles read request from /proc/mpt/summary or /proc/mpt/iocN/summary.
5324 * Returns number of characters written to process performing the read. 5341 * Returns number of characters written to process performing the read.
5325 */ 5342 */
5326static int 5343static int
@@ -5355,12 +5372,12 @@ procmpt_summary_read(char *buf, char **start, off_t offset, int request, int *eo
5355} 5372}
5356 5373
5357/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5374/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5358/* 5375/**
5359 * procmpt_version_read - Handle read request from /proc/mpt/version. 5376 * procmpt_version_read - Handle read request from /proc/mpt/version.
5360 * @buf: Pointer to area to write information 5377 * @buf: Pointer to area to write information
5361 * @start: Pointer to start pointer 5378 * @start: Pointer to start pointer
5362 * @offset: Offset to start writing 5379 * @offset: Offset to start writing
5363 * @request: 5380 * @request: Amount of read data requested
5364 * @eof: Pointer to EOF integer 5381 * @eof: Pointer to EOF integer
5365 * @data: Pointer 5382 * @data: Pointer
5366 * 5383 *
@@ -5411,12 +5428,12 @@ procmpt_version_read(char *buf, char **start, off_t offset, int request, int *eo
5411} 5428}
5412 5429
5413/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5430/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5414/* 5431/**
5415 * procmpt_iocinfo_read - Handle read request from /proc/mpt/iocN/info. 5432 * procmpt_iocinfo_read - Handle read request from /proc/mpt/iocN/info.
5416 * @buf: Pointer to area to write information 5433 * @buf: Pointer to area to write information
5417 * @start: Pointer to start pointer 5434 * @start: Pointer to start pointer
5418 * @offset: Offset to start writing 5435 * @offset: Offset to start writing
5419 * @request: 5436 * @request: Amount of read data requested
5420 * @eof: Pointer to EOF integer 5437 * @eof: Pointer to EOF integer
5421 * @data: Pointer 5438 * @data: Pointer
5422 * 5439 *
@@ -5577,16 +5594,17 @@ mpt_print_ioc_summary(MPT_ADAPTER *ioc, char *buffer, int *size, int len, int sh
5577 */ 5594 */
5578/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5595/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5579/** 5596/**
5580 * mpt_HardResetHandler - Generic reset handler, issue SCSI Task 5597 * mpt_HardResetHandler - Generic reset handler
5581 * Management call based on input arg values. If TaskMgmt fails,
5582 * return associated SCSI request.
5583 * @ioc: Pointer to MPT_ADAPTER structure 5598 * @ioc: Pointer to MPT_ADAPTER structure
5584 * @sleepFlag: Indicates if sleep or schedule must be called. 5599 * @sleepFlag: Indicates if sleep or schedule must be called.
5585 * 5600 *
5601 * Issues SCSI Task Management call based on input arg values.
5602 * If TaskMgmt fails, returns associated SCSI request.
5603 *
5586 * Remark: _HardResetHandler can be invoked from an interrupt thread (timer) 5604 * Remark: _HardResetHandler can be invoked from an interrupt thread (timer)
5587 * or a non-interrupt thread. In the former, must not call schedule(). 5605 * or a non-interrupt thread. In the former, must not call schedule().
5588 * 5606 *
5589 * Remark: A return of -1 is a FATAL error case, as it means a 5607 * Note: A return of -1 is a FATAL error case, as it means a
5590 * FW reload/initialization failed. 5608 * FW reload/initialization failed.
5591 * 5609 *
5592 * Returns 0 for SUCCESS or -1 if FAILED. 5610 * Returns 0 for SUCCESS or -1 if FAILED.
@@ -5935,13 +5953,14 @@ EventDescriptionStr(u8 event, u32 evData0, char *evStr)
5935} 5953}
5936 5954
5937/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5955/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5938/* 5956/**
5939 * ProcessEventNotification - Route a received EventNotificationReply to 5957 * ProcessEventNotification - Route EventNotificationReply to all event handlers
5940 * all currently regeistered event handlers.
5941 * @ioc: Pointer to MPT_ADAPTER structure 5958 * @ioc: Pointer to MPT_ADAPTER structure
5942 * @pEventReply: Pointer to EventNotification reply frame 5959 * @pEventReply: Pointer to EventNotification reply frame
5943 * @evHandlers: Pointer to integer, number of event handlers 5960 * @evHandlers: Pointer to integer, number of event handlers
5944 * 5961 *
5962 * Routes a received EventNotificationReply to all currently registered
5963 * event handlers.
5945 * Returns sum of event handlers return values. 5964 * Returns sum of event handlers return values.
5946 */ 5965 */
5947static int 5966static int
@@ -6056,7 +6075,7 @@ ProcessEventNotification(MPT_ADAPTER *ioc, EventNotificationReply_t *pEventReply
6056} 6075}
6057 6076
6058/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6077/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6059/* 6078/**
6060 * mpt_fc_log_info - Log information returned from Fibre Channel IOC. 6079 * mpt_fc_log_info - Log information returned from Fibre Channel IOC.
6061 * @ioc: Pointer to MPT_ADAPTER structure 6080 * @ioc: Pointer to MPT_ADAPTER structure
6062 * @log_info: U32 LogInfo reply word from the IOC 6081 * @log_info: U32 LogInfo reply word from the IOC
@@ -6077,7 +6096,7 @@ mpt_fc_log_info(MPT_ADAPTER *ioc, u32 log_info)
6077} 6096}
6078 6097
6079/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6098/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6080/* 6099/**
6081 * mpt_spi_log_info - Log information returned from SCSI Parallel IOC. 6100 * mpt_spi_log_info - Log information returned from SCSI Parallel IOC.
6082 * @ioc: Pointer to MPT_ADAPTER structure 6101 * @ioc: Pointer to MPT_ADAPTER structure
6083 * @mr: Pointer to MPT reply frame 6102 * @mr: Pointer to MPT reply frame
@@ -6200,7 +6219,7 @@ mpt_spi_log_info(MPT_ADAPTER *ioc, u32 log_info)
6200 }; 6219 };
6201 6220
6202/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6221/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6203/* 6222/**
6204 * mpt_sas_log_info - Log information returned from SAS IOC. 6223 * mpt_sas_log_info - Log information returned from SAS IOC.
6205 * @ioc: Pointer to MPT_ADAPTER structure 6224 * @ioc: Pointer to MPT_ADAPTER structure
6206 * @log_info: U32 LogInfo reply word from the IOC 6225 * @log_info: U32 LogInfo reply word from the IOC
@@ -6255,7 +6274,7 @@ union loginfo_type {
6255} 6274}
6256 6275
6257/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6276/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6258/* 6277/**
6259 * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC. 6278 * mpt_sp_ioc_info - IOC information returned from SCSI Parallel IOC.
6260 * @ioc: Pointer to MPT_ADAPTER structure 6279 * @ioc: Pointer to MPT_ADAPTER structure
6261 * @ioc_status: U32 IOCStatus word from IOC 6280 * @ioc_status: U32 IOCStatus word from IOC
@@ -6416,7 +6435,7 @@ EXPORT_SYMBOL(mpt_free_fw_memory);
6416EXPORT_SYMBOL(mptbase_sas_persist_operation); 6435EXPORT_SYMBOL(mptbase_sas_persist_operation);
6417 6436
6418/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6437/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6419/* 6438/**
6420 * fusion_init - Fusion MPT base driver initialization routine. 6439 * fusion_init - Fusion MPT base driver initialization routine.
6421 * 6440 *
6422 * Returns 0 for success, non-zero for failure. 6441 * Returns 0 for success, non-zero for failure.
@@ -6456,7 +6475,7 @@ fusion_init(void)
6456} 6475}
6457 6476
6458/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6477/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
6459/* 6478/**
6460 * fusion_exit - Perform driver unload cleanup. 6479 * fusion_exit - Perform driver unload cleanup.
6461 * 6480 *
6462 * This routine frees all resources associated with each MPT adapter 6481 * This routine frees all resources associated with each MPT adapter
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index ef2b55e19910..ca2f9107f145 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -1395,8 +1395,7 @@ mptfc_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
1395 1395
1396/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1396/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1397/** 1397/**
1398 * mptfc_init - Register MPT adapter(s) as SCSI host(s) with 1398 * mptfc_init - Register MPT adapter(s) as SCSI host(s) with SCSI mid-layer.
1399 * linux scsi mid-layer.
1400 * 1399 *
1401 * Returns 0 for success, non-zero for failure. 1400 * Returns 0 for success, non-zero for failure.
1402 */ 1401 */
@@ -1440,7 +1439,7 @@ mptfc_init(void)
1440 1439
1441/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1440/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1442/** 1441/**
1443 * mptfc_remove - Removed fc infrastructure for devices 1442 * mptfc_remove - Remove fc infrastructure for devices
1444 * @pdev: Pointer to pci_dev structure 1443 * @pdev: Pointer to pci_dev structure
1445 * 1444 *
1446 */ 1445 */
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 30524dc54b16..2c72c36b8171 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1230,15 +1230,15 @@ mptscsih_host_info(MPT_ADAPTER *ioc, char *pbuf, off_t offset, int len)
1230/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1230/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1231/** 1231/**
1232 * mptscsih_proc_info - Return information about MPT adapter 1232 * mptscsih_proc_info - Return information about MPT adapter
1233 * @host: scsi host struct
1234 * @buffer: if write, user data; if read, buffer for user
1235 * @start: returns the buffer address
1236 * @offset: if write, 0; if read, the current offset into the buffer from
1237 * the previous read.
1238 * @length: if write, return length;
1239 * @func: write = 1; read = 0
1233 * 1240 *
1234 * (linux scsi_host_template.info routine) 1241 * (linux scsi_host_template.info routine)
1235 *
1236 * buffer: if write, user data; if read, buffer for user
1237 * length: if write, return length;
1238 * offset: if write, 0; if read, the current offset into the buffer from
1239 * the previous read.
1240 * hostno: scsi host number
1241 * func: if write = 1; if read = 0
1242 */ 1242 */
1243int 1243int
1244mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, 1244mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset,
@@ -1902,8 +1902,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1902 1902
1903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1903/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1904/** 1904/**
1905 * mptscsih_host_reset - Perform a SCSI host adapter RESET! 1905 * mptscsih_host_reset - Perform a SCSI host adapter RESET (new_eh variant)
1906 * new_eh variant
1907 * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to 1906 * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to
1908 * 1907 *
1909 * (linux scsi_host_template.eh_host_reset_handler routine) 1908 * (linux scsi_host_template.eh_host_reset_handler routine)
@@ -1949,8 +1948,7 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
1949 1948
1950/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1949/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1951/** 1950/**
1952 * mptscsih_tm_pending_wait - wait for pending task management request to 1951 * mptscsih_tm_pending_wait - wait for pending task management request to complete
1953 * complete.
1954 * @hd: Pointer to MPT host structure. 1952 * @hd: Pointer to MPT host structure.
1955 * 1953 *
1956 * Returns {SUCCESS,FAILED}. 1954 * Returns {SUCCESS,FAILED}.
@@ -1982,6 +1980,7 @@ mptscsih_tm_pending_wait(MPT_SCSI_HOST * hd)
1982/** 1980/**
1983 * mptscsih_tm_wait_for_completion - wait for completion of TM task 1981 * mptscsih_tm_wait_for_completion - wait for completion of TM task
1984 * @hd: Pointer to MPT host structure. 1982 * @hd: Pointer to MPT host structure.
1983 * @timeout: timeout in seconds
1985 * 1984 *
1986 * Returns {SUCCESS,FAILED}. 1985 * Returns {SUCCESS,FAILED}.
1987 */ 1986 */
@@ -3429,8 +3428,7 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3429/** 3428/**
3430 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks. 3429 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks.
3431 * @hd: Pointer to a SCSI HOST structure 3430 * @hd: Pointer to a SCSI HOST structure
3432 * @vtarget: per device private data 3431 * @vdevice: virtual target device
3433 * @lun: lun
3434 * 3432 *
3435 * Uses the ISR, but with special processing. 3433 * Uses the ISR, but with special processing.
3436 * MUST be single-threaded. 3434 * MUST be single-threaded.
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index f422c0d0621c..36641da59289 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -1100,8 +1100,7 @@ static struct pci_driver mptspi_driver = {
1100 1100
1101/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1101/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1102/** 1102/**
1103 * mptspi_init - Register MPT adapter(s) as SCSI host(s) with 1103 * mptspi_init - Register MPT adapter(s) as SCSI host(s) with SCSI mid-layer.
1104 * linux scsi mid-layer.
1105 * 1104 *
1106 * Returns 0 for success, non-zero for failure. 1105 * Returns 0 for success, non-zero for failure.
1107 */ 1106 */
@@ -1135,7 +1134,6 @@ mptspi_init(void)
1135/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1134/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1136/** 1135/**
1137 * mptspi_exit - Unregisters MPT adapter(s) 1136 * mptspi_exit - Unregisters MPT adapter(s)
1138 *
1139 */ 1137 */
1140static void __exit 1138static void __exit
1141mptspi_exit(void) 1139mptspi_exit(void)
diff --git a/drivers/message/i2o/bus-osm.c b/drivers/message/i2o/bus-osm.c
index d96c687aee93..c463dc2efc09 100644
--- a/drivers/message/i2o/bus-osm.c
+++ b/drivers/message/i2o/bus-osm.c
@@ -56,6 +56,9 @@ static int i2o_bus_scan(struct i2o_device *dev)
56/** 56/**
57 * i2o_bus_store_scan - Scan the I2O Bus Adapter 57 * i2o_bus_store_scan - Scan the I2O Bus Adapter
58 * @d: device which should be scanned 58 * @d: device which should be scanned
59 * @attr: device_attribute
60 * @buf: output buffer
61 * @count: buffer size
59 * 62 *
60 * Returns count. 63 * Returns count.
61 */ 64 */
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index ee183053fa23..b9df143e4ff1 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -54,8 +54,8 @@ static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
54 * @dev: I2O device to claim 54 * @dev: I2O device to claim
55 * @drv: I2O driver which wants to claim the device 55 * @drv: I2O driver which wants to claim the device
56 * 56 *
57 * Do the leg work to assign a device to a given OSM. If the claim succeed 57 * Do the leg work to assign a device to a given OSM. If the claim succeeds,
58 * the owner of the rimary. If the attempt fails a negative errno code 58 * the owner is the primary. If the attempt fails a negative errno code
59 * is returned. On success zero is returned. 59 * is returned. On success zero is returned.
60 */ 60 */
61int i2o_device_claim(struct i2o_device *dev) 61int i2o_device_claim(struct i2o_device *dev)
@@ -208,24 +208,23 @@ static struct i2o_device *i2o_device_alloc(void)
208 208
209/** 209/**
210 * i2o_device_add - allocate a new I2O device and add it to the IOP 210 * i2o_device_add - allocate a new I2O device and add it to the IOP
211 * @iop: I2O controller where the device is on 211 * @c: I2O controller that the device is on
212 * @entry: LCT entry of the I2O device 212 * @entry: LCT entry of the I2O device
213 * 213 *
214 * Allocate a new I2O device and initialize it with the LCT entry. The 214 * Allocate a new I2O device and initialize it with the LCT entry. The
215 * device is appended to the device list of the controller. 215 * device is appended to the device list of the controller.
216 * 216 *
217 * Returns a pointer to the I2O device on success or negative error code 217 * Returns zero on success, or a -ve errno.
218 * on failure.
219 */ 218 */
220static struct i2o_device *i2o_device_add(struct i2o_controller *c, 219static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
221 i2o_lct_entry * entry)
222{ 220{
223 struct i2o_device *i2o_dev, *tmp; 221 struct i2o_device *i2o_dev, *tmp;
222 int rc;
224 223
225 i2o_dev = i2o_device_alloc(); 224 i2o_dev = i2o_device_alloc();
226 if (IS_ERR(i2o_dev)) { 225 if (IS_ERR(i2o_dev)) {
227 printk(KERN_ERR "i2o: unable to allocate i2o device\n"); 226 printk(KERN_ERR "i2o: unable to allocate i2o device\n");
228 return i2o_dev; 227 return PTR_ERR(i2o_dev);
229 } 228 }
230 229
231 i2o_dev->lct_data = *entry; 230 i2o_dev->lct_data = *entry;
@@ -236,7 +235,9 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
236 i2o_dev->iop = c; 235 i2o_dev->iop = c;
237 i2o_dev->device.parent = &c->device; 236 i2o_dev->device.parent = &c->device;
238 237
239 device_register(&i2o_dev->device); 238 rc = device_register(&i2o_dev->device);
239 if (rc)
240 goto err;
240 241
241 list_add_tail(&i2o_dev->list, &c->devices); 242 list_add_tail(&i2o_dev->list, &c->devices);
242 243
@@ -270,12 +271,16 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
270 271
271 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id); 272 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);
272 273
273 return i2o_dev; 274 return 0;
275
276err:
277 kfree(i2o_dev);
278 return rc;
274} 279}
275 280
276/** 281/**
277 * i2o_device_remove - remove an I2O device from the I2O core 282 * i2o_device_remove - remove an I2O device from the I2O core
278 * @dev: I2O device which should be released 283 * @i2o_dev: I2O device which should be released
279 * 284 *
280 * Is used on I2O controller removal or LCT modification, when the device 285 * Is used on I2O controller removal or LCT modification, when the device
281 * is removed from the system. Note that the device could still hang 286 * is removed from the system. Note that the device could still hang
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index 7fc7399bd2ec..9104b65ff70f 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -34,9 +34,7 @@ static spinlock_t i2o_drivers_lock;
34static struct i2o_driver **i2o_drivers; 34static struct i2o_driver **i2o_drivers;
35 35
36/** 36/**
37 * i2o_bus_match - Tell if a I2O device class id match the class ids of 37 * i2o_bus_match - Tell if I2O device class id matches the class ids of the I2O driver (OSM)
38 * the I2O driver (OSM)
39 *
40 * @dev: device which should be verified 38 * @dev: device which should be verified
41 * @drv: the driver to match against 39 * @drv: the driver to match against
42 * 40 *
@@ -248,7 +246,7 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
248 246
249/** 247/**
250 * i2o_driver_notify_controller_add_all - Send notify of added controller 248 * i2o_driver_notify_controller_add_all - Send notify of added controller
251 * to all I2O drivers 249 * @c: newly added controller
252 * 250 *
253 * Send notifications to all registered drivers that a new controller was 251 * Send notifications to all registered drivers that a new controller was
254 * added. 252 * added.
@@ -267,8 +265,8 @@ void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
267} 265}
268 266
269/** 267/**
270 * i2o_driver_notify_controller_remove_all - Send notify of removed 268 * i2o_driver_notify_controller_remove_all - Send notify of removed controller
271 * controller to all I2O drivers 269 * @c: controller that is being removed
272 * 270 *
273 * Send notifications to all registered drivers that a controller was 271 * Send notifications to all registered drivers that a controller was
274 * removed. 272 * removed.
@@ -287,8 +285,8 @@ void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
287} 285}
288 286
289/** 287/**
290 * i2o_driver_notify_device_add_all - Send notify of added device to all 288 * i2o_driver_notify_device_add_all - Send notify of added device
291 * I2O drivers 289 * @i2o_dev: newly added I2O device
292 * 290 *
293 * Send notifications to all registered drivers that a device was added. 291 * Send notifications to all registered drivers that a device was added.
294 */ 292 */
@@ -306,8 +304,8 @@ void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
306} 304}
307 305
308/** 306/**
309 * i2o_driver_notify_device_remove_all - Send notify of removed device to 307 * i2o_driver_notify_device_remove_all - Send notify of removed device
310 * all I2O drivers 308 * @i2o_dev: device that is being removed
311 * 309 *
312 * Send notifications to all registered drivers that a device was removed. 310 * Send notifications to all registered drivers that a device was removed.
313 */ 311 */
@@ -362,7 +360,7 @@ int __init i2o_driver_init(void)
362/** 360/**
363 * i2o_driver_exit - clean up I2O drivers (OSMs) 361 * i2o_driver_exit - clean up I2O drivers (OSMs)
364 * 362 *
365 * Unregisters the I2O bus and free driver array. 363 * Unregisters the I2O bus and frees driver array.
366 */ 364 */
367void __exit i2o_driver_exit(void) 365void __exit i2o_driver_exit(void)
368{ 366{
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 9e529d8dd5cb..902753b2c661 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -94,8 +94,8 @@ static struct i2o_exec_wait *i2o_exec_wait_alloc(void)
94}; 94};
95 95
96/** 96/**
97 * i2o_exec_wait_free - Free a i2o_exec_wait struct 97 * i2o_exec_wait_free - Free an i2o_exec_wait struct
98 * @i2o_exec_wait: I2O wait data which should be cleaned up 98 * @wait: I2O wait data which should be cleaned up
99 */ 99 */
100static void i2o_exec_wait_free(struct i2o_exec_wait *wait) 100static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
101{ 101{
@@ -105,7 +105,7 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
105/** 105/**
106 * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers 106 * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers
107 * @c: controller 107 * @c: controller
108 * @m: message to post 108 * @msg: message to post
109 * @timeout: time in seconds to wait 109 * @timeout: time in seconds to wait
110 * @dma: i2o_dma struct of the DMA buffer to free on failure 110 * @dma: i2o_dma struct of the DMA buffer to free on failure
111 * 111 *
@@ -269,6 +269,7 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
269/** 269/**
270 * i2o_exec_show_vendor_id - Displays Vendor ID of controller 270 * i2o_exec_show_vendor_id - Displays Vendor ID of controller
271 * @d: device of which the Vendor ID should be displayed 271 * @d: device of which the Vendor ID should be displayed
272 * @attr: device_attribute to display
272 * @buf: buffer into which the Vendor ID should be printed 273 * @buf: buffer into which the Vendor ID should be printed
273 * 274 *
274 * Returns number of bytes printed into buffer. 275 * Returns number of bytes printed into buffer.
@@ -290,6 +291,7 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d,
290/** 291/**
291 * i2o_exec_show_product_id - Displays Product ID of controller 292 * i2o_exec_show_product_id - Displays Product ID of controller
292 * @d: device of which the Product ID should be displayed 293 * @d: device of which the Product ID should be displayed
294 * @attr: device_attribute to display
293 * @buf: buffer into which the Product ID should be printed 295 * @buf: buffer into which the Product ID should be printed
294 * 296 *
295 * Returns number of bytes printed into buffer. 297 * Returns number of bytes printed into buffer.
@@ -365,7 +367,7 @@ static int i2o_exec_remove(struct device *dev)
365 367
366/** 368/**
367 * i2o_exec_lct_modified - Called on LCT NOTIFY reply 369 * i2o_exec_lct_modified - Called on LCT NOTIFY reply
368 * @c: I2O controller on which the LCT has modified 370 * @work: work struct for a specific controller
369 * 371 *
370 * This function handles asynchronus LCT NOTIFY replies. It parses the 372 * This function handles asynchronus LCT NOTIFY replies. It parses the
371 * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY 373 * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index 70ae00253321..da9859f2caf2 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -259,7 +259,7 @@ static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id)
259/** 259/**
260 * i2o_block_device_power - Power management for device dev 260 * i2o_block_device_power - Power management for device dev
261 * @dev: I2O device which should receive the power management request 261 * @dev: I2O device which should receive the power management request
262 * @operation: Operation which should be send 262 * @op: Operation to send
263 * 263 *
264 * Send a power management request to the device dev. 264 * Send a power management request to the device dev.
265 * 265 *
@@ -315,7 +315,7 @@ static inline struct i2o_block_request *i2o_block_request_alloc(void)
315 * i2o_block_request_free - Frees a I2O block request 315 * i2o_block_request_free - Frees a I2O block request
316 * @ireq: I2O block request which should be freed 316 * @ireq: I2O block request which should be freed
317 * 317 *
318 * Fres the allocated memory (give it back to the request mempool). 318 * Frees the allocated memory (give it back to the request mempool).
319 */ 319 */
320static inline void i2o_block_request_free(struct i2o_block_request *ireq) 320static inline void i2o_block_request_free(struct i2o_block_request *ireq)
321{ 321{
@@ -326,6 +326,7 @@ static inline void i2o_block_request_free(struct i2o_block_request *ireq)
326 * i2o_block_sglist_alloc - Allocate the SG list and map it 326 * i2o_block_sglist_alloc - Allocate the SG list and map it
327 * @c: I2O controller to which the request belongs 327 * @c: I2O controller to which the request belongs
328 * @ireq: I2O block request 328 * @ireq: I2O block request
329 * @mptr: message body pointer
329 * 330 *
330 * Builds the SG list and map it to be accessable by the controller. 331 * Builds the SG list and map it to be accessable by the controller.
331 * 332 *
@@ -490,7 +491,7 @@ static void i2o_block_end_request(struct request *req, int uptodate,
490 * i2o_block_reply - Block OSM reply handler. 491 * i2o_block_reply - Block OSM reply handler.
491 * @c: I2O controller from which the message arrives 492 * @c: I2O controller from which the message arrives
492 * @m: message id of reply 493 * @m: message id of reply
493 * qmsg: the actuall I2O message reply 494 * @msg: the actual I2O message reply
494 * 495 *
495 * This function gets all the message replies. 496 * This function gets all the message replies.
496 * 497 *
@@ -602,6 +603,8 @@ static void i2o_block_biosparam(unsigned long capacity, unsigned short *cyls,
602 603
603/** 604/**
604 * i2o_block_open - Open the block device 605 * i2o_block_open - Open the block device
606 * @inode: inode for block device being opened
607 * @file: file to open
605 * 608 *
606 * Power up the device, mount and lock the media. This function is called, 609 * Power up the device, mount and lock the media. This function is called,
607 * if the block device is opened for access. 610 * if the block device is opened for access.
@@ -629,6 +632,8 @@ static int i2o_block_open(struct inode *inode, struct file *file)
629 632
630/** 633/**
631 * i2o_block_release - Release the I2O block device 634 * i2o_block_release - Release the I2O block device
635 * @inode: inode for block device being released
636 * @file: file to close
632 * 637 *
633 * Unlock and unmount the media, and power down the device. Gets called if 638 * Unlock and unmount the media, and power down the device. Gets called if
634 * the block device is closed. 639 * the block device is closed.
@@ -675,6 +680,8 @@ static int i2o_block_getgeo(struct block_device *bdev, struct hd_geometry *geo)
675 680
676/** 681/**
677 * i2o_block_ioctl - Issue device specific ioctl calls. 682 * i2o_block_ioctl - Issue device specific ioctl calls.
683 * @inode: inode for block device ioctl
684 * @file: file for ioctl
678 * @cmd: ioctl command 685 * @cmd: ioctl command
679 * @arg: arg 686 * @arg: arg
680 * 687 *
@@ -902,7 +909,7 @@ static int i2o_block_transfer(struct request *req)
902 909
903/** 910/**
904 * i2o_block_request_fn - request queue handling function 911 * i2o_block_request_fn - request queue handling function
905 * q: request queue from which the request could be fetched 912 * @q: request queue from which the request could be fetched
906 * 913 *
907 * Takes the next request from the queue, transfers it and if no error 914 * Takes the next request from the queue, transfers it and if no error
908 * occurs dequeue it from the queue. On arrival of the reply the message 915 * occurs dequeue it from the queue. On arrival of the reply the message
diff --git a/drivers/message/i2o/i2o_block.h b/drivers/message/i2o/i2o_block.h
index d9fdc95b440d..67f921b4419b 100644
--- a/drivers/message/i2o/i2o_block.h
+++ b/drivers/message/i2o/i2o_block.h
@@ -64,7 +64,7 @@
64 64
65/* I2O Block OSM mempool struct */ 65/* I2O Block OSM mempool struct */
66struct i2o_block_mempool { 66struct i2o_block_mempool {
67 kmem_cache_t *slab; 67 struct kmem_cache *slab;
68 mempool_t *pool; 68 mempool_t *pool;
69}; 69};
70 70
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 7d23e082bf26..1de30d711671 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -265,7 +265,11 @@ static int i2o_cfg_swdl(unsigned long arg)
265 return -ENOMEM; 265 return -ENOMEM;
266 } 266 }
267 267
268 __copy_from_user(buffer.virt, kxfer.buf, fragsize); 268 if (__copy_from_user(buffer.virt, kxfer.buf, fragsize)) {
269 i2o_msg_nop(c, msg);
270 i2o_dma_free(&c->pdev->dev, &buffer);
271 return -EFAULT;
272 }
269 273
270 msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7); 274 msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7);
271 msg->u.head[1] = 275 msg->u.head[1] =
@@ -516,7 +520,6 @@ static int i2o_cfg_evt_get(unsigned long arg, struct file *fp)
516 return 0; 520 return 0;
517} 521}
518 522
519#ifdef CONFIG_I2O_EXT_ADAPTEC
520#ifdef CONFIG_COMPAT 523#ifdef CONFIG_COMPAT
521static int i2o_cfg_passthru32(struct file *file, unsigned cmnd, 524static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
522 unsigned long arg) 525 unsigned long arg)
@@ -759,6 +762,7 @@ static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd,
759 762
760#endif 763#endif
761 764
765#ifdef CONFIG_I2O_EXT_ADAPTEC
762static int i2o_cfg_passthru(unsigned long arg) 766static int i2o_cfg_passthru(unsigned long arg)
763{ 767{
764 struct i2o_cmd_passthru __user *cmd = 768 struct i2o_cmd_passthru __user *cmd =
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index 3d2e76eea93e..a61cb17c5c12 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -163,7 +163,7 @@ static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
163 * i2o_get_class_name - do i2o class name lookup 163 * i2o_get_class_name - do i2o class name lookup
164 * @class: class number 164 * @class: class number
165 * 165 *
166 * Return a descriptive string for an i2o class 166 * Return a descriptive string for an i2o class.
167 */ 167 */
168static const char *i2o_get_class_name(int class) 168static const char *i2o_get_class_name(int class)
169{ 169{
diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
index 6ebf38213f9f..1045c8a518bb 100644
--- a/drivers/message/i2o/i2o_scsi.c
+++ b/drivers/message/i2o/i2o_scsi.c
@@ -220,7 +220,7 @@ static int i2o_scsi_probe(struct device *dev)
220 u32 id = -1; 220 u32 id = -1;
221 u64 lun = -1; 221 u64 lun = -1;
222 int channel = -1; 222 int channel = -1;
223 int i; 223 int i, rc;
224 224
225 i2o_shost = i2o_scsi_get_host(c); 225 i2o_shost = i2o_scsi_get_host(c);
226 if (!i2o_shost) 226 if (!i2o_shost)
@@ -304,14 +304,20 @@ static int i2o_scsi_probe(struct device *dev)
304 return PTR_ERR(scsi_dev); 304 return PTR_ERR(scsi_dev);
305 } 305 }
306 306
307 sysfs_create_link(&i2o_dev->device.kobj, &scsi_dev->sdev_gendev.kobj, 307 rc = sysfs_create_link(&i2o_dev->device.kobj,
308 "scsi"); 308 &scsi_dev->sdev_gendev.kobj, "scsi");
309 if (rc)
310 goto err;
309 311
310 osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n", 312 osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n",
311 i2o_dev->lct_data.tid, channel, le32_to_cpu(id), 313 i2o_dev->lct_data.tid, channel, le32_to_cpu(id),
312 (long unsigned int)le64_to_cpu(lun)); 314 (long unsigned int)le64_to_cpu(lun));
313 315
314 return 0; 316 return 0;
317
318err:
319 scsi_remove_device(scsi_dev);
320 return rc;
315}; 321};
316 322
317static const char *i2o_scsi_info(struct Scsi_Host *SChost) 323static const char *i2o_scsi_info(struct Scsi_Host *SChost)
@@ -405,8 +411,7 @@ static void i2o_scsi_notify_device_add(struct i2o_device *i2o_dev)
405}; 411};
406 412
407/** 413/**
408 * i2o_scsi_notify_device_remove - Retrieve notifications of removed 414 * i2o_scsi_notify_device_remove - Retrieve notifications of removed devices
409 * devices
410 * @i2o_dev: the I2O device which was removed 415 * @i2o_dev: the I2O device which was removed
411 * 416 *
412 * If a I2O device is removed, we catch the notification to remove the 417 * If a I2O device is removed, we catch the notification to remove the
@@ -426,8 +431,7 @@ static void i2o_scsi_notify_device_remove(struct i2o_device *i2o_dev)
426}; 431};
427 432
428/** 433/**
429 * i2o_scsi_notify_controller_add - Retrieve notifications of added 434 * i2o_scsi_notify_controller_add - Retrieve notifications of added controllers
430 * controllers
431 * @c: the controller which was added 435 * @c: the controller which was added
432 * 436 *
433 * If a I2O controller is added, we catch the notification to add a 437 * If a I2O controller is added, we catch the notification to add a
@@ -457,8 +461,7 @@ static void i2o_scsi_notify_controller_add(struct i2o_controller *c)
457}; 461};
458 462
459/** 463/**
460 * i2o_scsi_notify_controller_remove - Retrieve notifications of removed 464 * i2o_scsi_notify_controller_remove - Retrieve notifications of removed controllers
461 * controllers
462 * @c: the controller which was removed 465 * @c: the controller which was removed
463 * 466 *
464 * If a I2O controller is removed, we catch the notification to remove the 467 * If a I2O controller is removed, we catch the notification to remove the
@@ -745,7 +748,7 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
745 * @capacity: size in sectors 748 * @capacity: size in sectors
746 * @ip: geometry array 749 * @ip: geometry array
747 * 750 *
748 * This is anyones guess quite frankly. We use the same rules everyone 751 * This is anyone's guess quite frankly. We use the same rules everyone
749 * else appears to and hope. It seems to work. 752 * else appears to and hope. It seems to work.
750 */ 753 */
751 754
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 8287f95c8c42..3661e6e065d2 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -259,6 +259,7 @@ static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id)
259 259
260/** 260/**
261 * i2o_pci_irq_enable - Allocate interrupt for I2O controller 261 * i2o_pci_irq_enable - Allocate interrupt for I2O controller
262 * @c: i2o_controller that the request is for
262 * 263 *
263 * Allocate an interrupt for the I2O controller, and activate interrupts 264 * Allocate an interrupt for the I2O controller, and activate interrupts
264 * on the I2O controller. 265 * on the I2O controller.
@@ -305,7 +306,7 @@ static void i2o_pci_irq_disable(struct i2o_controller *c)
305 306
306/** 307/**
307 * i2o_pci_probe - Probe the PCI device for an I2O controller 308 * i2o_pci_probe - Probe the PCI device for an I2O controller
308 * @dev: PCI device to test 309 * @pdev: PCI device to test
309 * @id: id which matched with the PCI device id table 310 * @id: id which matched with the PCI device id table
310 * 311 *
311 * Probe the PCI device for any device which is a memory of the 312 * Probe the PCI device for any device which is a memory of the
@@ -447,7 +448,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
447 448
448/** 449/**
449 * i2o_pci_remove - Removes a I2O controller from the system 450 * i2o_pci_remove - Removes a I2O controller from the system
450 * pdev: I2O controller which should be removed 451 * @pdev: I2O controller which should be removed
451 * 452 *
452 * Reset the I2O controller, disable interrupts and remove all allocated 453 * Reset the I2O controller, disable interrupts and remove all allocated
453 * resources. 454 * resources.
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index 82938ad6ddbd..ce1a48108210 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -28,7 +28,7 @@
28#include <linux/string.h> 28#include <linux/string.h>
29#include <linux/input.h> 29#include <linux/input.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/suspend.h> 31#include <linux/freezer.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34 34
diff --git a/drivers/misc/tifm_core.c b/drivers/misc/tifm_core.c
index ee326136d03b..d61df5c3ac36 100644
--- a/drivers/misc/tifm_core.c
+++ b/drivers/misc/tifm_core.c
@@ -219,8 +219,9 @@ static int tifm_device_remove(struct device *dev)
219 struct tifm_driver *drv = fm_dev->drv; 219 struct tifm_driver *drv = fm_dev->drv;
220 220
221 if (drv) { 221 if (drv) {
222 if (drv->remove) drv->remove(fm_dev); 222 if (drv->remove)
223 fm_dev->drv = 0; 223 drv->remove(fm_dev);
224 fm_dev->drv = NULL;
224 } 225 }
225 226
226 put_device(dev); 227 put_device(dev);
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index ef4a731ca5c2..334e078ffaff 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -451,7 +451,7 @@ static int __devinit m25p_probe(struct spi_device *spi)
451 return -ENODEV; 451 return -ENODEV;
452 } 452 }
453 453
454 flash = kzalloc(sizeof *flash, SLAB_KERNEL); 454 flash = kzalloc(sizeof *flash, GFP_KERNEL);
455 if (!flash) 455 if (!flash)
456 return -ENOMEM; 456 return -ENOMEM;
457 457
diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c
index 11d170afa9c3..06e33786078d 100644
--- a/drivers/net/3c501.c
+++ b/drivers/net/3c501.c
@@ -922,7 +922,7 @@ int __init init_module(void)
922 * and then free up the resources we took when the card was found. 922 * and then free up the resources we took when the card was found.
923 */ 923 */
924 924
925void cleanup_module(void) 925void __exit cleanup_module(void)
926{ 926{
927 struct net_device *dev = dev_3c501; 927 struct net_device *dev = dev_3c501;
928 unregister_netdev(dev); 928 unregister_netdev(dev);
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c
index a34b2206132d..7e34c4f07b70 100644
--- a/drivers/net/3c503.c
+++ b/drivers/net/3c503.c
@@ -726,7 +726,7 @@ static void cleanup_card(struct net_device *dev)
726 iounmap(ei_status.mem); 726 iounmap(ei_status.mem);
727} 727}
728 728
729void 729void __exit
730cleanup_module(void) 730cleanup_module(void)
731{ 731{
732 int this_dev; 732 int this_dev;
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 458cb9cbe915..702bfb2a5e99 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -1670,7 +1670,7 @@ int __init init_module(void)
1670 return 0; 1670 return 0;
1671} 1671}
1672 1672
1673void cleanup_module(void) 1673void __exit cleanup_module(void)
1674{ 1674{
1675 int this_dev; 1675 int this_dev;
1676 1676
diff --git a/drivers/net/3c507.c b/drivers/net/3c507.c
index aa43563610ae..54e1d5aebed3 100644
--- a/drivers/net/3c507.c
+++ b/drivers/net/3c507.c
@@ -940,7 +940,7 @@ int __init init_module(void)
940 return IS_ERR(dev_3c507) ? PTR_ERR(dev_3c507) : 0; 940 return IS_ERR(dev_3c507) ? PTR_ERR(dev_3c507) : 0;
941} 941}
942 942
943void 943void __exit
944cleanup_module(void) 944cleanup_module(void)
945{ 945{
946 struct net_device *dev = dev_3c507; 946 struct net_device *dev = dev_3c507;
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index 91849469b4f4..17d61eb0a7e5 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -1302,7 +1302,7 @@ int __init init_module(void)
1302 } else return 0; 1302 } else return 0;
1303} 1303}
1304 1304
1305void cleanup_module(void) 1305void __exit cleanup_module(void)
1306{ 1306{
1307 int this_dev; 1307 int this_dev;
1308 for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) { 1308 for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) {
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c
index f4aca5386add..6c7437e60bd2 100644
--- a/drivers/net/3c527.c
+++ b/drivers/net/3c527.c
@@ -1659,7 +1659,7 @@ int __init init_module(void)
1659 * transmit operations are allowed to start scribbling into memory. 1659 * transmit operations are allowed to start scribbling into memory.
1660 */ 1660 */
1661 1661
1662void cleanup_module(void) 1662void __exit cleanup_module(void)
1663{ 1663{
1664 unregister_netdev(this_device); 1664 unregister_netdev(this_device);
1665 cleanup_card(this_device); 1665 cleanup_card(this_device);
diff --git a/drivers/net/ac3200.c b/drivers/net/ac3200.c
index 0dca8bb9d2c7..c01f87f5bed7 100644
--- a/drivers/net/ac3200.c
+++ b/drivers/net/ac3200.c
@@ -405,7 +405,7 @@ static void cleanup_card(struct net_device *dev)
405 iounmap(ei_status.mem); 405 iounmap(ei_status.mem);
406} 406}
407 407
408void 408void __exit
409cleanup_module(void) 409cleanup_module(void)
410{ 410{
411 int this_dev; 411 int this_dev;
diff --git a/drivers/net/apne.c b/drivers/net/apne.c
index 9164d8cd670e..d4e408169073 100644
--- a/drivers/net/apne.c
+++ b/drivers/net/apne.c
@@ -568,7 +568,7 @@ static irqreturn_t apne_interrupt(int irq, void *dev_id)
568#ifdef MODULE 568#ifdef MODULE
569static struct net_device *apne_dev; 569static struct net_device *apne_dev;
570 570
571int init_module(void) 571int __init init_module(void)
572{ 572{
573 apne_dev = apne_probe(-1); 573 apne_dev = apne_probe(-1);
574 if (IS_ERR(apne_dev)) 574 if (IS_ERR(apne_dev))
@@ -576,7 +576,7 @@ int init_module(void)
576 return 0; 576 return 0;
577} 577}
578 578
579void cleanup_module(void) 579void __exit cleanup_module(void)
580{ 580{
581 unregister_netdev(apne_dev); 581 unregister_netdev(apne_dev);
582 582
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index cc1a27ed197f..dba5e5165452 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -1041,7 +1041,7 @@ int __init init_module(void)
1041 return 0; 1041 return 0;
1042} 1042}
1043 1043
1044void cleanup_module(void) 1044void __exit cleanup_module(void)
1045{ 1045{
1046 unregister_netdev(cops_dev); 1046 unregister_netdev(cops_dev);
1047 cleanup_card(cops_dev); 1047 cleanup_card(cops_dev);
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index b54b857e357e..fada15d959de 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -41,9 +41,6 @@
41#define DRV_NAME "at91_ether" 41#define DRV_NAME "at91_ether"
42#define DRV_VERSION "1.0" 42#define DRV_VERSION "1.0"
43 43
44static struct net_device *at91_dev;
45
46static struct timer_list check_timer;
47#define LINK_POLL_INTERVAL (HZ) 44#define LINK_POLL_INTERVAL (HZ)
48 45
49/* ..................................................................... */ 46/* ..................................................................... */
@@ -146,7 +143,7 @@ static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int
146 */ 143 */
147static void update_linkspeed(struct net_device *dev, int silent) 144static void update_linkspeed(struct net_device *dev, int silent)
148{ 145{
149 struct at91_private *lp = (struct at91_private *) dev->priv; 146 struct at91_private *lp = netdev_priv(dev);
150 unsigned int bmsr, bmcr, lpa, mac_cfg; 147 unsigned int bmsr, bmcr, lpa, mac_cfg;
151 unsigned int speed, duplex; 148 unsigned int speed, duplex;
152 149
@@ -199,7 +196,7 @@ static void update_linkspeed(struct net_device *dev, int silent)
199static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id) 196static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
200{ 197{
201 struct net_device *dev = (struct net_device *) dev_id; 198 struct net_device *dev = (struct net_device *) dev_id;
202 struct at91_private *lp = (struct at91_private *) dev->priv; 199 struct at91_private *lp = netdev_priv(dev);
203 unsigned int phy; 200 unsigned int phy;
204 201
205 /* 202 /*
@@ -242,7 +239,7 @@ done:
242 */ 239 */
243static void enable_phyirq(struct net_device *dev) 240static void enable_phyirq(struct net_device *dev)
244{ 241{
245 struct at91_private *lp = (struct at91_private *) dev->priv; 242 struct at91_private *lp = netdev_priv(dev);
246 unsigned int dsintr, irq_number; 243 unsigned int dsintr, irq_number;
247 int status; 244 int status;
248 245
@@ -252,8 +249,7 @@ static void enable_phyirq(struct net_device *dev)
252 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L), 249 * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L),
253 * or board does not have it connected. 250 * or board does not have it connected.
254 */ 251 */
255 check_timer.expires = jiffies + LINK_POLL_INTERVAL; 252 mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
256 add_timer(&check_timer);
257 return; 253 return;
258 } 254 }
259 255
@@ -294,13 +290,13 @@ static void enable_phyirq(struct net_device *dev)
294 */ 290 */
295static void disable_phyirq(struct net_device *dev) 291static void disable_phyirq(struct net_device *dev)
296{ 292{
297 struct at91_private *lp = (struct at91_private *) dev->priv; 293 struct at91_private *lp = netdev_priv(dev);
298 unsigned int dsintr; 294 unsigned int dsintr;
299 unsigned int irq_number; 295 unsigned int irq_number;
300 296
301 irq_number = lp->board_data.phy_irq_pin; 297 irq_number = lp->board_data.phy_irq_pin;
302 if (!irq_number) { 298 if (!irq_number) {
303 del_timer_sync(&check_timer); 299 del_timer_sync(&lp->check_timer);
304 return; 300 return;
305 } 301 }
306 302
@@ -340,7 +336,7 @@ static void disable_phyirq(struct net_device *dev)
340#if 0 336#if 0
341static void reset_phy(struct net_device *dev) 337static void reset_phy(struct net_device *dev)
342{ 338{
343 struct at91_private *lp = (struct at91_private *) dev->priv; 339 struct at91_private *lp = netdev_priv(dev);
344 unsigned int bmcr; 340 unsigned int bmcr;
345 341
346 spin_lock_irq(&lp->lock); 342 spin_lock_irq(&lp->lock);
@@ -362,13 +358,13 @@ static void reset_phy(struct net_device *dev)
362static void at91ether_check_link(unsigned long dev_id) 358static void at91ether_check_link(unsigned long dev_id)
363{ 359{
364 struct net_device *dev = (struct net_device *) dev_id; 360 struct net_device *dev = (struct net_device *) dev_id;
361 struct at91_private *lp = netdev_priv(dev);
365 362
366 enable_mdi(); 363 enable_mdi();
367 update_linkspeed(dev, 1); 364 update_linkspeed(dev, 1);
368 disable_mdi(); 365 disable_mdi();
369 366
370 check_timer.expires = jiffies + LINK_POLL_INTERVAL; 367 mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL);
371 add_timer(&check_timer);
372} 368}
373 369
374/* ......................... ADDRESS MANAGEMENT ........................ */ 370/* ......................... ADDRESS MANAGEMENT ........................ */
@@ -590,7 +586,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
590 586
591static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 587static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
592{ 588{
593 struct at91_private *lp = (struct at91_private *) dev->priv; 589 struct at91_private *lp = netdev_priv(dev);
594 int ret; 590 int ret;
595 591
596 spin_lock_irq(&lp->lock); 592 spin_lock_irq(&lp->lock);
@@ -611,7 +607,7 @@ static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cm
611 607
612static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 608static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
613{ 609{
614 struct at91_private *lp = (struct at91_private *) dev->priv; 610 struct at91_private *lp = netdev_priv(dev);
615 int ret; 611 int ret;
616 612
617 spin_lock_irq(&lp->lock); 613 spin_lock_irq(&lp->lock);
@@ -627,7 +623,7 @@ static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cm
627 623
628static int at91ether_nwayreset(struct net_device *dev) 624static int at91ether_nwayreset(struct net_device *dev)
629{ 625{
630 struct at91_private *lp = (struct at91_private *) dev->priv; 626 struct at91_private *lp = netdev_priv(dev);
631 int ret; 627 int ret;
632 628
633 spin_lock_irq(&lp->lock); 629 spin_lock_irq(&lp->lock);
@@ -658,7 +654,7 @@ static const struct ethtool_ops at91ether_ethtool_ops = {
658 654
659static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 655static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
660{ 656{
661 struct at91_private *lp = (struct at91_private *) dev->priv; 657 struct at91_private *lp = netdev_priv(dev);
662 int res; 658 int res;
663 659
664 if (!netif_running(dev)) 660 if (!netif_running(dev))
@@ -680,7 +676,7 @@ static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
680 */ 676 */
681static void at91ether_start(struct net_device *dev) 677static void at91ether_start(struct net_device *dev)
682{ 678{
683 struct at91_private *lp = (struct at91_private *) dev->priv; 679 struct at91_private *lp = netdev_priv(dev);
684 struct recv_desc_bufs *dlist, *dlist_phys; 680 struct recv_desc_bufs *dlist, *dlist_phys;
685 int i; 681 int i;
686 unsigned long ctl; 682 unsigned long ctl;
@@ -712,7 +708,7 @@ static void at91ether_start(struct net_device *dev)
712 */ 708 */
713static int at91ether_open(struct net_device *dev) 709static int at91ether_open(struct net_device *dev)
714{ 710{
715 struct at91_private *lp = (struct at91_private *) dev->priv; 711 struct at91_private *lp = netdev_priv(dev);
716 unsigned long ctl; 712 unsigned long ctl;
717 713
718 if (!is_valid_ether_addr(dev->dev_addr)) 714 if (!is_valid_ether_addr(dev->dev_addr))
@@ -752,7 +748,7 @@ static int at91ether_open(struct net_device *dev)
752 */ 748 */
753static int at91ether_close(struct net_device *dev) 749static int at91ether_close(struct net_device *dev)
754{ 750{
755 struct at91_private *lp = (struct at91_private *) dev->priv; 751 struct at91_private *lp = netdev_priv(dev);
756 unsigned long ctl; 752 unsigned long ctl;
757 753
758 /* Disable Receiver and Transmitter */ 754 /* Disable Receiver and Transmitter */
@@ -779,7 +775,7 @@ static int at91ether_close(struct net_device *dev)
779 */ 775 */
780static int at91ether_tx(struct sk_buff *skb, struct net_device *dev) 776static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
781{ 777{
782 struct at91_private *lp = (struct at91_private *) dev->priv; 778 struct at91_private *lp = netdev_priv(dev);
783 779
784 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) { 780 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
785 netif_stop_queue(dev); 781 netif_stop_queue(dev);
@@ -811,7 +807,7 @@ static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
811 */ 807 */
812static struct net_device_stats *at91ether_stats(struct net_device *dev) 808static struct net_device_stats *at91ether_stats(struct net_device *dev)
813{ 809{
814 struct at91_private *lp = (struct at91_private *) dev->priv; 810 struct at91_private *lp = netdev_priv(dev);
815 int ale, lenerr, seqe, lcol, ecol; 811 int ale, lenerr, seqe, lcol, ecol;
816 812
817 if (netif_running(dev)) { 813 if (netif_running(dev)) {
@@ -847,7 +843,7 @@ static struct net_device_stats *at91ether_stats(struct net_device *dev)
847 */ 843 */
848static void at91ether_rx(struct net_device *dev) 844static void at91ether_rx(struct net_device *dev)
849{ 845{
850 struct at91_private *lp = (struct at91_private *) dev->priv; 846 struct at91_private *lp = netdev_priv(dev);
851 struct recv_desc_bufs *dlist; 847 struct recv_desc_bufs *dlist;
852 unsigned char *p_recv; 848 unsigned char *p_recv;
853 struct sk_buff *skb; 849 struct sk_buff *skb;
@@ -857,14 +853,13 @@ static void at91ether_rx(struct net_device *dev)
857 while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) { 853 while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
858 p_recv = dlist->recv_buf[lp->rxBuffIndex]; 854 p_recv = dlist->recv_buf[lp->rxBuffIndex];
859 pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */ 855 pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
860 skb = alloc_skb(pktlen + 2, GFP_ATOMIC); 856 skb = dev_alloc_skb(pktlen + 2);
861 if (skb != NULL) { 857 if (skb != NULL) {
862 skb_reserve(skb, 2); 858 skb_reserve(skb, 2);
863 memcpy(skb_put(skb, pktlen), p_recv, pktlen); 859 memcpy(skb_put(skb, pktlen), p_recv, pktlen);
864 860
865 skb->dev = dev; 861 skb->dev = dev;
866 skb->protocol = eth_type_trans(skb, dev); 862 skb->protocol = eth_type_trans(skb, dev);
867 skb->len = pktlen;
868 dev->last_rx = jiffies; 863 dev->last_rx = jiffies;
869 lp->stats.rx_bytes += pktlen; 864 lp->stats.rx_bytes += pktlen;
870 netif_rx(skb); 865 netif_rx(skb);
@@ -891,7 +886,7 @@ static void at91ether_rx(struct net_device *dev)
891static irqreturn_t at91ether_interrupt(int irq, void *dev_id) 886static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
892{ 887{
893 struct net_device *dev = (struct net_device *) dev_id; 888 struct net_device *dev = (struct net_device *) dev_id;
894 struct at91_private *lp = (struct at91_private *) dev->priv; 889 struct at91_private *lp = netdev_priv(dev);
895 unsigned long intstatus, ctl; 890 unsigned long intstatus, ctl;
896 891
897 /* MAC Interrupt Status register indicates what interrupts are pending. 892 /* MAC Interrupt Status register indicates what interrupts are pending.
@@ -927,6 +922,17 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
927 return IRQ_HANDLED; 922 return IRQ_HANDLED;
928} 923}
929 924
925#ifdef CONFIG_NET_POLL_CONTROLLER
926static void at91ether_poll_controller(struct net_device *dev)
927{
928 unsigned long flags;
929
930 local_irq_save(flags);
931 at91ether_interrupt(dev->irq, dev);
932 local_irq_restore(flags);
933}
934#endif
935
930/* 936/*
931 * Initialize the ethernet interface 937 * Initialize the ethernet interface
932 */ 938 */
@@ -939,9 +945,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
939 unsigned int val; 945 unsigned int val;
940 int res; 946 int res;
941 947
942 if (at91_dev) /* already initialized */
943 return 0;
944
945 dev = alloc_etherdev(sizeof(struct at91_private)); 948 dev = alloc_etherdev(sizeof(struct at91_private));
946 if (!dev) 949 if (!dev)
947 return -ENOMEM; 950 return -ENOMEM;
@@ -957,7 +960,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
957 } 960 }
958 961
959 /* Allocate memory for DMA Receive descriptors */ 962 /* Allocate memory for DMA Receive descriptors */
960 lp = (struct at91_private *)dev->priv; 963 lp = netdev_priv(dev);
961 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL); 964 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
962 if (lp->dlist == NULL) { 965 if (lp->dlist == NULL) {
963 free_irq(dev->irq, dev); 966 free_irq(dev->irq, dev);
@@ -979,6 +982,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
979 dev->set_mac_address = set_mac_address; 982 dev->set_mac_address = set_mac_address;
980 dev->ethtool_ops = &at91ether_ethtool_ops; 983 dev->ethtool_ops = &at91ether_ethtool_ops;
981 dev->do_ioctl = at91ether_ioctl; 984 dev->do_ioctl = at91ether_ioctl;
985#ifdef CONFIG_NET_POLL_CONTROLLER
986 dev->poll_controller = at91ether_poll_controller;
987#endif
982 988
983 SET_NETDEV_DEV(dev, &pdev->dev); 989 SET_NETDEV_DEV(dev, &pdev->dev);
984 990
@@ -1024,7 +1030,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1024 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); 1030 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1025 return res; 1031 return res;
1026 } 1032 }
1027 at91_dev = dev;
1028 1033
1029 /* Determine current link speed */ 1034 /* Determine current link speed */
1030 spin_lock_irq(&lp->lock); 1035 spin_lock_irq(&lp->lock);
@@ -1036,9 +1041,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1036 1041
1037 /* If board has no PHY IRQ, use a timer to poll the PHY */ 1042 /* If board has no PHY IRQ, use a timer to poll the PHY */
1038 if (!lp->board_data.phy_irq_pin) { 1043 if (!lp->board_data.phy_irq_pin) {
1039 init_timer(&check_timer); 1044 init_timer(&lp->check_timer);
1040 check_timer.data = (unsigned long)dev; 1045 lp->check_timer.data = (unsigned long)dev;
1041 check_timer.function = at91ether_check_link; 1046 lp->check_timer.function = at91ether_check_link;
1042 } 1047 }
1043 1048
1044 /* Display ethernet banner */ 1049 /* Display ethernet banner */
@@ -1115,15 +1120,16 @@ static int __init at91ether_probe(struct platform_device *pdev)
1115 1120
1116static int __devexit at91ether_remove(struct platform_device *pdev) 1121static int __devexit at91ether_remove(struct platform_device *pdev)
1117{ 1122{
1118 struct at91_private *lp = (struct at91_private *) at91_dev->priv; 1123 struct net_device *dev = platform_get_drvdata(pdev);
1124 struct at91_private *lp = netdev_priv(dev);
1119 1125
1120 unregister_netdev(at91_dev); 1126 unregister_netdev(dev);
1121 free_irq(at91_dev->irq, at91_dev); 1127 free_irq(dev->irq, dev);
1122 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); 1128 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1123 clk_put(lp->ether_clk); 1129 clk_put(lp->ether_clk);
1124 1130
1125 free_netdev(at91_dev); 1131 platform_set_drvdata(pdev, NULL);
1126 at91_dev = NULL; 1132 free_netdev(dev);
1127 return 0; 1133 return 0;
1128} 1134}
1129 1135
@@ -1131,8 +1137,8 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
1131 1137
1132static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg) 1138static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1133{ 1139{
1134 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1135 struct net_device *net_dev = platform_get_drvdata(pdev); 1140 struct net_device *net_dev = platform_get_drvdata(pdev);
1141 struct at91_private *lp = netdev_priv(net_dev);
1136 int phy_irq = lp->board_data.phy_irq_pin; 1142 int phy_irq = lp->board_data.phy_irq_pin;
1137 1143
1138 if (netif_running(net_dev)) { 1144 if (netif_running(net_dev)) {
@@ -1149,8 +1155,8 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1149 1155
1150static int at91ether_resume(struct platform_device *pdev) 1156static int at91ether_resume(struct platform_device *pdev)
1151{ 1157{
1152 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1153 struct net_device *net_dev = platform_get_drvdata(pdev); 1158 struct net_device *net_dev = platform_get_drvdata(pdev);
1159 struct at91_private *lp = netdev_priv(net_dev);
1154 int phy_irq = lp->board_data.phy_irq_pin; 1160 int phy_irq = lp->board_data.phy_irq_pin;
1155 1161
1156 if (netif_running(net_dev)) { 1162 if (netif_running(net_dev)) {
diff --git a/drivers/net/arm/at91_ether.h b/drivers/net/arm/at91_ether.h
index d1e72e02be3a..b6b665de2ea0 100644
--- a/drivers/net/arm/at91_ether.h
+++ b/drivers/net/arm/at91_ether.h
@@ -87,6 +87,7 @@ struct at91_private
87 spinlock_t lock; /* lock for MDI interface */ 87 spinlock_t lock; /* lock for MDI interface */
88 short phy_media; /* media interface type */ 88 short phy_media; /* media interface type */
89 unsigned short phy_address; /* 5-bit MDI address of PHY (0..31) */ 89 unsigned short phy_address; /* 5-bit MDI address of PHY (0..31) */
90 struct timer_list check_timer; /* Poll link status */
90 91
91 /* Transmit */ 92 /* Transmit */
92 struct sk_buff *skb; /* holds skb until xmit interrupt completes */ 93 struct sk_buff *skb; /* holds skb until xmit interrupt completes */
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c
index f3478a30e778..d6da3ce9ad79 100644
--- a/drivers/net/arm/ether1.c
+++ b/drivers/net/arm/ether1.c
@@ -254,7 +254,7 @@ ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsig
254 } while (thislen); 254 } while (thislen);
255} 255}
256 256
257static int __init 257static int __devinit
258ether1_ramtest(struct net_device *dev, unsigned char byte) 258ether1_ramtest(struct net_device *dev, unsigned char byte)
259{ 259{
260 unsigned char *buffer = kmalloc (BUFFER_SIZE, GFP_KERNEL); 260 unsigned char *buffer = kmalloc (BUFFER_SIZE, GFP_KERNEL);
@@ -308,7 +308,7 @@ ether1_reset (struct net_device *dev)
308 return BUS_16; 308 return BUS_16;
309} 309}
310 310
311static int __init 311static int __devinit
312ether1_init_2(struct net_device *dev) 312ether1_init_2(struct net_device *dev)
313{ 313{
314 int i; 314 int i;
@@ -986,7 +986,7 @@ ether1_setmulticastlist (struct net_device *dev)
986 986
987/* ------------------------------------------------------------------------- */ 987/* ------------------------------------------------------------------------- */
988 988
989static void __init ether1_banner(void) 989static void __devinit ether1_banner(void)
990{ 990{
991 static unsigned int version_printed = 0; 991 static unsigned int version_printed = 0;
992 992
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c
index 84686c8a5bc2..4fc234785d56 100644
--- a/drivers/net/arm/ether3.c
+++ b/drivers/net/arm/ether3.c
@@ -198,7 +198,7 @@ static inline void ether3_ledon(struct net_device *dev)
198 * Read the ethernet address string from the on board rom. 198 * Read the ethernet address string from the on board rom.
199 * This is an ascii string!!! 199 * This is an ascii string!!!
200 */ 200 */
201static int __init 201static int __devinit
202ether3_addr(char *addr, struct expansion_card *ec) 202ether3_addr(char *addr, struct expansion_card *ec)
203{ 203{
204 struct in_chunk_dir cd; 204 struct in_chunk_dir cd;
@@ -223,7 +223,7 @@ ether3_addr(char *addr, struct expansion_card *ec)
223 223
224/* --------------------------------------------------------------------------- */ 224/* --------------------------------------------------------------------------- */
225 225
226static int __init 226static int __devinit
227ether3_ramtest(struct net_device *dev, unsigned char byte) 227ether3_ramtest(struct net_device *dev, unsigned char byte)
228{ 228{
229 unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL); 229 unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL);
@@ -272,7 +272,7 @@ ether3_ramtest(struct net_device *dev, unsigned char byte)
272 272
273/* ------------------------------------------------------------------------------- */ 273/* ------------------------------------------------------------------------------- */
274 274
275static int __init ether3_init_2(struct net_device *dev) 275static int __devinit ether3_init_2(struct net_device *dev)
276{ 276{
277 int i; 277 int i;
278 278
@@ -765,7 +765,7 @@ static void ether3_tx(struct net_device *dev)
765 } 765 }
766} 766}
767 767
768static void __init ether3_banner(void) 768static void __devinit ether3_banner(void)
769{ 769{
770 static unsigned version_printed = 0; 770 static unsigned version_printed = 0;
771 771
diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c
index 8620a5b470f5..56ae8babd919 100644
--- a/drivers/net/at1700.c
+++ b/drivers/net/at1700.c
@@ -908,7 +908,7 @@ int __init init_module(void)
908 return 0; 908 return 0;
909} 909}
910 910
911void 911void __exit
912cleanup_module(void) 912cleanup_module(void)
913{ 913{
914 unregister_netdev(dev_at1700); 914 unregister_netdev(dev_at1700);
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c
index d79489e46249..7e37ac86a69a 100644
--- a/drivers/net/atarilance.c
+++ b/drivers/net/atarilance.c
@@ -1179,7 +1179,7 @@ static int lance_set_mac_address( struct net_device *dev, void *addr )
1179#ifdef MODULE 1179#ifdef MODULE
1180static struct net_device *atarilance_dev; 1180static struct net_device *atarilance_dev;
1181 1181
1182int init_module(void) 1182int __init init_module(void)
1183{ 1183{
1184 atarilance_dev = atarilance_probe(-1); 1184 atarilance_dev = atarilance_probe(-1);
1185 if (IS_ERR(atarilance_dev)) 1185 if (IS_ERR(atarilance_dev))
@@ -1187,7 +1187,7 @@ int init_module(void)
1187 return 0; 1187 return 0;
1188} 1188}
1189 1189
1190void cleanup_module(void) 1190void __exit cleanup_module(void)
1191{ 1191{
1192 unregister_netdev(atarilance_dev); 1192 unregister_netdev(atarilance_dev);
1193 free_irq(atarilance_dev->irq, atarilance_dev); 1193 free_irq(atarilance_dev->irq, atarilance_dev);
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 488d8ed9e740..6482aed4bb7c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3684,7 +3684,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3684 mii->val_out = 0; 3684 mii->val_out = 0;
3685 read_lock_bh(&bond->lock); 3685 read_lock_bh(&bond->lock);
3686 read_lock(&bond->curr_slave_lock); 3686 read_lock(&bond->curr_slave_lock);
3687 if (bond->curr_active_slave) { 3687 if (netif_carrier_ok(bond->dev)) {
3688 mii->val_out = BMSR_LSTATUS; 3688 mii->val_out = BMSR_LSTATUS;
3689 } 3689 }
3690 read_unlock(&bond->curr_slave_lock); 3690 read_unlock(&bond->curr_slave_lock);
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index dec70c2b374a..4612f71a7106 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -1974,7 +1974,7 @@ out:
1974 return ret; 1974 return ret;
1975} 1975}
1976 1976
1977void 1977void __exit
1978cleanup_module(void) 1978cleanup_module(void)
1979{ 1979{
1980 unregister_netdev(dev_cs89x0); 1980 unregister_netdev(dev_cs89x0);
diff --git a/drivers/net/de600.c b/drivers/net/de600.c
index 690bb40b353d..8396e411f1ce 100644
--- a/drivers/net/de600.c
+++ b/drivers/net/de600.c
@@ -43,7 +43,6 @@ static const char version[] = "de600.c: $Revision: 1.41-2.5 $, Bjorn Ekwall (bj
43 * modify the following "#define": (see <asm/io.h> for more info) 43 * modify the following "#define": (see <asm/io.h> for more info)
44#define REALLY_SLOW_IO 44#define REALLY_SLOW_IO
45 */ 45 */
46#define SLOW_IO_BY_JUMPING /* Looks "better" than dummy write to port 0x80 :-) */
47 46
48/* use 0 for production, 1 for verification, >2 for debug */ 47/* use 0 for production, 1 for verification, >2 for debug */
49#ifdef DE600_DEBUG 48#ifdef DE600_DEBUG
diff --git a/drivers/net/declance.c b/drivers/net/declance.c
index 00e2a8a134d7..4ae0fed7122e 100644
--- a/drivers/net/declance.c
+++ b/drivers/net/declance.c
@@ -40,6 +40,10 @@
40 * 40 *
41 * v0.009: Module support fixes, multiple interfaces support, various 41 * v0.009: Module support fixes, multiple interfaces support, various
42 * bits. macro 42 * bits. macro
43 *
44 * v0.010: Fixes for the PMAD mapping of the LANCE buffer and for the
45 * PMAX requirement to only use halfword accesses to the
46 * buffer. macro
43 */ 47 */
44 48
45#include <linux/crc32.h> 49#include <linux/crc32.h>
@@ -54,6 +58,7 @@
54#include <linux/spinlock.h> 58#include <linux/spinlock.h>
55#include <linux/stddef.h> 59#include <linux/stddef.h>
56#include <linux/string.h> 60#include <linux/string.h>
61#include <linux/types.h>
57 62
58#include <asm/addrspace.h> 63#include <asm/addrspace.h>
59#include <asm/system.h> 64#include <asm/system.h>
@@ -67,7 +72,7 @@
67#include <asm/dec/tc.h> 72#include <asm/dec/tc.h>
68 73
69static char version[] __devinitdata = 74static char version[] __devinitdata =
70"declance.c: v0.009 by Linux MIPS DECstation task force\n"; 75"declance.c: v0.010 by Linux MIPS DECstation task force\n";
71 76
72MODULE_AUTHOR("Linux MIPS DECstation task force"); 77MODULE_AUTHOR("Linux MIPS DECstation task force");
73MODULE_DESCRIPTION("DEC LANCE (DECstation onboard, PMAD-xx) driver"); 78MODULE_DESCRIPTION("DEC LANCE (DECstation onboard, PMAD-xx) driver");
@@ -110,24 +115,25 @@ MODULE_LICENSE("GPL");
110#define LE_C3_BCON 0x1 /* Byte control */ 115#define LE_C3_BCON 0x1 /* Byte control */
111 116
112/* Receive message descriptor 1 */ 117/* Receive message descriptor 1 */
113#define LE_R1_OWN 0x80 /* Who owns the entry */ 118#define LE_R1_OWN 0x8000 /* Who owns the entry */
114#define LE_R1_ERR 0x40 /* Error: if FRA, OFL, CRC or BUF is set */ 119#define LE_R1_ERR 0x4000 /* Error: if FRA, OFL, CRC or BUF is set */
115#define LE_R1_FRA 0x20 /* FRA: Frame error */ 120#define LE_R1_FRA 0x2000 /* FRA: Frame error */
116#define LE_R1_OFL 0x10 /* OFL: Frame overflow */ 121#define LE_R1_OFL 0x1000 /* OFL: Frame overflow */
117#define LE_R1_CRC 0x08 /* CRC error */ 122#define LE_R1_CRC 0x0800 /* CRC error */
118#define LE_R1_BUF 0x04 /* BUF: Buffer error */ 123#define LE_R1_BUF 0x0400 /* BUF: Buffer error */
119#define LE_R1_SOP 0x02 /* Start of packet */ 124#define LE_R1_SOP 0x0200 /* Start of packet */
120#define LE_R1_EOP 0x01 /* End of packet */ 125#define LE_R1_EOP 0x0100 /* End of packet */
121#define LE_R1_POK 0x03 /* Packet is complete: SOP + EOP */ 126#define LE_R1_POK 0x0300 /* Packet is complete: SOP + EOP */
122 127
123#define LE_T1_OWN 0x80 /* Lance owns the packet */ 128/* Transmit message descriptor 1 */
124#define LE_T1_ERR 0x40 /* Error summary */ 129#define LE_T1_OWN 0x8000 /* Lance owns the packet */
125#define LE_T1_EMORE 0x10 /* Error: more than one retry needed */ 130#define LE_T1_ERR 0x4000 /* Error summary */
126#define LE_T1_EONE 0x08 /* Error: one retry needed */ 131#define LE_T1_EMORE 0x1000 /* Error: more than one retry needed */
127#define LE_T1_EDEF 0x04 /* Error: deferred */ 132#define LE_T1_EONE 0x0800 /* Error: one retry needed */
128#define LE_T1_SOP 0x02 /* Start of packet */ 133#define LE_T1_EDEF 0x0400 /* Error: deferred */
129#define LE_T1_EOP 0x01 /* End of packet */ 134#define LE_T1_SOP 0x0200 /* Start of packet */
130#define LE_T1_POK 0x03 /* Packet is complete: SOP + EOP */ 135#define LE_T1_EOP 0x0100 /* End of packet */
136#define LE_T1_POK 0x0300 /* Packet is complete: SOP + EOP */
131 137
132#define LE_T3_BUF 0x8000 /* Buffer error */ 138#define LE_T3_BUF 0x8000 /* Buffer error */
133#define LE_T3_UFL 0x4000 /* Error underflow */ 139#define LE_T3_UFL 0x4000 /* Error underflow */
@@ -156,69 +162,57 @@ MODULE_LICENSE("GPL");
156#undef TEST_HITS 162#undef TEST_HITS
157#define ZERO 0 163#define ZERO 0
158 164
159/* The DS2000/3000 have a linear 64 KB buffer. 165/*
160 166 * The DS2100/3100 have a linear 64 kB buffer which supports halfword
161 * The PMAD-AA has 128 kb buffer on-board. 167 * accesses only. Each halfword of the buffer is word-aligned in the
168 * CPU address space.
162 * 169 *
163 * The IOASIC LANCE devices use a shared memory region. This region as seen 170 * The PMAD-AA has a 128 kB buffer on-board.
164 * from the CPU is (max) 128 KB long and has to be on an 128 KB boundary.
165 * The LANCE sees this as a 64 KB long continuous memory region.
166 * 171 *
167 * The LANCE's DMA address is used as an index in this buffer and DMA takes 172 * The IOASIC LANCE devices use a shared memory region. This region
168 * place in bursts of eight 16-Bit words which are packed into four 32-Bit words 173 * as seen from the CPU is (max) 128 kB long and has to be on an 128 kB
169 * by the IOASIC. This leads to a strange padding: 16 bytes of valid data followed 174 * boundary. The LANCE sees this as a 64 kB long continuous memory
170 * by a 16 byte gap :-(. 175 * region.
176 *
177 * The LANCE's DMA address is used as an index in this buffer and DMA
178 * takes place in bursts of eight 16-bit words which are packed into
179 * four 32-bit words by the IOASIC. This leads to a strange padding:
180 * 16 bytes of valid data followed by a 16 byte gap :-(.
171 */ 181 */
172 182
173struct lance_rx_desc { 183struct lance_rx_desc {
174 unsigned short rmd0; /* low address of packet */ 184 unsigned short rmd0; /* low address of packet */
175 short gap0; 185 unsigned short rmd1; /* high address of packet
176 unsigned char rmd1_hadr; /* high address of packet */ 186 and descriptor bits */
177 unsigned char rmd1_bits; /* descriptor bits */
178 short gap1;
179 short length; /* 2s complement (negative!) 187 short length; /* 2s complement (negative!)
180 of buffer length */ 188 of buffer length */
181 short gap2;
182 unsigned short mblength; /* actual number of bytes received */ 189 unsigned short mblength; /* actual number of bytes received */
183 short gap3;
184}; 190};
185 191
186struct lance_tx_desc { 192struct lance_tx_desc {
187 unsigned short tmd0; /* low address of packet */ 193 unsigned short tmd0; /* low address of packet */
188 short gap0; 194 unsigned short tmd1; /* high address of packet
189 unsigned char tmd1_hadr; /* high address of packet */ 195 and descriptor bits */
190 unsigned char tmd1_bits; /* descriptor bits */
191 short gap1;
192 short length; /* 2s complement (negative!) 196 short length; /* 2s complement (negative!)
193 of buffer length */ 197 of buffer length */
194 short gap2;
195 unsigned short misc; 198 unsigned short misc;
196 short gap3;
197}; 199};
198 200
199 201
200/* First part of the LANCE initialization block, described in databook. */ 202/* First part of the LANCE initialization block, described in databook. */
201struct lance_init_block { 203struct lance_init_block {
202 unsigned short mode; /* pre-set mode (reg. 15) */ 204 unsigned short mode; /* pre-set mode (reg. 15) */
203 short gap0;
204 205
205 unsigned char phys_addr[12]; /* physical ethernet address 206 unsigned short phys_addr[3]; /* physical ethernet address */
206 only 0, 1, 4, 5, 8, 9 are valid 207 unsigned short filter[4]; /* multicast filter */
207 2, 3, 6, 7, 10, 11 are gaps */
208 unsigned short filter[8]; /* multicast filter
209 only 0, 2, 4, 6 are valid
210 1, 3, 5, 7 are gaps */
211 208
212 /* Receive and transmit ring base, along with extra bits. */ 209 /* Receive and transmit ring base, along with extra bits. */
213 unsigned short rx_ptr; /* receive descriptor addr */ 210 unsigned short rx_ptr; /* receive descriptor addr */
214 short gap1;
215 unsigned short rx_len; /* receive len and high addr */ 211 unsigned short rx_len; /* receive len and high addr */
216 short gap2;
217 unsigned short tx_ptr; /* transmit descriptor addr */ 212 unsigned short tx_ptr; /* transmit descriptor addr */
218 short gap3;
219 unsigned short tx_len; /* transmit len and high addr */ 213 unsigned short tx_len; /* transmit len and high addr */
220 short gap4; 214
221 short gap5[8]; 215 short gap[4];
222 216
223 /* The buffer descriptors */ 217 /* The buffer descriptors */
224 struct lance_rx_desc brx_ring[RX_RING_SIZE]; 218 struct lance_rx_desc brx_ring[RX_RING_SIZE];
@@ -226,15 +220,28 @@ struct lance_init_block {
226}; 220};
227 221
228#define BUF_OFFSET_CPU sizeof(struct lance_init_block) 222#define BUF_OFFSET_CPU sizeof(struct lance_init_block)
229#define BUF_OFFSET_LNC (sizeof(struct lance_init_block)>>1) 223#define BUF_OFFSET_LNC sizeof(struct lance_init_block)
230 224
231#define libdesc_offset(rt, elem) \ 225#define shift_off(off, type) \
232((__u32)(((unsigned long)(&(((struct lance_init_block *)0)->rt[elem]))))) 226 (type == ASIC_LANCE || type == PMAX_LANCE ? off << 1 : off)
233 227
234/* 228#define lib_off(rt, type) \
235 * This works *only* for the ring descriptors 229 shift_off(offsetof(struct lance_init_block, rt), type)
236 */ 230
237#define LANCE_ADDR(x) (CPHYSADDR(x) >> 1) 231#define lib_ptr(ib, rt, type) \
232 ((volatile u16 *)((u8 *)(ib) + lib_off(rt, type)))
233
234#define rds_off(rt, type) \
235 shift_off(offsetof(struct lance_rx_desc, rt), type)
236
237#define rds_ptr(rd, rt, type) \
238 ((volatile u16 *)((u8 *)(rd) + rds_off(rt, type)))
239
240#define tds_off(rt, type) \
241 shift_off(offsetof(struct lance_tx_desc, rt), type)
242
243#define tds_ptr(td, rt, type) \
244 ((volatile u16 *)((u8 *)(td) + tds_off(rt, type)))
238 245
239struct lance_private { 246struct lance_private {
240 struct net_device *next; 247 struct net_device *next;
@@ -242,7 +249,6 @@ struct lance_private {
242 int slot; 249 int slot;
243 int dma_irq; 250 int dma_irq;
244 volatile struct lance_regs *ll; 251 volatile struct lance_regs *ll;
245 volatile struct lance_init_block *init_block;
246 252
247 spinlock_t lock; 253 spinlock_t lock;
248 254
@@ -260,8 +266,8 @@ struct lance_private {
260 char *tx_buf_ptr_cpu[TX_RING_SIZE]; 266 char *tx_buf_ptr_cpu[TX_RING_SIZE];
261 267
262 /* Pointers to the ring buffers as seen from the LANCE */ 268 /* Pointers to the ring buffers as seen from the LANCE */
263 char *rx_buf_ptr_lnc[RX_RING_SIZE]; 269 uint rx_buf_ptr_lnc[RX_RING_SIZE];
264 char *tx_buf_ptr_lnc[TX_RING_SIZE]; 270 uint tx_buf_ptr_lnc[TX_RING_SIZE];
265}; 271};
266 272
267#define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\ 273#define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\
@@ -294,7 +300,7 @@ static inline void writereg(volatile unsigned short *regptr, short value)
294static void load_csrs(struct lance_private *lp) 300static void load_csrs(struct lance_private *lp)
295{ 301{
296 volatile struct lance_regs *ll = lp->ll; 302 volatile struct lance_regs *ll = lp->ll;
297 int leptr; 303 uint leptr;
298 304
299 /* The address space as seen from the LANCE 305 /* The address space as seen from the LANCE
300 * begins at address 0. HK 306 * begins at address 0. HK
@@ -316,12 +322,14 @@ static void load_csrs(struct lance_private *lp)
316 * Our specialized copy routines 322 * Our specialized copy routines
317 * 323 *
318 */ 324 */
319void cp_to_buf(const int type, void *to, const void *from, int len) 325static void cp_to_buf(const int type, void *to, const void *from, int len)
320{ 326{
321 unsigned short *tp, *fp, clen; 327 unsigned short *tp, *fp, clen;
322 unsigned char *rtp, *rfp; 328 unsigned char *rtp, *rfp;
323 329
324 if (type == PMAX_LANCE) { 330 if (type == PMAD_LANCE) {
331 memcpy(to, from, len);
332 } else if (type == PMAX_LANCE) {
325 clen = len >> 1; 333 clen = len >> 1;
326 tp = (unsigned short *) to; 334 tp = (unsigned short *) to;
327 fp = (unsigned short *) from; 335 fp = (unsigned short *) from;
@@ -370,12 +378,14 @@ void cp_to_buf(const int type, void *to, const void *from, int len)
370 iob(); 378 iob();
371} 379}
372 380
373void cp_from_buf(const int type, void *to, const void *from, int len) 381static void cp_from_buf(const int type, void *to, const void *from, int len)
374{ 382{
375 unsigned short *tp, *fp, clen; 383 unsigned short *tp, *fp, clen;
376 unsigned char *rtp, *rfp; 384 unsigned char *rtp, *rfp;
377 385
378 if (type == PMAX_LANCE) { 386 if (type == PMAD_LANCE) {
387 memcpy(to, from, len);
388 } else if (type == PMAX_LANCE) {
379 clen = len >> 1; 389 clen = len >> 1;
380 tp = (unsigned short *) to; 390 tp = (unsigned short *) to;
381 fp = (unsigned short *) from; 391 fp = (unsigned short *) from;
@@ -431,12 +441,10 @@ void cp_from_buf(const int type, void *to, const void *from, int len)
431static void lance_init_ring(struct net_device *dev) 441static void lance_init_ring(struct net_device *dev)
432{ 442{
433 struct lance_private *lp = netdev_priv(dev); 443 struct lance_private *lp = netdev_priv(dev);
434 volatile struct lance_init_block *ib; 444 volatile u16 *ib = (volatile u16 *)dev->mem_start;
435 int leptr; 445 uint leptr;
436 int i; 446 int i;
437 447
438 ib = (struct lance_init_block *) (dev->mem_start);
439
440 /* Lock out other processes while setting up hardware */ 448 /* Lock out other processes while setting up hardware */
441 netif_stop_queue(dev); 449 netif_stop_queue(dev);
442 lp->rx_new = lp->tx_new = 0; 450 lp->rx_new = lp->tx_new = 0;
@@ -445,55 +453,64 @@ static void lance_init_ring(struct net_device *dev)
445 /* Copy the ethernet address to the lance init block. 453 /* Copy the ethernet address to the lance init block.
446 * XXX bit 0 of the physical address registers has to be zero 454 * XXX bit 0 of the physical address registers has to be zero
447 */ 455 */
448 ib->phys_addr[0] = dev->dev_addr[0]; 456 *lib_ptr(ib, phys_addr[0], lp->type) = (dev->dev_addr[1] << 8) |
449 ib->phys_addr[1] = dev->dev_addr[1]; 457 dev->dev_addr[0];
450 ib->phys_addr[4] = dev->dev_addr[2]; 458 *lib_ptr(ib, phys_addr[1], lp->type) = (dev->dev_addr[3] << 8) |
451 ib->phys_addr[5] = dev->dev_addr[3]; 459 dev->dev_addr[2];
452 ib->phys_addr[8] = dev->dev_addr[4]; 460 *lib_ptr(ib, phys_addr[2], lp->type) = (dev->dev_addr[5] << 8) |
453 ib->phys_addr[9] = dev->dev_addr[5]; 461 dev->dev_addr[4];
454 /* Setup the initialization block */ 462 /* Setup the initialization block */
455 463
456 /* Setup rx descriptor pointer */ 464 /* Setup rx descriptor pointer */
457 leptr = LANCE_ADDR(libdesc_offset(brx_ring, 0)); 465 leptr = offsetof(struct lance_init_block, brx_ring);
458 ib->rx_len = (LANCE_LOG_RX_BUFFERS << 13) | (leptr >> 16); 466 *lib_ptr(ib, rx_len, lp->type) = (LANCE_LOG_RX_BUFFERS << 13) |
459 ib->rx_ptr = leptr; 467 (leptr >> 16);
468 *lib_ptr(ib, rx_ptr, lp->type) = leptr;
460 if (ZERO) 469 if (ZERO)
461 printk("RX ptr: %8.8x(%8.8x)\n", leptr, libdesc_offset(brx_ring, 0)); 470 printk("RX ptr: %8.8x(%8.8x)\n",
471 leptr, lib_off(brx_ring, lp->type));
462 472
463 /* Setup tx descriptor pointer */ 473 /* Setup tx descriptor pointer */
464 leptr = LANCE_ADDR(libdesc_offset(btx_ring, 0)); 474 leptr = offsetof(struct lance_init_block, btx_ring);
465 ib->tx_len = (LANCE_LOG_TX_BUFFERS << 13) | (leptr >> 16); 475 *lib_ptr(ib, tx_len, lp->type) = (LANCE_LOG_TX_BUFFERS << 13) |
466 ib->tx_ptr = leptr; 476 (leptr >> 16);
477 *lib_ptr(ib, tx_ptr, lp->type) = leptr;
467 if (ZERO) 478 if (ZERO)
468 printk("TX ptr: %8.8x(%8.8x)\n", leptr, libdesc_offset(btx_ring, 0)); 479 printk("TX ptr: %8.8x(%8.8x)\n",
480 leptr, lib_off(btx_ring, lp->type));
469 481
470 if (ZERO) 482 if (ZERO)
471 printk("TX rings:\n"); 483 printk("TX rings:\n");
472 484
473 /* Setup the Tx ring entries */ 485 /* Setup the Tx ring entries */
474 for (i = 0; i < TX_RING_SIZE; i++) { 486 for (i = 0; i < TX_RING_SIZE; i++) {
475 leptr = (int) lp->tx_buf_ptr_lnc[i]; 487 leptr = lp->tx_buf_ptr_lnc[i];
476 ib->btx_ring[i].tmd0 = leptr; 488 *lib_ptr(ib, btx_ring[i].tmd0, lp->type) = leptr;
477 ib->btx_ring[i].tmd1_hadr = leptr >> 16; 489 *lib_ptr(ib, btx_ring[i].tmd1, lp->type) = (leptr >> 16) &
478 ib->btx_ring[i].tmd1_bits = 0; 490 0xff;
479 ib->btx_ring[i].length = 0xf000; /* The ones required by tmd2 */ 491 *lib_ptr(ib, btx_ring[i].length, lp->type) = 0xf000;
480 ib->btx_ring[i].misc = 0; 492 /* The ones required by tmd2 */
493 *lib_ptr(ib, btx_ring[i].misc, lp->type) = 0;
481 if (i < 3 && ZERO) 494 if (i < 3 && ZERO)
482 printk("%d: 0x%8.8x(0x%8.8x)\n", i, leptr, (int) lp->tx_buf_ptr_cpu[i]); 495 printk("%d: 0x%8.8x(0x%8.8x)\n",
496 i, leptr, (uint)lp->tx_buf_ptr_cpu[i]);
483 } 497 }
484 498
485 /* Setup the Rx ring entries */ 499 /* Setup the Rx ring entries */
486 if (ZERO) 500 if (ZERO)
487 printk("RX rings:\n"); 501 printk("RX rings:\n");
488 for (i = 0; i < RX_RING_SIZE; i++) { 502 for (i = 0; i < RX_RING_SIZE; i++) {
489 leptr = (int) lp->rx_buf_ptr_lnc[i]; 503 leptr = lp->rx_buf_ptr_lnc[i];
490 ib->brx_ring[i].rmd0 = leptr; 504 *lib_ptr(ib, brx_ring[i].rmd0, lp->type) = leptr;
491 ib->brx_ring[i].rmd1_hadr = leptr >> 16; 505 *lib_ptr(ib, brx_ring[i].rmd1, lp->type) = ((leptr >> 16) &
492 ib->brx_ring[i].rmd1_bits = LE_R1_OWN; 506 0xff) |
493 ib->brx_ring[i].length = -RX_BUFF_SIZE | 0xf000; 507 LE_R1_OWN;
494 ib->brx_ring[i].mblength = 0; 508 *lib_ptr(ib, brx_ring[i].length, lp->type) = -RX_BUFF_SIZE |
509 0xf000;
510 *lib_ptr(ib, brx_ring[i].mblength, lp->type) = 0;
495 if (i < 3 && ZERO) 511 if (i < 3 && ZERO)
496 printk("%d: 0x%8.8x(0x%8.8x)\n", i, leptr, (int) lp->rx_buf_ptr_cpu[i]); 512 printk("%d: 0x%8.8x(0x%8.8x)\n",
513 i, leptr, (uint)lp->rx_buf_ptr_cpu[i]);
497 } 514 }
498 iob(); 515 iob();
499} 516}
@@ -511,11 +528,13 @@ static int init_restart_lance(struct lance_private *lp)
511 udelay(10); 528 udelay(10);
512 } 529 }
513 if ((i == 100) || (ll->rdp & LE_C0_ERR)) { 530 if ((i == 100) || (ll->rdp & LE_C0_ERR)) {
514 printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, ll->rdp); 531 printk("LANCE unopened after %d ticks, csr0=%4.4x.\n",
532 i, ll->rdp);
515 return -1; 533 return -1;
516 } 534 }
517 if ((ll->rdp & LE_C0_ERR)) { 535 if ((ll->rdp & LE_C0_ERR)) {
518 printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, ll->rdp); 536 printk("LANCE unopened after %d ticks, csr0=%4.4x.\n",
537 i, ll->rdp);
519 return -1; 538 return -1;
520 } 539 }
521 writereg(&ll->rdp, LE_C0_IDON); 540 writereg(&ll->rdp, LE_C0_IDON);
@@ -528,12 +547,11 @@ static int init_restart_lance(struct lance_private *lp)
528static int lance_rx(struct net_device *dev) 547static int lance_rx(struct net_device *dev)
529{ 548{
530 struct lance_private *lp = netdev_priv(dev); 549 struct lance_private *lp = netdev_priv(dev);
531 volatile struct lance_init_block *ib; 550 volatile u16 *ib = (volatile u16 *)dev->mem_start;
532 volatile struct lance_rx_desc *rd = 0; 551 volatile u16 *rd;
533 unsigned char bits; 552 unsigned short bits;
534 int len = 0; 553 int entry, len;
535 struct sk_buff *skb = 0; 554 struct sk_buff *skb;
536 ib = (struct lance_init_block *) (dev->mem_start);
537 555
538#ifdef TEST_HITS 556#ifdef TEST_HITS
539 { 557 {
@@ -542,19 +560,22 @@ static int lance_rx(struct net_device *dev)
542 printk("["); 560 printk("[");
543 for (i = 0; i < RX_RING_SIZE; i++) { 561 for (i = 0; i < RX_RING_SIZE; i++) {
544 if (i == lp->rx_new) 562 if (i == lp->rx_new)
545 printk("%s", ib->brx_ring[i].rmd1_bits & 563 printk("%s", *lib_ptr(ib, brx_ring[i].rmd1,
564 lp->type) &
546 LE_R1_OWN ? "_" : "X"); 565 LE_R1_OWN ? "_" : "X");
547 else 566 else
548 printk("%s", ib->brx_ring[i].rmd1_bits & 567 printk("%s", *lib_ptr(ib, brx_ring[i].rmd1,
568 lp->type) &
549 LE_R1_OWN ? "." : "1"); 569 LE_R1_OWN ? "." : "1");
550 } 570 }
551 printk("]"); 571 printk("]");
552 } 572 }
553#endif 573#endif
554 574
555 for (rd = &ib->brx_ring[lp->rx_new]; 575 for (rd = lib_ptr(ib, brx_ring[lp->rx_new], lp->type);
556 !((bits = rd->rmd1_bits) & LE_R1_OWN); 576 !((bits = *rds_ptr(rd, rmd1, lp->type)) & LE_R1_OWN);
557 rd = &ib->brx_ring[lp->rx_new]) { 577 rd = lib_ptr(ib, brx_ring[lp->rx_new], lp->type)) {
578 entry = lp->rx_new;
558 579
559 /* We got an incomplete frame? */ 580 /* We got an incomplete frame? */
560 if ((bits & LE_R1_POK) != LE_R1_POK) { 581 if ((bits & LE_R1_POK) != LE_R1_POK) {
@@ -575,16 +596,18 @@ static int lance_rx(struct net_device *dev)
575 if (bits & LE_R1_EOP) 596 if (bits & LE_R1_EOP)
576 lp->stats.rx_errors++; 597 lp->stats.rx_errors++;
577 } else { 598 } else {
578 len = (rd->mblength & 0xfff) - 4; 599 len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4;
579 skb = dev_alloc_skb(len + 2); 600 skb = dev_alloc_skb(len + 2);
580 601
581 if (skb == 0) { 602 if (skb == 0) {
582 printk("%s: Memory squeeze, deferring packet.\n", 603 printk("%s: Memory squeeze, deferring packet.\n",
583 dev->name); 604 dev->name);
584 lp->stats.rx_dropped++; 605 lp->stats.rx_dropped++;
585 rd->mblength = 0; 606 *rds_ptr(rd, mblength, lp->type) = 0;
586 rd->rmd1_bits = LE_R1_OWN; 607 *rds_ptr(rd, rmd1, lp->type) =
587 lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK; 608 ((lp->rx_buf_ptr_lnc[entry] >> 16) &
609 0xff) | LE_R1_OWN;
610 lp->rx_new = (entry + 1) & RX_RING_MOD_MASK;
588 return 0; 611 return 0;
589 } 612 }
590 lp->stats.rx_bytes += len; 613 lp->stats.rx_bytes += len;
@@ -594,8 +617,7 @@ static int lance_rx(struct net_device *dev)
594 skb_put(skb, len); /* make room */ 617 skb_put(skb, len); /* make room */
595 618
596 cp_from_buf(lp->type, skb->data, 619 cp_from_buf(lp->type, skb->data,
597 (char *)lp->rx_buf_ptr_cpu[lp->rx_new], 620 (char *)lp->rx_buf_ptr_cpu[entry], len);
598 len);
599 621
600 skb->protocol = eth_type_trans(skb, dev); 622 skb->protocol = eth_type_trans(skb, dev);
601 netif_rx(skb); 623 netif_rx(skb);
@@ -604,10 +626,11 @@ static int lance_rx(struct net_device *dev)
604 } 626 }
605 627
606 /* Return the packet to the pool */ 628 /* Return the packet to the pool */
607 rd->mblength = 0; 629 *rds_ptr(rd, mblength, lp->type) = 0;
608 rd->length = -RX_BUFF_SIZE | 0xf000; 630 *rds_ptr(rd, length, lp->type) = -RX_BUFF_SIZE | 0xf000;
609 rd->rmd1_bits = LE_R1_OWN; 631 *rds_ptr(rd, rmd1, lp->type) =
610 lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK; 632 ((lp->rx_buf_ptr_lnc[entry] >> 16) & 0xff) | LE_R1_OWN;
633 lp->rx_new = (entry + 1) & RX_RING_MOD_MASK;
611 } 634 }
612 return 0; 635 return 0;
613} 636}
@@ -615,24 +638,24 @@ static int lance_rx(struct net_device *dev)
615static void lance_tx(struct net_device *dev) 638static void lance_tx(struct net_device *dev)
616{ 639{
617 struct lance_private *lp = netdev_priv(dev); 640 struct lance_private *lp = netdev_priv(dev);
618 volatile struct lance_init_block *ib; 641 volatile u16 *ib = (volatile u16 *)dev->mem_start;
619 volatile struct lance_regs *ll = lp->ll; 642 volatile struct lance_regs *ll = lp->ll;
620 volatile struct lance_tx_desc *td; 643 volatile u16 *td;
621 int i, j; 644 int i, j;
622 int status; 645 int status;
623 ib = (struct lance_init_block *) (dev->mem_start); 646
624 j = lp->tx_old; 647 j = lp->tx_old;
625 648
626 spin_lock(&lp->lock); 649 spin_lock(&lp->lock);
627 650
628 for (i = j; i != lp->tx_new; i = j) { 651 for (i = j; i != lp->tx_new; i = j) {
629 td = &ib->btx_ring[i]; 652 td = lib_ptr(ib, btx_ring[i], lp->type);
630 /* If we hit a packet not owned by us, stop */ 653 /* If we hit a packet not owned by us, stop */
631 if (td->tmd1_bits & LE_T1_OWN) 654 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_OWN)
632 break; 655 break;
633 656
634 if (td->tmd1_bits & LE_T1_ERR) { 657 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_ERR) {
635 status = td->misc; 658 status = *tds_ptr(td, misc, lp->type);
636 659
637 lp->stats.tx_errors++; 660 lp->stats.tx_errors++;
638 if (status & LE_T3_RTY) 661 if (status & LE_T3_RTY)
@@ -667,18 +690,19 @@ static void lance_tx(struct net_device *dev)
667 init_restart_lance(lp); 690 init_restart_lance(lp);
668 goto out; 691 goto out;
669 } 692 }
670 } else if ((td->tmd1_bits & LE_T1_POK) == LE_T1_POK) { 693 } else if ((*tds_ptr(td, tmd1, lp->type) & LE_T1_POK) ==
694 LE_T1_POK) {
671 /* 695 /*
672 * So we don't count the packet more than once. 696 * So we don't count the packet more than once.
673 */ 697 */
674 td->tmd1_bits &= ~(LE_T1_POK); 698 *tds_ptr(td, tmd1, lp->type) &= ~(LE_T1_POK);
675 699
676 /* One collision before packet was sent. */ 700 /* One collision before packet was sent. */
677 if (td->tmd1_bits & LE_T1_EONE) 701 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EONE)
678 lp->stats.collisions++; 702 lp->stats.collisions++;
679 703
680 /* More than one collision, be optimistic. */ 704 /* More than one collision, be optimistic. */
681 if (td->tmd1_bits & LE_T1_EMORE) 705 if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EMORE)
682 lp->stats.collisions += 2; 706 lp->stats.collisions += 2;
683 707
684 lp->stats.tx_packets++; 708 lp->stats.tx_packets++;
@@ -752,7 +776,7 @@ struct net_device *last_dev = 0;
752 776
753static int lance_open(struct net_device *dev) 777static int lance_open(struct net_device *dev)
754{ 778{
755 volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); 779 volatile u16 *ib = (volatile u16 *)dev->mem_start;
756 struct lance_private *lp = netdev_priv(dev); 780 struct lance_private *lp = netdev_priv(dev);
757 volatile struct lance_regs *ll = lp->ll; 781 volatile struct lance_regs *ll = lp->ll;
758 int status = 0; 782 int status = 0;
@@ -769,11 +793,11 @@ static int lance_open(struct net_device *dev)
769 * 793 *
770 * BTW it is common bug in all lance drivers! --ANK 794 * BTW it is common bug in all lance drivers! --ANK
771 */ 795 */
772 ib->mode = 0; 796 *lib_ptr(ib, mode, lp->type) = 0;
773 ib->filter [0] = 0; 797 *lib_ptr(ib, filter[0], lp->type) = 0;
774 ib->filter [2] = 0; 798 *lib_ptr(ib, filter[1], lp->type) = 0;
775 ib->filter [4] = 0; 799 *lib_ptr(ib, filter[2], lp->type) = 0;
776 ib->filter [6] = 0; 800 *lib_ptr(ib, filter[3], lp->type) = 0;
777 801
778 lance_init_ring(dev); 802 lance_init_ring(dev);
779 load_csrs(lp); 803 load_csrs(lp);
@@ -874,12 +898,10 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
874{ 898{
875 struct lance_private *lp = netdev_priv(dev); 899 struct lance_private *lp = netdev_priv(dev);
876 volatile struct lance_regs *ll = lp->ll; 900 volatile struct lance_regs *ll = lp->ll;
877 volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); 901 volatile u16 *ib = (volatile u16 *)dev->mem_start;
878 int entry, skblen, len; 902 int entry, len;
879 903
880 skblen = skb->len; 904 len = skb->len;
881
882 len = skblen;
883 905
884 if (len < ETH_ZLEN) { 906 if (len < ETH_ZLEN) {
885 if (skb_padto(skb, ETH_ZLEN)) 907 if (skb_padto(skb, ETH_ZLEN))
@@ -889,23 +911,17 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev)
889 911
890 lp->stats.tx_bytes += len; 912 lp->stats.tx_bytes += len;
891 913
892 entry = lp->tx_new & TX_RING_MOD_MASK; 914 entry = lp->tx_new;
893 ib->btx_ring[entry].length = (-len); 915 *lib_ptr(ib, btx_ring[entry].length, lp->type) = (-len);
894 ib->btx_ring[entry].misc = 0; 916 *lib_ptr(ib, btx_ring[entry].misc, lp->type) = 0;
895
896 cp_to_buf(lp->type, (char *)lp->tx_buf_ptr_cpu[entry], skb->data,
897 skblen);
898 917
899 /* Clear the slack of the packet, do I need this? */ 918 cp_to_buf(lp->type, (char *)lp->tx_buf_ptr_cpu[entry], skb->data, len);
900 /* For a firewall it's a good idea - AC */
901/*
902 if (len != skblen)
903 memset ((char *) &ib->tx_buf [entry][skblen], 0, (len - skblen) << 1);
904 */
905 919
906 /* Now, give the packet to the lance */ 920 /* Now, give the packet to the lance */
907 ib->btx_ring[entry].tmd1_bits = (LE_T1_POK | LE_T1_OWN); 921 *lib_ptr(ib, btx_ring[entry].tmd1, lp->type) =
908 lp->tx_new = (lp->tx_new + 1) & TX_RING_MOD_MASK; 922 ((lp->tx_buf_ptr_lnc[entry] >> 16) & 0xff) |
923 (LE_T1_POK | LE_T1_OWN);
924 lp->tx_new = (entry + 1) & TX_RING_MOD_MASK;
909 925
910 if (TX_BUFFS_AVAIL <= 0) 926 if (TX_BUFFS_AVAIL <= 0)
911 netif_stop_queue(dev); 927 netif_stop_queue(dev);
@@ -930,8 +946,8 @@ static struct net_device_stats *lance_get_stats(struct net_device *dev)
930 946
931static void lance_load_multicast(struct net_device *dev) 947static void lance_load_multicast(struct net_device *dev)
932{ 948{
933 volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); 949 struct lance_private *lp = netdev_priv(dev);
934 volatile u16 *mcast_table = (u16 *) & ib->filter; 950 volatile u16 *ib = (volatile u16 *)dev->mem_start;
935 struct dev_mc_list *dmi = dev->mc_list; 951 struct dev_mc_list *dmi = dev->mc_list;
936 char *addrs; 952 char *addrs;
937 int i; 953 int i;
@@ -939,17 +955,17 @@ static void lance_load_multicast(struct net_device *dev)
939 955
940 /* set all multicast bits */ 956 /* set all multicast bits */
941 if (dev->flags & IFF_ALLMULTI) { 957 if (dev->flags & IFF_ALLMULTI) {
942 ib->filter[0] = 0xffff; 958 *lib_ptr(ib, filter[0], lp->type) = 0xffff;
943 ib->filter[2] = 0xffff; 959 *lib_ptr(ib, filter[1], lp->type) = 0xffff;
944 ib->filter[4] = 0xffff; 960 *lib_ptr(ib, filter[2], lp->type) = 0xffff;
945 ib->filter[6] = 0xffff; 961 *lib_ptr(ib, filter[3], lp->type) = 0xffff;
946 return; 962 return;
947 } 963 }
948 /* clear the multicast filter */ 964 /* clear the multicast filter */
949 ib->filter[0] = 0; 965 *lib_ptr(ib, filter[0], lp->type) = 0;
950 ib->filter[2] = 0; 966 *lib_ptr(ib, filter[1], lp->type) = 0;
951 ib->filter[4] = 0; 967 *lib_ptr(ib, filter[2], lp->type) = 0;
952 ib->filter[6] = 0; 968 *lib_ptr(ib, filter[3], lp->type) = 0;
953 969
954 /* Add addresses */ 970 /* Add addresses */
955 for (i = 0; i < dev->mc_count; i++) { 971 for (i = 0; i < dev->mc_count; i++) {
@@ -962,7 +978,7 @@ static void lance_load_multicast(struct net_device *dev)
962 978
963 crc = ether_crc_le(ETH_ALEN, addrs); 979 crc = ether_crc_le(ETH_ALEN, addrs);
964 crc = crc >> 26; 980 crc = crc >> 26;
965 mcast_table[2 * (crc >> 4)] |= 1 << (crc & 0xf); 981 *lib_ptr(ib, filter[crc >> 4], lp->type) |= 1 << (crc & 0xf);
966 } 982 }
967 return; 983 return;
968} 984}
@@ -970,11 +986,9 @@ static void lance_load_multicast(struct net_device *dev)
970static void lance_set_multicast(struct net_device *dev) 986static void lance_set_multicast(struct net_device *dev)
971{ 987{
972 struct lance_private *lp = netdev_priv(dev); 988 struct lance_private *lp = netdev_priv(dev);
973 volatile struct lance_init_block *ib; 989 volatile u16 *ib = (volatile u16 *)dev->mem_start;
974 volatile struct lance_regs *ll = lp->ll; 990 volatile struct lance_regs *ll = lp->ll;
975 991
976 ib = (struct lance_init_block *) (dev->mem_start);
977
978 if (!netif_running(dev)) 992 if (!netif_running(dev))
979 return; 993 return;
980 994
@@ -992,9 +1006,9 @@ static void lance_set_multicast(struct net_device *dev)
992 lance_init_ring(dev); 1006 lance_init_ring(dev);
993 1007
994 if (dev->flags & IFF_PROMISC) { 1008 if (dev->flags & IFF_PROMISC) {
995 ib->mode |= LE_MO_PROM; 1009 *lib_ptr(ib, mode, lp->type) |= LE_MO_PROM;
996 } else { 1010 } else {
997 ib->mode &= ~LE_MO_PROM; 1011 *lib_ptr(ib, mode, lp->type) &= ~LE_MO_PROM;
998 lance_load_multicast(dev); 1012 lance_load_multicast(dev);
999 } 1013 }
1000 load_csrs(lp); 1014 load_csrs(lp);
@@ -1051,7 +1065,6 @@ static int __init dec_lance_init(const int type, const int slot)
1051 lp->type = type; 1065 lp->type = type;
1052 lp->slot = slot; 1066 lp->slot = slot;
1053 switch (type) { 1067 switch (type) {
1054#ifdef CONFIG_TC
1055 case ASIC_LANCE: 1068 case ASIC_LANCE:
1056 dev->base_addr = CKSEG1ADDR(dec_kn_slot_base + IOASIC_LANCE); 1069 dev->base_addr = CKSEG1ADDR(dec_kn_slot_base + IOASIC_LANCE);
1057 1070
@@ -1073,20 +1086,20 @@ static int __init dec_lance_init(const int type, const int slot)
1073 */ 1086 */
1074 for (i = 0; i < RX_RING_SIZE; i++) { 1087 for (i = 0; i < RX_RING_SIZE; i++) {
1075 lp->rx_buf_ptr_cpu[i] = 1088 lp->rx_buf_ptr_cpu[i] =
1076 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1089 (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
1077 2 * i * RX_BUFF_SIZE); 1090 2 * i * RX_BUFF_SIZE);
1078 lp->rx_buf_ptr_lnc[i] = 1091 lp->rx_buf_ptr_lnc[i] =
1079 (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE); 1092 (BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
1080 } 1093 }
1081 for (i = 0; i < TX_RING_SIZE; i++) { 1094 for (i = 0; i < TX_RING_SIZE; i++) {
1082 lp->tx_buf_ptr_cpu[i] = 1095 lp->tx_buf_ptr_cpu[i] =
1083 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1096 (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
1084 2 * RX_RING_SIZE * RX_BUFF_SIZE + 1097 2 * RX_RING_SIZE * RX_BUFF_SIZE +
1085 2 * i * TX_BUFF_SIZE); 1098 2 * i * TX_BUFF_SIZE);
1086 lp->tx_buf_ptr_lnc[i] = 1099 lp->tx_buf_ptr_lnc[i] =
1087 (char *)(BUF_OFFSET_LNC + 1100 (BUF_OFFSET_LNC +
1088 RX_RING_SIZE * RX_BUFF_SIZE + 1101 RX_RING_SIZE * RX_BUFF_SIZE +
1089 i * TX_BUFF_SIZE); 1102 i * TX_BUFF_SIZE);
1090 } 1103 }
1091 1104
1092 /* Setup I/O ASIC LANCE DMA. */ 1105 /* Setup I/O ASIC LANCE DMA. */
@@ -1095,11 +1108,12 @@ static int __init dec_lance_init(const int type, const int slot)
1095 CPHYSADDR(dev->mem_start) << 3); 1108 CPHYSADDR(dev->mem_start) << 3);
1096 1109
1097 break; 1110 break;
1098 1111#ifdef CONFIG_TC
1099 case PMAD_LANCE: 1112 case PMAD_LANCE:
1100 claim_tc_card(slot); 1113 claim_tc_card(slot);
1101 1114
1102 dev->mem_start = CKSEG1ADDR(get_tc_base_addr(slot)); 1115 dev->mem_start = CKSEG1ADDR(get_tc_base_addr(slot));
1116 dev->mem_end = dev->mem_start + 0x100000;
1103 dev->base_addr = dev->mem_start + 0x100000; 1117 dev->base_addr = dev->mem_start + 0x100000;
1104 dev->irq = get_tc_irq_nr(slot); 1118 dev->irq = get_tc_irq_nr(slot);
1105 esar_base = dev->mem_start + 0x1c0002; 1119 esar_base = dev->mem_start + 0x1c0002;
@@ -1110,7 +1124,7 @@ static int __init dec_lance_init(const int type, const int slot)
1110 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1124 (char *)(dev->mem_start + BUF_OFFSET_CPU +
1111 i * RX_BUFF_SIZE); 1125 i * RX_BUFF_SIZE);
1112 lp->rx_buf_ptr_lnc[i] = 1126 lp->rx_buf_ptr_lnc[i] =
1113 (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE); 1127 (BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
1114 } 1128 }
1115 for (i = 0; i < TX_RING_SIZE; i++) { 1129 for (i = 0; i < TX_RING_SIZE; i++) {
1116 lp->tx_buf_ptr_cpu[i] = 1130 lp->tx_buf_ptr_cpu[i] =
@@ -1118,18 +1132,18 @@ static int __init dec_lance_init(const int type, const int slot)
1118 RX_RING_SIZE * RX_BUFF_SIZE + 1132 RX_RING_SIZE * RX_BUFF_SIZE +
1119 i * TX_BUFF_SIZE); 1133 i * TX_BUFF_SIZE);
1120 lp->tx_buf_ptr_lnc[i] = 1134 lp->tx_buf_ptr_lnc[i] =
1121 (char *)(BUF_OFFSET_LNC + 1135 (BUF_OFFSET_LNC +
1122 RX_RING_SIZE * RX_BUFF_SIZE + 1136 RX_RING_SIZE * RX_BUFF_SIZE +
1123 i * TX_BUFF_SIZE); 1137 i * TX_BUFF_SIZE);
1124 } 1138 }
1125 1139
1126 break; 1140 break;
1127#endif 1141#endif
1128
1129 case PMAX_LANCE: 1142 case PMAX_LANCE:
1130 dev->irq = dec_interrupt[DEC_IRQ_LANCE]; 1143 dev->irq = dec_interrupt[DEC_IRQ_LANCE];
1131 dev->base_addr = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE); 1144 dev->base_addr = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE);
1132 dev->mem_start = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE_MEM); 1145 dev->mem_start = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE_MEM);
1146 dev->mem_end = dev->mem_start + KN01_SLOT_SIZE;
1133 esar_base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_ESAR + 1); 1147 esar_base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_ESAR + 1);
1134 lp->dma_irq = -1; 1148 lp->dma_irq = -1;
1135 1149
@@ -1138,20 +1152,20 @@ static int __init dec_lance_init(const int type, const int slot)
1138 */ 1152 */
1139 for (i = 0; i < RX_RING_SIZE; i++) { 1153 for (i = 0; i < RX_RING_SIZE; i++) {
1140 lp->rx_buf_ptr_cpu[i] = 1154 lp->rx_buf_ptr_cpu[i] =
1141 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1155 (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
1142 2 * i * RX_BUFF_SIZE); 1156 2 * i * RX_BUFF_SIZE);
1143 lp->rx_buf_ptr_lnc[i] = 1157 lp->rx_buf_ptr_lnc[i] =
1144 (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE); 1158 (BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
1145 } 1159 }
1146 for (i = 0; i < TX_RING_SIZE; i++) { 1160 for (i = 0; i < TX_RING_SIZE; i++) {
1147 lp->tx_buf_ptr_cpu[i] = 1161 lp->tx_buf_ptr_cpu[i] =
1148 (char *)(dev->mem_start + BUF_OFFSET_CPU + 1162 (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
1149 2 * RX_RING_SIZE * RX_BUFF_SIZE + 1163 2 * RX_RING_SIZE * RX_BUFF_SIZE +
1150 2 * i * TX_BUFF_SIZE); 1164 2 * i * TX_BUFF_SIZE);
1151 lp->tx_buf_ptr_lnc[i] = 1165 lp->tx_buf_ptr_lnc[i] =
1152 (char *)(BUF_OFFSET_LNC + 1166 (BUF_OFFSET_LNC +
1153 RX_RING_SIZE * RX_BUFF_SIZE + 1167 RX_RING_SIZE * RX_BUFF_SIZE +
1154 i * TX_BUFF_SIZE); 1168 i * TX_BUFF_SIZE);
1155 } 1169 }
1156 1170
1157 break; 1171 break;
@@ -1279,10 +1293,8 @@ static int __init dec_lance_probe(void)
1279 /* Then handle onboard devices. */ 1293 /* Then handle onboard devices. */
1280 if (dec_interrupt[DEC_IRQ_LANCE] >= 0) { 1294 if (dec_interrupt[DEC_IRQ_LANCE] >= 0) {
1281 if (dec_interrupt[DEC_IRQ_LANCE_MERR] >= 0) { 1295 if (dec_interrupt[DEC_IRQ_LANCE_MERR] >= 0) {
1282#ifdef CONFIG_TC
1283 if (dec_lance_init(ASIC_LANCE, -1) >= 0) 1296 if (dec_lance_init(ASIC_LANCE, -1) >= 0)
1284 count++; 1297 count++;
1285#endif
1286 } else if (!TURBOCHANNEL) { 1298 } else if (!TURBOCHANNEL) {
1287 if (dec_lance_init(PMAX_LANCE, -1) >= 0) 1299 if (dec_lance_init(PMAX_LANCE, -1) >= 0)
1288 count++; 1300 count++;
diff --git a/drivers/net/e2100.c b/drivers/net/e2100.c
index d39e8480ca56..c62d9c6363c6 100644
--- a/drivers/net/e2100.c
+++ b/drivers/net/e2100.c
@@ -463,7 +463,7 @@ static void cleanup_card(struct net_device *dev)
463 release_region(dev->base_addr, E21_IO_EXTENT); 463 release_region(dev->base_addr, E21_IO_EXTENT);
464} 464}
465 465
466void 466void __exit
467cleanup_module(void) 467cleanup_module(void)
468{ 468{
469 int this_dev; 469 int this_dev;
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index a4eb0dc99ecf..b4463094c93a 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -1827,7 +1827,7 @@ int __init init_module(void)
1827 return n_eepro ? 0 : -ENODEV; 1827 return n_eepro ? 0 : -ENODEV;
1828} 1828}
1829 1829
1830void 1830void __exit
1831cleanup_module(void) 1831cleanup_module(void)
1832{ 1832{
1833 int i; 1833 int i;
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index e14be020e562..4a50fcb5ad6b 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -1719,7 +1719,7 @@ int __init init_module(void)
1719 return -ENXIO; 1719 return -ENXIO;
1720} 1720}
1721 1721
1722void cleanup_module(void) 1722void __exit cleanup_module(void)
1723{ 1723{
1724 int this_dev; 1724 int this_dev;
1725 1725
diff --git a/drivers/net/es3210.c b/drivers/net/es3210.c
index fd7b32a24ea4..2d2ea94a00bb 100644
--- a/drivers/net/es3210.c
+++ b/drivers/net/es3210.c
@@ -455,7 +455,7 @@ static void cleanup_card(struct net_device *dev)
455 iounmap(ei_status.mem); 455 iounmap(ei_status.mem);
456} 456}
457 457
458void 458void __exit
459cleanup_module(void) 459cleanup_module(void)
460{ 460{
461 int this_dev; 461 int this_dev;
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c
index b7b8bc2a6307..93283e386f3a 100644
--- a/drivers/net/eth16i.c
+++ b/drivers/net/eth16i.c
@@ -1475,7 +1475,7 @@ int __init init_module(void)
1475 return -ENXIO; 1475 return -ENXIO;
1476} 1476}
1477 1477
1478void cleanup_module(void) 1478void __exit cleanup_module(void)
1479{ 1479{
1480 int this_dev; 1480 int this_dev;
1481 1481
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index 6abcfd2a4b28..99a36cc3f8df 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -482,7 +482,7 @@ static void cleanup_card(struct net_device *dev)
482 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT); 482 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
483} 483}
484 484
485void 485void __exit
486cleanup_module(void) 486cleanup_module(void)
487{ 487{
488 int this_dev; 488 int this_dev;
diff --git a/drivers/net/hp.c b/drivers/net/hp.c
index 29470970aa27..635b13c2e2aa 100644
--- a/drivers/net/hp.c
+++ b/drivers/net/hp.c
@@ -444,7 +444,7 @@ static void cleanup_card(struct net_device *dev)
444 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT); 444 release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
445} 445}
446 446
447void 447void __exit
448cleanup_module(void) 448cleanup_module(void)
449{ 449{
450 int this_dev; 450 int this_dev;
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index f9a1c88a4283..9137e239fac2 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -704,9 +704,9 @@ static int pxa_irda_stop(struct net_device *dev)
704 return 0; 704 return 0;
705} 705}
706 706
707static int pxa_irda_suspend(struct device *_dev, pm_message_t state) 707static int pxa_irda_suspend(struct platform_device *_dev, pm_message_t state)
708{ 708{
709 struct net_device *dev = dev_get_drvdata(_dev); 709 struct net_device *dev = platform_get_drvdata(_dev);
710 struct pxa_irda *si; 710 struct pxa_irda *si;
711 711
712 if (dev && netif_running(dev)) { 712 if (dev && netif_running(dev)) {
@@ -718,9 +718,9 @@ static int pxa_irda_suspend(struct device *_dev, pm_message_t state)
718 return 0; 718 return 0;
719} 719}
720 720
721static int pxa_irda_resume(struct device *_dev) 721static int pxa_irda_resume(struct platform_device *_dev)
722{ 722{
723 struct net_device *dev = dev_get_drvdata(_dev); 723 struct net_device *dev = platform_get_drvdata(_dev);
724 struct pxa_irda *si; 724 struct pxa_irda *si;
725 725
726 if (dev && netif_running(dev)) { 726 if (dev && netif_running(dev)) {
@@ -746,9 +746,8 @@ static int pxa_irda_init_iobuf(iobuff_t *io, int size)
746 return io->head ? 0 : -ENOMEM; 746 return io->head ? 0 : -ENOMEM;
747} 747}
748 748
749static int pxa_irda_probe(struct device *_dev) 749static int pxa_irda_probe(struct platform_device *pdev)
750{ 750{
751 struct platform_device *pdev = to_platform_device(_dev);
752 struct net_device *dev; 751 struct net_device *dev;
753 struct pxa_irda *si; 752 struct pxa_irda *si;
754 unsigned int baudrate_mask; 753 unsigned int baudrate_mask;
@@ -822,9 +821,9 @@ err_mem_1:
822 return err; 821 return err;
823} 822}
824 823
825static int pxa_irda_remove(struct device *_dev) 824static int pxa_irda_remove(struct platform_device *_dev)
826{ 825{
827 struct net_device *dev = dev_get_drvdata(_dev); 826 struct net_device *dev = platform_get_drvdata(_dev);
828 827
829 if (dev) { 828 if (dev) {
830 struct pxa_irda *si = netdev_priv(dev); 829 struct pxa_irda *si = netdev_priv(dev);
@@ -840,9 +839,10 @@ static int pxa_irda_remove(struct device *_dev)
840 return 0; 839 return 0;
841} 840}
842 841
843static struct device_driver pxa_ir_driver = { 842static struct platform_driver pxa_ir_driver = {
844 .name = "pxa2xx-ir", 843 .driver = {
845 .bus = &platform_bus_type, 844 .name = "pxa2xx-ir",
845 },
846 .probe = pxa_irda_probe, 846 .probe = pxa_irda_probe,
847 .remove = pxa_irda_remove, 847 .remove = pxa_irda_remove,
848 .suspend = pxa_irda_suspend, 848 .suspend = pxa_irda_suspend,
@@ -851,12 +851,12 @@ static struct device_driver pxa_ir_driver = {
851 851
852static int __init pxa_irda_init(void) 852static int __init pxa_irda_init(void)
853{ 853{
854 return driver_register(&pxa_ir_driver); 854 return platform_driver_register(&pxa_ir_driver);
855} 855}
856 856
857static void __exit pxa_irda_exit(void) 857static void __exit pxa_irda_exit(void)
858{ 858{
859 driver_unregister(&pxa_ir_driver); 859 platform_driver_unregister(&pxa_ir_driver);
860} 860}
861 861
862module_init(pxa_irda_init); 862module_init(pxa_irda_init);
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 3b4c47875935..c14a74634fd5 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -50,6 +50,7 @@
50#include <linux/usb.h> 50#include <linux/usb.h>
51#include <linux/crc32.h> 51#include <linux/crc32.h>
52#include <linux/kthread.h> 52#include <linux/kthread.h>
53#include <linux/freezer.h>
53#include <net/irda/irda.h> 54#include <net/irda/irda.h>
54#include <net/irda/irlap.h> 55#include <net/irda/irlap.h>
55#include <net/irda/irda_device.h> 56#include <net/irda/irda_device.h>
diff --git a/drivers/net/lance.c b/drivers/net/lance.c
index 4256c13c73c2..a3843320dbe1 100644
--- a/drivers/net/lance.c
+++ b/drivers/net/lance.c
@@ -368,7 +368,7 @@ static void cleanup_card(struct net_device *dev)
368 kfree(lp); 368 kfree(lp);
369} 369}
370 370
371void cleanup_module(void) 371void __exit cleanup_module(void)
372{ 372{
373 int this_dev; 373 int this_dev;
374 374
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index f4d815bca643..ea392f2a5aa2 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -119,14 +119,14 @@
119#define DEB(x,y) if (i596_debug & (x)) { y; } 119#define DEB(x,y) if (i596_debug & (x)) { y; }
120 120
121 121
122#define CHECK_WBACK(addr,len) \ 122#define CHECK_WBACK(priv, addr,len) \
123 do { dma_cache_sync((void *)addr, len, DMA_TO_DEVICE); } while (0) 123 do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_TO_DEVICE); } while (0)
124 124
125#define CHECK_INV(addr,len) \ 125#define CHECK_INV(priv, addr,len) \
126 do { dma_cache_sync((void *)addr, len, DMA_FROM_DEVICE); } while(0) 126 do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_FROM_DEVICE); } while(0)
127 127
128#define CHECK_WBACK_INV(addr,len) \ 128#define CHECK_WBACK_INV(priv, addr,len) \
129 do { dma_cache_sync((void *)addr, len, DMA_BIDIRECTIONAL); } while (0) 129 do { dma_cache_sync((priv)->dev, (void *)addr, len, DMA_BIDIRECTIONAL); } while (0)
130 130
131 131
132#define PA_I82596_RESET 0 /* Offsets relative to LASI-LAN-Addr.*/ 132#define PA_I82596_RESET 0 /* Offsets relative to LASI-LAN-Addr.*/
@@ -449,10 +449,10 @@ static inline void MPU_PORT(struct net_device *dev, int c, dma_addr_t x)
449 449
450static inline int wait_istat(struct net_device *dev, struct i596_private *lp, int delcnt, char *str) 450static inline int wait_istat(struct net_device *dev, struct i596_private *lp, int delcnt, char *str)
451{ 451{
452 CHECK_INV(&(lp->iscp), sizeof(struct i596_iscp)); 452 CHECK_INV(lp, &(lp->iscp), sizeof(struct i596_iscp));
453 while (--delcnt && lp->iscp.stat) { 453 while (--delcnt && lp->iscp.stat) {
454 udelay(10); 454 udelay(10);
455 CHECK_INV(&(lp->iscp), sizeof(struct i596_iscp)); 455 CHECK_INV(lp, &(lp->iscp), sizeof(struct i596_iscp));
456 } 456 }
457 if (!delcnt) { 457 if (!delcnt) {
458 printk("%s: %s, iscp.stat %04x, didn't clear\n", 458 printk("%s: %s, iscp.stat %04x, didn't clear\n",
@@ -466,10 +466,10 @@ static inline int wait_istat(struct net_device *dev, struct i596_private *lp, in
466 466
467static inline int wait_cmd(struct net_device *dev, struct i596_private *lp, int delcnt, char *str) 467static inline int wait_cmd(struct net_device *dev, struct i596_private *lp, int delcnt, char *str)
468{ 468{
469 CHECK_INV(&(lp->scb), sizeof(struct i596_scb)); 469 CHECK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
470 while (--delcnt && lp->scb.command) { 470 while (--delcnt && lp->scb.command) {
471 udelay(10); 471 udelay(10);
472 CHECK_INV(&(lp->scb), sizeof(struct i596_scb)); 472 CHECK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
473 } 473 }
474 if (!delcnt) { 474 if (!delcnt) {
475 printk("%s: %s, status %4.4x, cmd %4.4x.\n", 475 printk("%s: %s, status %4.4x, cmd %4.4x.\n",
@@ -522,7 +522,7 @@ static void i596_display_data(struct net_device *dev)
522 rbd, rbd->count, rbd->b_next, rbd->b_data, rbd->size); 522 rbd, rbd->count, rbd->b_next, rbd->b_data, rbd->size);
523 rbd = rbd->v_next; 523 rbd = rbd->v_next;
524 } while (rbd != lp->rbd_head); 524 } while (rbd != lp->rbd_head);
525 CHECK_INV(lp, sizeof(struct i596_private)); 525 CHECK_INV(lp, lp, sizeof(struct i596_private));
526} 526}
527 527
528 528
@@ -592,7 +592,7 @@ static inline void init_rx_bufs(struct net_device *dev)
592 rfd->b_next = WSWAPrfd(virt_to_dma(lp,lp->rfds)); 592 rfd->b_next = WSWAPrfd(virt_to_dma(lp,lp->rfds));
593 rfd->cmd = CMD_EOL|CMD_FLEX; 593 rfd->cmd = CMD_EOL|CMD_FLEX;
594 594
595 CHECK_WBACK_INV(lp, sizeof(struct i596_private)); 595 CHECK_WBACK_INV(lp, lp, sizeof(struct i596_private));
596} 596}
597 597
598static inline void remove_rx_bufs(struct net_device *dev) 598static inline void remove_rx_bufs(struct net_device *dev)
@@ -629,7 +629,7 @@ static void rebuild_rx_bufs(struct net_device *dev)
629 lp->rbd_head = lp->rbds; 629 lp->rbd_head = lp->rbds;
630 lp->rfds[0].rbd = WSWAPrbd(virt_to_dma(lp,lp->rbds)); 630 lp->rfds[0].rbd = WSWAPrbd(virt_to_dma(lp,lp->rbds));
631 631
632 CHECK_WBACK_INV(lp, sizeof(struct i596_private)); 632 CHECK_WBACK_INV(lp, lp, sizeof(struct i596_private));
633} 633}
634 634
635 635
@@ -663,8 +663,8 @@ static int init_i596_mem(struct net_device *dev)
663 663
664 DEB(DEB_INIT, printk("%s: starting i82596.\n", dev->name)); 664 DEB(DEB_INIT, printk("%s: starting i82596.\n", dev->name));
665 665
666 CHECK_WBACK(&(lp->scp), sizeof(struct i596_scp)); 666 CHECK_WBACK(lp, &(lp->scp), sizeof(struct i596_scp));
667 CHECK_WBACK(&(lp->iscp), sizeof(struct i596_iscp)); 667 CHECK_WBACK(lp, &(lp->iscp), sizeof(struct i596_iscp));
668 668
669 MPU_PORT(dev, PORT_ALTSCP, virt_to_dma(lp,&lp->scp)); 669 MPU_PORT(dev, PORT_ALTSCP, virt_to_dma(lp,&lp->scp));
670 670
@@ -678,25 +678,25 @@ static int init_i596_mem(struct net_device *dev)
678 rebuild_rx_bufs(dev); 678 rebuild_rx_bufs(dev);
679 679
680 lp->scb.command = 0; 680 lp->scb.command = 0;
681 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 681 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
682 682
683 enable_irq(dev->irq); /* enable IRQs from LAN */ 683 enable_irq(dev->irq); /* enable IRQs from LAN */
684 684
685 DEB(DEB_INIT, printk("%s: queuing CmdConfigure\n", dev->name)); 685 DEB(DEB_INIT, printk("%s: queuing CmdConfigure\n", dev->name));
686 memcpy(lp->cf_cmd.i596_config, init_setup, 14); 686 memcpy(lp->cf_cmd.i596_config, init_setup, 14);
687 lp->cf_cmd.cmd.command = CmdConfigure; 687 lp->cf_cmd.cmd.command = CmdConfigure;
688 CHECK_WBACK(&(lp->cf_cmd), sizeof(struct cf_cmd)); 688 CHECK_WBACK(lp, &(lp->cf_cmd), sizeof(struct cf_cmd));
689 i596_add_cmd(dev, &lp->cf_cmd.cmd); 689 i596_add_cmd(dev, &lp->cf_cmd.cmd);
690 690
691 DEB(DEB_INIT, printk("%s: queuing CmdSASetup\n", dev->name)); 691 DEB(DEB_INIT, printk("%s: queuing CmdSASetup\n", dev->name));
692 memcpy(lp->sa_cmd.eth_addr, dev->dev_addr, 6); 692 memcpy(lp->sa_cmd.eth_addr, dev->dev_addr, 6);
693 lp->sa_cmd.cmd.command = CmdSASetup; 693 lp->sa_cmd.cmd.command = CmdSASetup;
694 CHECK_WBACK(&(lp->sa_cmd), sizeof(struct sa_cmd)); 694 CHECK_WBACK(lp, &(lp->sa_cmd), sizeof(struct sa_cmd));
695 i596_add_cmd(dev, &lp->sa_cmd.cmd); 695 i596_add_cmd(dev, &lp->sa_cmd.cmd);
696 696
697 DEB(DEB_INIT, printk("%s: queuing CmdTDR\n", dev->name)); 697 DEB(DEB_INIT, printk("%s: queuing CmdTDR\n", dev->name));
698 lp->tdr_cmd.cmd.command = CmdTDR; 698 lp->tdr_cmd.cmd.command = CmdTDR;
699 CHECK_WBACK(&(lp->tdr_cmd), sizeof(struct tdr_cmd)); 699 CHECK_WBACK(lp, &(lp->tdr_cmd), sizeof(struct tdr_cmd));
700 i596_add_cmd(dev, &lp->tdr_cmd.cmd); 700 i596_add_cmd(dev, &lp->tdr_cmd.cmd);
701 701
702 spin_lock_irqsave (&lp->lock, flags); 702 spin_lock_irqsave (&lp->lock, flags);
@@ -708,7 +708,7 @@ static int init_i596_mem(struct net_device *dev)
708 DEB(DEB_INIT, printk("%s: Issuing RX_START\n", dev->name)); 708 DEB(DEB_INIT, printk("%s: Issuing RX_START\n", dev->name));
709 lp->scb.command = RX_START; 709 lp->scb.command = RX_START;
710 lp->scb.rfd = WSWAPrfd(virt_to_dma(lp,lp->rfds)); 710 lp->scb.rfd = WSWAPrfd(virt_to_dma(lp,lp->rfds));
711 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 711 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
712 712
713 CA(dev); 713 CA(dev);
714 714
@@ -740,13 +740,13 @@ static inline int i596_rx(struct net_device *dev)
740 740
741 rfd = lp->rfd_head; /* Ref next frame to check */ 741 rfd = lp->rfd_head; /* Ref next frame to check */
742 742
743 CHECK_INV(rfd, sizeof(struct i596_rfd)); 743 CHECK_INV(lp, rfd, sizeof(struct i596_rfd));
744 while ((rfd->stat) & STAT_C) { /* Loop while complete frames */ 744 while ((rfd->stat) & STAT_C) { /* Loop while complete frames */
745 if (rfd->rbd == I596_NULL) 745 if (rfd->rbd == I596_NULL)
746 rbd = NULL; 746 rbd = NULL;
747 else if (rfd->rbd == lp->rbd_head->b_addr) { 747 else if (rfd->rbd == lp->rbd_head->b_addr) {
748 rbd = lp->rbd_head; 748 rbd = lp->rbd_head;
749 CHECK_INV(rbd, sizeof(struct i596_rbd)); 749 CHECK_INV(lp, rbd, sizeof(struct i596_rbd));
750 } 750 }
751 else { 751 else {
752 printk("%s: rbd chain broken!\n", dev->name); 752 printk("%s: rbd chain broken!\n", dev->name);
@@ -790,7 +790,7 @@ static inline int i596_rx(struct net_device *dev)
790 dma_addr = dma_map_single(lp->dev, newskb->data, PKT_BUF_SZ, DMA_FROM_DEVICE); 790 dma_addr = dma_map_single(lp->dev, newskb->data, PKT_BUF_SZ, DMA_FROM_DEVICE);
791 rbd->v_data = newskb->data; 791 rbd->v_data = newskb->data;
792 rbd->b_data = WSWAPchar(dma_addr); 792 rbd->b_data = WSWAPchar(dma_addr);
793 CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd)); 793 CHECK_WBACK_INV(lp, rbd, sizeof(struct i596_rbd));
794 } 794 }
795 else 795 else
796 skb = dev_alloc_skb(pkt_len + 2); 796 skb = dev_alloc_skb(pkt_len + 2);
@@ -842,7 +842,7 @@ memory_squeeze:
842 if (rbd != NULL && (rbd->count & 0x4000)) { 842 if (rbd != NULL && (rbd->count & 0x4000)) {
843 rbd->count = 0; 843 rbd->count = 0;
844 lp->rbd_head = rbd->v_next; 844 lp->rbd_head = rbd->v_next;
845 CHECK_WBACK_INV(rbd, sizeof(struct i596_rbd)); 845 CHECK_WBACK_INV(lp, rbd, sizeof(struct i596_rbd));
846 } 846 }
847 847
848 /* Tidy the frame descriptor, marking it as end of list */ 848 /* Tidy the frame descriptor, marking it as end of list */
@@ -860,10 +860,10 @@ memory_squeeze:
860 860
861 lp->scb.rfd = rfd->b_next; 861 lp->scb.rfd = rfd->b_next;
862 lp->rfd_head = rfd->v_next; 862 lp->rfd_head = rfd->v_next;
863 CHECK_WBACK_INV(rfd->v_prev, sizeof(struct i596_rfd)); 863 CHECK_WBACK_INV(lp, rfd->v_prev, sizeof(struct i596_rfd));
864 CHECK_WBACK_INV(rfd, sizeof(struct i596_rfd)); 864 CHECK_WBACK_INV(lp, rfd, sizeof(struct i596_rfd));
865 rfd = lp->rfd_head; 865 rfd = lp->rfd_head;
866 CHECK_INV(rfd, sizeof(struct i596_rfd)); 866 CHECK_INV(lp, rfd, sizeof(struct i596_rfd));
867 } 867 }
868 868
869 DEB(DEB_RXFRAME, printk("frames %d\n", frames)); 869 DEB(DEB_RXFRAME, printk("frames %d\n", frames));
@@ -902,12 +902,12 @@ static inline void i596_cleanup_cmd(struct net_device *dev, struct i596_private
902 ptr->v_next = NULL; 902 ptr->v_next = NULL;
903 ptr->b_next = I596_NULL; 903 ptr->b_next = I596_NULL;
904 } 904 }
905 CHECK_WBACK_INV(ptr, sizeof(struct i596_cmd)); 905 CHECK_WBACK_INV(lp, ptr, sizeof(struct i596_cmd));
906 } 906 }
907 907
908 wait_cmd(dev, lp, 100, "i596_cleanup_cmd timed out"); 908 wait_cmd(dev, lp, 100, "i596_cleanup_cmd timed out");
909 lp->scb.cmd = I596_NULL; 909 lp->scb.cmd = I596_NULL;
910 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 910 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
911} 911}
912 912
913 913
@@ -925,7 +925,7 @@ static inline void i596_reset(struct net_device *dev, struct i596_private *lp)
925 925
926 /* FIXME: this command might cause an lpmc */ 926 /* FIXME: this command might cause an lpmc */
927 lp->scb.command = CUC_ABORT | RX_ABORT; 927 lp->scb.command = CUC_ABORT | RX_ABORT;
928 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 928 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
929 CA(dev); 929 CA(dev);
930 930
931 /* wait for shutdown */ 931 /* wait for shutdown */
@@ -951,20 +951,20 @@ static void i596_add_cmd(struct net_device *dev, struct i596_cmd *cmd)
951 cmd->command |= (CMD_EOL | CMD_INTR); 951 cmd->command |= (CMD_EOL | CMD_INTR);
952 cmd->v_next = NULL; 952 cmd->v_next = NULL;
953 cmd->b_next = I596_NULL; 953 cmd->b_next = I596_NULL;
954 CHECK_WBACK(cmd, sizeof(struct i596_cmd)); 954 CHECK_WBACK(lp, cmd, sizeof(struct i596_cmd));
955 955
956 spin_lock_irqsave (&lp->lock, flags); 956 spin_lock_irqsave (&lp->lock, flags);
957 957
958 if (lp->cmd_head != NULL) { 958 if (lp->cmd_head != NULL) {
959 lp->cmd_tail->v_next = cmd; 959 lp->cmd_tail->v_next = cmd;
960 lp->cmd_tail->b_next = WSWAPcmd(virt_to_dma(lp,&cmd->status)); 960 lp->cmd_tail->b_next = WSWAPcmd(virt_to_dma(lp,&cmd->status));
961 CHECK_WBACK(lp->cmd_tail, sizeof(struct i596_cmd)); 961 CHECK_WBACK(lp, lp->cmd_tail, sizeof(struct i596_cmd));
962 } else { 962 } else {
963 lp->cmd_head = cmd; 963 lp->cmd_head = cmd;
964 wait_cmd(dev, lp, 100, "i596_add_cmd timed out"); 964 wait_cmd(dev, lp, 100, "i596_add_cmd timed out");
965 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&cmd->status)); 965 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&cmd->status));
966 lp->scb.command = CUC_START; 966 lp->scb.command = CUC_START;
967 CHECK_WBACK(&(lp->scb), sizeof(struct i596_scb)); 967 CHECK_WBACK(lp, &(lp->scb), sizeof(struct i596_scb));
968 CA(dev); 968 CA(dev);
969 } 969 }
970 lp->cmd_tail = cmd; 970 lp->cmd_tail = cmd;
@@ -998,12 +998,12 @@ static int i596_test(struct net_device *dev)
998 data = virt_to_dma(lp,tint); 998 data = virt_to_dma(lp,tint);
999 999
1000 tint[1] = -1; 1000 tint[1] = -1;
1001 CHECK_WBACK(tint,PAGE_SIZE); 1001 CHECK_WBACK(lp, tint, PAGE_SIZE);
1002 1002
1003 MPU_PORT(dev, 1, data); 1003 MPU_PORT(dev, 1, data);
1004 1004
1005 for(data = 1000000; data; data--) { 1005 for(data = 1000000; data; data--) {
1006 CHECK_INV(tint,PAGE_SIZE); 1006 CHECK_INV(lp, tint, PAGE_SIZE);
1007 if(tint[1] != -1) 1007 if(tint[1] != -1)
1008 break; 1008 break;
1009 1009
@@ -1061,7 +1061,7 @@ static void i596_tx_timeout (struct net_device *dev)
1061 /* Issue a channel attention signal */ 1061 /* Issue a channel attention signal */
1062 DEB(DEB_ERRORS, printk("Kicking board.\n")); 1062 DEB(DEB_ERRORS, printk("Kicking board.\n"));
1063 lp->scb.command = CUC_START | RX_START; 1063 lp->scb.command = CUC_START | RX_START;
1064 CHECK_WBACK_INV(&(lp->scb), sizeof(struct i596_scb)); 1064 CHECK_WBACK_INV(lp, &(lp->scb), sizeof(struct i596_scb));
1065 CA (dev); 1065 CA (dev);
1066 lp->last_restart = lp->stats.tx_packets; 1066 lp->last_restart = lp->stats.tx_packets;
1067 } 1067 }
@@ -1118,8 +1118,8 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev)
1118 tbd->data = WSWAPchar(tx_cmd->dma_addr); 1118 tbd->data = WSWAPchar(tx_cmd->dma_addr);
1119 1119
1120 DEB(DEB_TXADDR,print_eth(skb->data, "tx-queued")); 1120 DEB(DEB_TXADDR,print_eth(skb->data, "tx-queued"));
1121 CHECK_WBACK_INV(tx_cmd, sizeof(struct tx_cmd)); 1121 CHECK_WBACK_INV(lp, tx_cmd, sizeof(struct tx_cmd));
1122 CHECK_WBACK_INV(tbd, sizeof(struct i596_tbd)); 1122 CHECK_WBACK_INV(lp, tbd, sizeof(struct i596_tbd));
1123 i596_add_cmd(dev, &tx_cmd->cmd); 1123 i596_add_cmd(dev, &tx_cmd->cmd);
1124 1124
1125 lp->stats.tx_packets++; 1125 lp->stats.tx_packets++;
@@ -1228,7 +1228,7 @@ static int __devinit i82596_probe(struct net_device *dev,
1228 lp->dma_addr = dma_addr; 1228 lp->dma_addr = dma_addr;
1229 lp->dev = gen_dev; 1229 lp->dev = gen_dev;
1230 1230
1231 CHECK_WBACK_INV(dev->mem_start, sizeof(struct i596_private)); 1231 CHECK_WBACK_INV(lp, dev->mem_start, sizeof(struct i596_private));
1232 1232
1233 i = register_netdev(dev); 1233 i = register_netdev(dev);
1234 if (i) { 1234 if (i) {
@@ -1295,7 +1295,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1295 DEB(DEB_INTS, printk("%s: i596 interrupt command unit inactive %x.\n", dev->name, status & 0x0700)); 1295 DEB(DEB_INTS, printk("%s: i596 interrupt command unit inactive %x.\n", dev->name, status & 0x0700));
1296 1296
1297 while (lp->cmd_head != NULL) { 1297 while (lp->cmd_head != NULL) {
1298 CHECK_INV(lp->cmd_head, sizeof(struct i596_cmd)); 1298 CHECK_INV(lp, lp->cmd_head, sizeof(struct i596_cmd));
1299 if (!(lp->cmd_head->status & STAT_C)) 1299 if (!(lp->cmd_head->status & STAT_C))
1300 break; 1300 break;
1301 1301
@@ -1358,7 +1358,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1358 } 1358 }
1359 ptr->v_next = NULL; 1359 ptr->v_next = NULL;
1360 ptr->b_next = I596_NULL; 1360 ptr->b_next = I596_NULL;
1361 CHECK_WBACK(ptr, sizeof(struct i596_cmd)); 1361 CHECK_WBACK(lp, ptr, sizeof(struct i596_cmd));
1362 lp->last_cmd = jiffies; 1362 lp->last_cmd = jiffies;
1363 } 1363 }
1364 1364
@@ -1372,13 +1372,13 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1372 1372
1373 ptr->command &= 0x1fff; 1373 ptr->command &= 0x1fff;
1374 ptr = ptr->v_next; 1374 ptr = ptr->v_next;
1375 CHECK_WBACK_INV(prev, sizeof(struct i596_cmd)); 1375 CHECK_WBACK_INV(lp, prev, sizeof(struct i596_cmd));
1376 } 1376 }
1377 1377
1378 if ((lp->cmd_head != NULL)) 1378 if ((lp->cmd_head != NULL))
1379 ack_cmd |= CUC_START; 1379 ack_cmd |= CUC_START;
1380 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&lp->cmd_head->status)); 1380 lp->scb.cmd = WSWAPcmd(virt_to_dma(lp,&lp->cmd_head->status));
1381 CHECK_WBACK_INV(&lp->scb, sizeof(struct i596_scb)); 1381 CHECK_WBACK_INV(lp, &lp->scb, sizeof(struct i596_scb));
1382 } 1382 }
1383 if ((status & 0x1000) || (status & 0x4000)) { 1383 if ((status & 0x1000) || (status & 0x4000)) {
1384 if ((status & 0x4000)) 1384 if ((status & 0x4000))
@@ -1397,7 +1397,7 @@ static irqreturn_t i596_interrupt(int irq, void *dev_id)
1397 } 1397 }
1398 wait_cmd(dev, lp, 100, "i596 interrupt, timeout"); 1398 wait_cmd(dev, lp, 100, "i596 interrupt, timeout");
1399 lp->scb.command = ack_cmd; 1399 lp->scb.command = ack_cmd;
1400 CHECK_WBACK(&lp->scb, sizeof(struct i596_scb)); 1400 CHECK_WBACK(lp, &lp->scb, sizeof(struct i596_scb));
1401 1401
1402 /* DANGER: I suspect that some kind of interrupt 1402 /* DANGER: I suspect that some kind of interrupt
1403 acknowledgement aside from acking the 82596 might be needed 1403 acknowledgement aside from acking the 82596 might be needed
@@ -1426,7 +1426,7 @@ static int i596_close(struct net_device *dev)
1426 1426
1427 wait_cmd(dev, lp, 100, "close1 timed out"); 1427 wait_cmd(dev, lp, 100, "close1 timed out");
1428 lp->scb.command = CUC_ABORT | RX_ABORT; 1428 lp->scb.command = CUC_ABORT | RX_ABORT;
1429 CHECK_WBACK(&lp->scb, sizeof(struct i596_scb)); 1429 CHECK_WBACK(lp, &lp->scb, sizeof(struct i596_scb));
1430 1430
1431 CA(dev); 1431 CA(dev);
1432 1432
@@ -1486,7 +1486,7 @@ static void set_multicast_list(struct net_device *dev)
1486 dev->name); 1486 dev->name);
1487 else { 1487 else {
1488 lp->cf_cmd.cmd.command = CmdConfigure; 1488 lp->cf_cmd.cmd.command = CmdConfigure;
1489 CHECK_WBACK_INV(&lp->cf_cmd, sizeof(struct cf_cmd)); 1489 CHECK_WBACK_INV(lp, &lp->cf_cmd, sizeof(struct cf_cmd));
1490 i596_add_cmd(dev, &lp->cf_cmd.cmd); 1490 i596_add_cmd(dev, &lp->cf_cmd.cmd);
1491 } 1491 }
1492 } 1492 }
@@ -1514,7 +1514,7 @@ static void set_multicast_list(struct net_device *dev)
1514 DEB(DEB_MULTI, printk("%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n", 1514 DEB(DEB_MULTI, printk("%s: Adding address %02x:%02x:%02x:%02x:%02x:%02x\n",
1515 dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5])); 1515 dev->name, cp[0],cp[1],cp[2],cp[3],cp[4],cp[5]));
1516 } 1516 }
1517 CHECK_WBACK_INV(&lp->mc_cmd, sizeof(struct mc_cmd)); 1517 CHECK_WBACK_INV(lp, &lp->mc_cmd, sizeof(struct mc_cmd));
1518 i596_add_cmd(dev, &cmd->cmd); 1518 i596_add_cmd(dev, &cmd->cmd);
1519 } 1519 }
1520} 1520}
diff --git a/drivers/net/lne390.c b/drivers/net/lne390.c
index 5795ee116205..0a08d0c4e7b4 100644
--- a/drivers/net/lne390.c
+++ b/drivers/net/lne390.c
@@ -440,7 +440,7 @@ static void cleanup_card(struct net_device *dev)
440 iounmap(ei_status.mem); 440 iounmap(ei_status.mem);
441} 441}
442 442
443void cleanup_module(void) 443void __exit cleanup_module(void)
444{ 444{
445 int this_dev; 445 int this_dev;
446 446
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index d9f48bb04b05..c41ae4286eea 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1100,7 +1100,7 @@ static void eth_tx_fill_frag_descs(struct mv643xx_private *mp,
1100 ETH_TX_ENABLE_INTERRUPT; 1100 ETH_TX_ENABLE_INTERRUPT;
1101 mp->tx_skb[tx_index] = skb; 1101 mp->tx_skb[tx_index] = skb;
1102 } else 1102 } else
1103 mp->tx_skb[tx_index] = 0; 1103 mp->tx_skb[tx_index] = NULL;
1104 1104
1105 desc = &mp->p_tx_desc_area[tx_index]; 1105 desc = &mp->p_tx_desc_area[tx_index];
1106 desc->l4i_chk = 0; 1106 desc->l4i_chk = 0;
@@ -1136,7 +1136,7 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp,
1136 eth_tx_fill_frag_descs(mp, skb); 1136 eth_tx_fill_frag_descs(mp, skb);
1137 1137
1138 length = skb_headlen(skb); 1138 length = skb_headlen(skb);
1139 mp->tx_skb[tx_index] = 0; 1139 mp->tx_skb[tx_index] = NULL;
1140 } else { 1140 } else {
1141 cmd_sts |= ETH_ZERO_PADDING | 1141 cmd_sts |= ETH_ZERO_PADDING |
1142 ETH_TX_LAST_DESC | 1142 ETH_TX_LAST_DESC |
diff --git a/drivers/net/mvme147.c b/drivers/net/mvme147.c
index 56a82d8ee8f5..e246d00bba6d 100644
--- a/drivers/net/mvme147.c
+++ b/drivers/net/mvme147.c
@@ -184,7 +184,7 @@ static int m147lance_close(struct net_device *dev)
184MODULE_LICENSE("GPL"); 184MODULE_LICENSE("GPL");
185 185
186static struct net_device *dev_mvme147_lance; 186static struct net_device *dev_mvme147_lance;
187int init_module(void) 187int __init init_module(void)
188{ 188{
189 dev_mvme147_lance = mvme147lance_probe(-1); 189 dev_mvme147_lance = mvme147lance_probe(-1);
190 if (IS_ERR(dev_mvme147_lance)) 190 if (IS_ERR(dev_mvme147_lance))
@@ -192,7 +192,7 @@ int init_module(void)
192 return 0; 192 return 0;
193} 193}
194 194
195void cleanup_module(void) 195void __exit cleanup_module(void)
196{ 196{
197 struct m147lance_private *lp = dev_mvme147_lance->priv; 197 struct m147lance_private *lp = dev_mvme147_lance->priv;
198 unregister_netdev(dev_mvme147_lance); 198 unregister_netdev(dev_mvme147_lance);
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index 38df42802386..81f127a78afa 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -89,7 +89,7 @@ MODULE_LICENSE("Dual BSD/GPL");
89#define MYRI10GE_EEPROM_STRINGS_SIZE 256 89#define MYRI10GE_EEPROM_STRINGS_SIZE 256
90#define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2) 90#define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2)
91 91
92#define MYRI10GE_NO_CONFIRM_DATA 0xffffffff 92#define MYRI10GE_NO_CONFIRM_DATA htonl(0xffffffff)
93#define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff 93#define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff
94 94
95struct myri10ge_rx_buffer_state { 95struct myri10ge_rx_buffer_state {
@@ -156,8 +156,8 @@ struct myri10ge_priv {
156 int sram_size; 156 int sram_size;
157 unsigned long board_span; 157 unsigned long board_span;
158 unsigned long iomem_base; 158 unsigned long iomem_base;
159 u32 __iomem *irq_claim; 159 __be32 __iomem *irq_claim;
160 u32 __iomem *irq_deassert; 160 __be32 __iomem *irq_deassert;
161 char *mac_addr_string; 161 char *mac_addr_string;
162 struct mcp_cmd_response *cmd; 162 struct mcp_cmd_response *cmd;
163 dma_addr_t cmd_bus; 163 dma_addr_t cmd_bus;
@@ -165,10 +165,10 @@ struct myri10ge_priv {
165 dma_addr_t fw_stats_bus; 165 dma_addr_t fw_stats_bus;
166 struct pci_dev *pdev; 166 struct pci_dev *pdev;
167 int msi_enabled; 167 int msi_enabled;
168 unsigned int link_state; 168 __be32 link_state;
169 unsigned int rdma_tags_available; 169 unsigned int rdma_tags_available;
170 int intr_coal_delay; 170 int intr_coal_delay;
171 u32 __iomem *intr_coal_delay_ptr; 171 __be32 __iomem *intr_coal_delay_ptr;
172 int mtrr; 172 int mtrr;
173 int wake_queue; 173 int wake_queue;
174 int stop_queue; 174 int stop_queue;
@@ -273,6 +273,11 @@ MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
273 273
274#define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8) 274#define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8)
275 275
276static inline void put_be32(__be32 val, __be32 __iomem *p)
277{
278 __raw_writel((__force __u32)val, (__force void __iomem *)p);
279}
280
276static int 281static int
277myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, 282myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
278 struct myri10ge_cmd *data, int atomic) 283 struct myri10ge_cmd *data, int atomic)
@@ -296,7 +301,7 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
296 301
297 buf->response_addr.low = htonl(dma_low); 302 buf->response_addr.low = htonl(dma_low);
298 buf->response_addr.high = htonl(dma_high); 303 buf->response_addr.high = htonl(dma_high);
299 response->result = MYRI10GE_NO_RESPONSE_RESULT; 304 response->result = htonl(MYRI10GE_NO_RESPONSE_RESULT);
300 mb(); 305 mb();
301 myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf)); 306 myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf));
302 307
@@ -311,14 +316,14 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
311 * (1ms will be enough for those commands) */ 316 * (1ms will be enough for those commands) */
312 for (sleep_total = 0; 317 for (sleep_total = 0;
313 sleep_total < 1000 318 sleep_total < 1000
314 && response->result == MYRI10GE_NO_RESPONSE_RESULT; 319 && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
315 sleep_total += 10) 320 sleep_total += 10)
316 udelay(10); 321 udelay(10);
317 } else { 322 } else {
318 /* use msleep for most command */ 323 /* use msleep for most command */
319 for (sleep_total = 0; 324 for (sleep_total = 0;
320 sleep_total < 15 325 sleep_total < 15
321 && response->result == MYRI10GE_NO_RESPONSE_RESULT; 326 && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
322 sleep_total++) 327 sleep_total++)
323 msleep(1); 328 msleep(1);
324 } 329 }
@@ -393,7 +398,7 @@ abort:
393static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) 398static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
394{ 399{
395 char __iomem *submit; 400 char __iomem *submit;
396 u32 buf[16]; 401 __be32 buf[16];
397 u32 dma_low, dma_high; 402 u32 dma_low, dma_high;
398 int i; 403 int i;
399 404
@@ -410,7 +415,7 @@ static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
410 415
411 buf[0] = htonl(dma_high); /* confirm addr MSW */ 416 buf[0] = htonl(dma_high); /* confirm addr MSW */
412 buf[1] = htonl(dma_low); /* confirm addr LSW */ 417 buf[1] = htonl(dma_low); /* confirm addr LSW */
413 buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA); /* confirm data */ 418 buf[2] = MYRI10GE_NO_CONFIRM_DATA; /* confirm data */
414 buf[3] = htonl(dma_high); /* dummy addr MSW */ 419 buf[3] = htonl(dma_high); /* dummy addr MSW */
415 buf[4] = htonl(dma_low); /* dummy addr LSW */ 420 buf[4] = htonl(dma_low); /* dummy addr LSW */
416 buf[5] = htonl(enable); /* enable? */ 421 buf[5] = htonl(enable); /* enable? */
@@ -479,7 +484,7 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size)
479 } 484 }
480 485
481 /* check id */ 486 /* check id */
482 hdr_offset = ntohl(*(u32 *) (fw->data + MCP_HEADER_PTR_OFFSET)); 487 hdr_offset = ntohl(*(__be32 *) (fw->data + MCP_HEADER_PTR_OFFSET));
483 if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) { 488 if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) {
484 dev_err(dev, "Bad firmware file\n"); 489 dev_err(dev, "Bad firmware file\n");
485 status = -EINVAL; 490 status = -EINVAL;
@@ -550,7 +555,7 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
550static int myri10ge_load_firmware(struct myri10ge_priv *mgp) 555static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
551{ 556{
552 char __iomem *submit; 557 char __iomem *submit;
553 u32 buf[16]; 558 __be32 buf[16];
554 u32 dma_low, dma_high, size; 559 u32 dma_low, dma_high, size;
555 int status, i; 560 int status, i;
556 561
@@ -600,7 +605,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
600 605
601 buf[0] = htonl(dma_high); /* confirm addr MSW */ 606 buf[0] = htonl(dma_high); /* confirm addr MSW */
602 buf[1] = htonl(dma_low); /* confirm addr LSW */ 607 buf[1] = htonl(dma_low); /* confirm addr LSW */
603 buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA); /* confirm data */ 608 buf[2] = MYRI10GE_NO_CONFIRM_DATA; /* confirm data */
604 609
605 /* FIX: All newest firmware should un-protect the bottom of 610 /* FIX: All newest firmware should un-protect the bottom of
606 * the sram before handoff. However, the very first interfaces 611 * the sram before handoff. However, the very first interfaces
@@ -705,21 +710,21 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
705 710
706 status |= 711 status |=
707 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); 712 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0);
708 mgp->irq_claim = (__iomem u32 *) (mgp->sram + cmd.data0); 713 mgp->irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0);
709 if (!mgp->msi_enabled) { 714 if (!mgp->msi_enabled) {
710 status |= myri10ge_send_cmd 715 status |= myri10ge_send_cmd
711 (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0); 716 (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0);
712 mgp->irq_deassert = (__iomem u32 *) (mgp->sram + cmd.data0); 717 mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0);
713 718
714 } 719 }
715 status |= myri10ge_send_cmd 720 status |= myri10ge_send_cmd
716 (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0); 721 (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0);
717 mgp->intr_coal_delay_ptr = (__iomem u32 *) (mgp->sram + cmd.data0); 722 mgp->intr_coal_delay_ptr = (__iomem __be32 *) (mgp->sram + cmd.data0);
718 if (status != 0) { 723 if (status != 0) {
719 dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n"); 724 dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n");
720 return status; 725 return status;
721 } 726 }
722 __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); 727 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
723 728
724 /* Run a small DMA test. 729 /* Run a small DMA test.
725 * The magic multipliers to the length tell the firmware 730 * The magic multipliers to the length tell the firmware
@@ -786,14 +791,16 @@ static inline void
786myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst, 791myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst,
787 struct mcp_kreq_ether_recv *src) 792 struct mcp_kreq_ether_recv *src)
788{ 793{
789 u32 low; 794 __be32 low;
790 795
791 low = src->addr_low; 796 low = src->addr_low;
792 src->addr_low = DMA_32BIT_MASK; 797 src->addr_low = htonl(DMA_32BIT_MASK);
793 myri10ge_pio_copy(dst, src, 8 * sizeof(*src)); 798 myri10ge_pio_copy(dst, src, 4 * sizeof(*src));
799 mb();
800 myri10ge_pio_copy(dst + 4, src + 4, 4 * sizeof(*src));
794 mb(); 801 mb();
795 src->addr_low = low; 802 src->addr_low = low;
796 __raw_writel(low, &dst->addr_low); 803 put_be32(low, &dst->addr_low);
797 mb(); 804 mb();
798} 805}
799 806
@@ -939,11 +946,11 @@ done:
939 return retval; 946 return retval;
940} 947}
941 948
942static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum) 949static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, __wsum hw_csum)
943{ 950{
944 struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data); 951 struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data);
945 952
946 if ((skb->protocol == ntohs(ETH_P_8021Q)) && 953 if ((skb->protocol == htons(ETH_P_8021Q)) &&
947 (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) || 954 (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) ||
948 vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) { 955 vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) {
949 skb->csum = hw_csum; 956 skb->csum = hw_csum;
@@ -953,7 +960,7 @@ static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum)
953 960
954static inline unsigned long 961static inline unsigned long
955myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, 962myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
956 int bytes, int len, int csum) 963 int bytes, int len, __wsum csum)
957{ 964{
958 dma_addr_t bus; 965 dma_addr_t bus;
959 struct sk_buff *skb; 966 struct sk_buff *skb;
@@ -986,12 +993,12 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
986 993
987 skb->protocol = eth_type_trans(skb, mgp->dev); 994 skb->protocol = eth_type_trans(skb, mgp->dev);
988 if (mgp->csum_flag) { 995 if (mgp->csum_flag) {
989 if ((skb->protocol == ntohs(ETH_P_IP)) || 996 if ((skb->protocol == htons(ETH_P_IP)) ||
990 (skb->protocol == ntohs(ETH_P_IPV6))) { 997 (skb->protocol == htons(ETH_P_IPV6))) {
991 skb->csum = ntohs((u16) csum); 998 skb->csum = csum;
992 skb->ip_summed = CHECKSUM_COMPLETE; 999 skb->ip_summed = CHECKSUM_COMPLETE;
993 } else 1000 } else
994 myri10ge_vlan_ip_csum(skb, ntohs((u16) csum)); 1001 myri10ge_vlan_ip_csum(skb, csum);
995 } 1002 }
996 1003
997 netif_receive_skb(skb); 1004 netif_receive_skb(skb);
@@ -1060,12 +1067,12 @@ static inline void myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int *limit)
1060 int idx = rx_done->idx; 1067 int idx = rx_done->idx;
1061 int cnt = rx_done->cnt; 1068 int cnt = rx_done->cnt;
1062 u16 length; 1069 u16 length;
1063 u16 checksum; 1070 __wsum checksum;
1064 1071
1065 while (rx_done->entry[idx].length != 0 && *limit != 0) { 1072 while (rx_done->entry[idx].length != 0 && *limit != 0) {
1066 length = ntohs(rx_done->entry[idx].length); 1073 length = ntohs(rx_done->entry[idx].length);
1067 rx_done->entry[idx].length = 0; 1074 rx_done->entry[idx].length = 0;
1068 checksum = ntohs(rx_done->entry[idx].checksum); 1075 checksum = csum_unfold(rx_done->entry[idx].checksum);
1069 if (length <= mgp->small_bytes) 1076 if (length <= mgp->small_bytes)
1070 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small, 1077 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small,
1071 mgp->small_bytes, 1078 mgp->small_bytes,
@@ -1142,7 +1149,7 @@ static int myri10ge_poll(struct net_device *netdev, int *budget)
1142 1149
1143 if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) { 1150 if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) {
1144 netif_rx_complete(netdev); 1151 netif_rx_complete(netdev);
1145 __raw_writel(htonl(3), mgp->irq_claim); 1152 put_be32(htonl(3), mgp->irq_claim);
1146 return 0; 1153 return 0;
1147 } 1154 }
1148 return 1; 1155 return 1;
@@ -1166,7 +1173,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1166 netif_rx_schedule(mgp->dev); 1173 netif_rx_schedule(mgp->dev);
1167 1174
1168 if (!mgp->msi_enabled) { 1175 if (!mgp->msi_enabled) {
1169 __raw_writel(0, mgp->irq_deassert); 1176 put_be32(0, mgp->irq_deassert);
1170 if (!myri10ge_deassert_wait) 1177 if (!myri10ge_deassert_wait)
1171 stats->valid = 0; 1178 stats->valid = 0;
1172 mb(); 1179 mb();
@@ -1195,7 +1202,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1195 1202
1196 myri10ge_check_statblock(mgp); 1203 myri10ge_check_statblock(mgp);
1197 1204
1198 __raw_writel(htonl(3), mgp->irq_claim + 1); 1205 put_be32(htonl(3), mgp->irq_claim + 1);
1199 return (IRQ_HANDLED); 1206 return (IRQ_HANDLED);
1200} 1207}
1201 1208
@@ -1233,7 +1240,7 @@ myri10ge_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
1233 struct myri10ge_priv *mgp = netdev_priv(netdev); 1240 struct myri10ge_priv *mgp = netdev_priv(netdev);
1234 1241
1235 mgp->intr_coal_delay = coal->rx_coalesce_usecs; 1242 mgp->intr_coal_delay = coal->rx_coalesce_usecs;
1236 __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); 1243 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
1237 return 0; 1244 return 0;
1238} 1245}
1239 1246
@@ -1748,7 +1755,7 @@ static int myri10ge_open(struct net_device *dev)
1748 goto abort_with_rings; 1755 goto abort_with_rings;
1749 } 1756 }
1750 1757
1751 mgp->link_state = -1; 1758 mgp->link_state = htonl(~0U);
1752 mgp->rdma_tags_available = 15; 1759 mgp->rdma_tags_available = 15;
1753 1760
1754 netif_poll_enable(mgp->dev); /* must happen prior to any irq */ 1761 netif_poll_enable(mgp->dev); /* must happen prior to any irq */
@@ -1876,7 +1883,7 @@ myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src,
1876 1883
1877 /* re-write the last 32-bits with the valid flags */ 1884 /* re-write the last 32-bits with the valid flags */
1878 src->flags = last_flags; 1885 src->flags = last_flags;
1879 __raw_writel(*((u32 *) src + 3), (u32 __iomem *) dst + 3); 1886 put_be32(*((__be32 *) src + 3), (__be32 __iomem *) dst + 3);
1880 tx->req += cnt; 1887 tx->req += cnt;
1881 mb(); 1888 mb();
1882} 1889}
@@ -1919,7 +1926,8 @@ static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
1919 struct myri10ge_tx_buf *tx = &mgp->tx; 1926 struct myri10ge_tx_buf *tx = &mgp->tx;
1920 struct skb_frag_struct *frag; 1927 struct skb_frag_struct *frag;
1921 dma_addr_t bus; 1928 dma_addr_t bus;
1922 u32 low, high_swapped; 1929 u32 low;
1930 __be32 high_swapped;
1923 unsigned int len; 1931 unsigned int len;
1924 int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments; 1932 int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments;
1925 u16 pseudo_hdr_offset, cksum_offset; 1933 u16 pseudo_hdr_offset, cksum_offset;
@@ -1964,7 +1972,6 @@ again:
1964 cksum_offset = 0; 1972 cksum_offset = 0;
1965 pseudo_hdr_offset = 0; 1973 pseudo_hdr_offset = 0;
1966 } else { 1974 } else {
1967 pseudo_hdr_offset = htons(pseudo_hdr_offset);
1968 odd_flag = MXGEFW_FLAGS_ALIGN_ODD; 1975 odd_flag = MXGEFW_FLAGS_ALIGN_ODD;
1969 flags |= MXGEFW_FLAGS_CKSUM; 1976 flags |= MXGEFW_FLAGS_CKSUM;
1970 } 1977 }
@@ -1986,7 +1993,7 @@ again:
1986 /* for TSO, pseudo_hdr_offset holds mss. 1993 /* for TSO, pseudo_hdr_offset holds mss.
1987 * The firmware figures out where to put 1994 * The firmware figures out where to put
1988 * the checksum by parsing the header. */ 1995 * the checksum by parsing the header. */
1989 pseudo_hdr_offset = htons(mss); 1996 pseudo_hdr_offset = mss;
1990 } else 1997 } else
1991#endif /*NETIF_F_TSO */ 1998#endif /*NETIF_F_TSO */
1992 /* Mark small packets, and pad out tiny packets */ 1999 /* Mark small packets, and pad out tiny packets */
@@ -2086,7 +2093,7 @@ again:
2086#endif /* NETIF_F_TSO */ 2093#endif /* NETIF_F_TSO */
2087 req->addr_high = high_swapped; 2094 req->addr_high = high_swapped;
2088 req->addr_low = htonl(low); 2095 req->addr_low = htonl(low);
2089 req->pseudo_hdr_offset = pseudo_hdr_offset; 2096 req->pseudo_hdr_offset = htons(pseudo_hdr_offset);
2090 req->pad = 0; /* complete solid 16-byte block; does this matter? */ 2097 req->pad = 0; /* complete solid 16-byte block; does this matter? */
2091 req->rdma_count = 1; 2098 req->rdma_count = 1;
2092 req->length = htons(seglen); 2099 req->length = htons(seglen);
@@ -2199,6 +2206,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
2199 struct myri10ge_cmd cmd; 2206 struct myri10ge_cmd cmd;
2200 struct myri10ge_priv *mgp; 2207 struct myri10ge_priv *mgp;
2201 struct dev_mc_list *mc_list; 2208 struct dev_mc_list *mc_list;
2209 __be32 data[2] = {0, 0};
2202 int err; 2210 int err;
2203 2211
2204 mgp = netdev_priv(dev); 2212 mgp = netdev_priv(dev);
@@ -2237,10 +2245,9 @@ static void myri10ge_set_multicast_list(struct net_device *dev)
2237 2245
2238 /* Walk the multicast list, and add each address */ 2246 /* Walk the multicast list, and add each address */
2239 for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) { 2247 for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) {
2240 memcpy(&cmd.data0, &mc_list->dmi_addr, 4); 2248 memcpy(data, &mc_list->dmi_addr, 6);
2241 memcpy(&cmd.data1, ((char *)&mc_list->dmi_addr) + 4, 2); 2249 cmd.data0 = ntohl(data[0]);
2242 cmd.data0 = htonl(cmd.data0); 2250 cmd.data1 = ntohl(data[1]);
2243 cmd.data1 = htonl(cmd.data1);
2244 err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP, 2251 err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP,
2245 &cmd, 1); 2252 &cmd, 1);
2246 2253
diff --git a/drivers/net/myri10ge/myri10ge_mcp.h b/drivers/net/myri10ge/myri10ge_mcp.h
index 9519ae7cd5ec..29463b301a84 100644
--- a/drivers/net/myri10ge/myri10ge_mcp.h
+++ b/drivers/net/myri10ge/myri10ge_mcp.h
@@ -6,23 +6,23 @@
6 6
7/* 8 Bytes */ 7/* 8 Bytes */
8struct mcp_dma_addr { 8struct mcp_dma_addr {
9 u32 high; 9 __be32 high;
10 u32 low; 10 __be32 low;
11}; 11};
12 12
13/* 4 Bytes */ 13/* 4 Bytes */
14struct mcp_slot { 14struct mcp_slot {
15 u16 checksum; 15 __sum16 checksum;
16 u16 length; 16 __be16 length;
17}; 17};
18 18
19/* 64 Bytes */ 19/* 64 Bytes */
20struct mcp_cmd { 20struct mcp_cmd {
21 u32 cmd; 21 __be32 cmd;
22 u32 data0; /* will be low portion if data > 32 bits */ 22 __be32 data0; /* will be low portion if data > 32 bits */
23 /* 8 */ 23 /* 8 */
24 u32 data1; /* will be high portion if data > 32 bits */ 24 __be32 data1; /* will be high portion if data > 32 bits */
25 u32 data2; /* currently unused.. */ 25 __be32 data2; /* currently unused.. */
26 /* 16 */ 26 /* 16 */
27 struct mcp_dma_addr response_addr; 27 struct mcp_dma_addr response_addr;
28 /* 24 */ 28 /* 24 */
@@ -31,8 +31,8 @@ struct mcp_cmd {
31 31
32/* 8 Bytes */ 32/* 8 Bytes */
33struct mcp_cmd_response { 33struct mcp_cmd_response {
34 u32 data; 34 __be32 data;
35 u32 result; 35 __be32 result;
36}; 36};
37 37
38/* 38/*
@@ -73,10 +73,10 @@ union mcp_pso_or_cumlen {
73 73
74/* 16 Bytes */ 74/* 16 Bytes */
75struct mcp_kreq_ether_send { 75struct mcp_kreq_ether_send {
76 u32 addr_high; 76 __be32 addr_high;
77 u32 addr_low; 77 __be32 addr_low;
78 u16 pseudo_hdr_offset; 78 __be16 pseudo_hdr_offset;
79 u16 length; 79 __be16 length;
80 u8 pad; 80 u8 pad;
81 u8 rdma_count; 81 u8 rdma_count;
82 u8 cksum_offset; /* where to start computing cksum */ 82 u8 cksum_offset; /* where to start computing cksum */
@@ -85,8 +85,8 @@ struct mcp_kreq_ether_send {
85 85
86/* 8 Bytes */ 86/* 8 Bytes */
87struct mcp_kreq_ether_recv { 87struct mcp_kreq_ether_recv {
88 u32 addr_high; 88 __be32 addr_high;
89 u32 addr_low; 89 __be32 addr_low;
90}; 90};
91 91
92/* Commands */ 92/* Commands */
@@ -219,19 +219,19 @@ enum myri10ge_mcp_cmd_status {
219 219
220struct mcp_irq_data { 220struct mcp_irq_data {
221 /* add new counters at the beginning */ 221 /* add new counters at the beginning */
222 u32 future_use[5]; 222 __be32 future_use[5];
223 u32 dropped_multicast_filtered; 223 __be32 dropped_multicast_filtered;
224 /* 40 Bytes */ 224 /* 40 Bytes */
225 u32 send_done_count; 225 __be32 send_done_count;
226 226
227 u32 link_up; 227 __be32 link_up;
228 u32 dropped_link_overflow; 228 __be32 dropped_link_overflow;
229 u32 dropped_link_error_or_filtered; 229 __be32 dropped_link_error_or_filtered;
230 u32 dropped_runt; 230 __be32 dropped_runt;
231 u32 dropped_overrun; 231 __be32 dropped_overrun;
232 u32 dropped_no_small_buffer; 232 __be32 dropped_no_small_buffer;
233 u32 dropped_no_big_buffer; 233 __be32 dropped_no_big_buffer;
234 u32 rdma_tags_available; 234 __be32 rdma_tags_available;
235 235
236 u8 tx_stopped; 236 u8 tx_stopped;
237 u8 link_down; 237 u8 link_down;
diff --git a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
index 487f7792fd46..16a810dd6d51 100644
--- a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
+++ b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
@@ -36,7 +36,7 @@
36struct mcp_gen_header { 36struct mcp_gen_header {
37 /* the first 4 fields are filled at compile time */ 37 /* the first 4 fields are filled at compile time */
38 unsigned header_length; 38 unsigned header_length;
39 unsigned mcp_type; 39 __be32 mcp_type;
40 char version[128]; 40 char version[128];
41 unsigned mcp_globals; /* pointer to mcp-type specific structure */ 41 unsigned mcp_globals; /* pointer to mcp-type specific structure */
42 42
diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index 787aa4221528..a5c4199e2754 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -867,7 +867,7 @@ static void cleanup_card(struct net_device *dev)
867 release_region(dev->base_addr, NE_IO_EXTENT); 867 release_region(dev->base_addr, NE_IO_EXTENT);
868} 868}
869 869
870void cleanup_module(void) 870void __exit cleanup_module(void)
871{ 871{
872 int this_dev; 872 int this_dev;
873 873
diff --git a/drivers/net/ne2.c b/drivers/net/ne2.c
index 5fccfea66d87..089b5bb702fc 100644
--- a/drivers/net/ne2.c
+++ b/drivers/net/ne2.c
@@ -813,7 +813,7 @@ static void cleanup_card(struct net_device *dev)
813 release_region(dev->base_addr, NE_IO_EXTENT); 813 release_region(dev->base_addr, NE_IO_EXTENT);
814} 814}
815 815
816void cleanup_module(void) 816void __exit cleanup_module(void)
817{ 817{
818 int this_dev; 818 int this_dev;
819 819
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 9c588af8ab74..b5410bee5f21 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -1,25 +1,25 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
@@ -63,40 +63,68 @@
63 63
64#include "netxen_nic_hw.h" 64#include "netxen_nic_hw.h"
65 65
66#define NETXEN_NIC_BUILD_NO "5" 66#define NETXEN_NIC_BUILD_NO "1"
67#define _NETXEN_NIC_LINUX_MAJOR 2 67#define _NETXEN_NIC_LINUX_MAJOR 3
68#define _NETXEN_NIC_LINUX_MINOR 3 68#define _NETXEN_NIC_LINUX_MINOR 3
69#define _NETXEN_NIC_LINUX_SUBVERSION 59 69#define _NETXEN_NIC_LINUX_SUBVERSION 2
70#define NETXEN_NIC_LINUX_VERSIONID "2.3.59" "-" NETXEN_NIC_BUILD_NO 70#define NETXEN_NIC_LINUX_VERSIONID "3.3.2" "-" NETXEN_NIC_BUILD_NO
71#define NETXEN_NIC_FW_VERSIONID "2.3.59" 71#define NETXEN_NIC_FW_VERSIONID "3.3.2"
72 72
73#define RCV_DESC_RINGSIZE \ 73#define RCV_DESC_RINGSIZE \
74 (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) 74 (sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
75#define STATUS_DESC_RINGSIZE \ 75#define STATUS_DESC_RINGSIZE \
76 (sizeof(struct status_desc)* adapter->max_rx_desc_count) 76 (sizeof(struct status_desc)* adapter->max_rx_desc_count)
77#define LRO_DESC_RINGSIZE \
78 (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count)
77#define TX_RINGSIZE \ 79#define TX_RINGSIZE \
78 (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) 80 (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count)
79#define RCV_BUFFSIZE \ 81#define RCV_BUFFSIZE \
80 (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count) 82 (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count)
81#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) 83#define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a)))
82 84
83#define NETXEN_NETDEV_STATUS 0x1 85#define NETXEN_NETDEV_STATUS 0x1
86#define NETXEN_RCV_PRODUCER_OFFSET 0
87#define NETXEN_RCV_PEG_DB_ID 2
88#define NETXEN_HOST_DUMMY_DMA_SIZE 1024
84 89
85#define ADDR_IN_WINDOW1(off) \ 90#define ADDR_IN_WINDOW1(off) \
86 ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 91 ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0
92/*
93 * In netxen_nic_down(), we must wait for any pending callback requests into
94 * netxen_watchdog_task() to complete; eg otherwise the watchdog_timer could be
95 * reenabled right after it is deleted in netxen_nic_down(). FLUSH_SCHEDULED_WORK()
96 * does this synchronization.
97 *
98 * Normally, schedule_work()/flush_scheduled_work() could have worked, but
99 * netxen_nic_close() is invoked with kernel rtnl lock held. netif_carrier_off()
100 * call in netxen_nic_close() triggers a schedule_work(&linkwatch_work), and a
101 * subsequent call to flush_scheduled_work() in netxen_nic_down() would cause
102 * linkwatch_event() to be executed which also attempts to acquire the rtnl
103 * lock thus causing a deadlock.
104 */
105
106#define SCHEDULE_WORK(tp) queue_work(netxen_workq, tp)
107#define FLUSH_SCHEDULED_WORK() flush_workqueue(netxen_workq)
108extern struct workqueue_struct *netxen_workq;
87 109
88/* 110/*
89 * normalize a 64MB crb address to 32MB PCI window 111 * normalize a 64MB crb address to 32MB PCI window
90 * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 112 * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
91 */ 113 */
92#define NETXEN_CRB_NORMAL(reg) \ 114#define NETXEN_CRB_NORMAL(reg) \
93 (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST 115 ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST)
94 116
95#define NETXEN_CRB_NORMALIZE(adapter, reg) \ 117#define NETXEN_CRB_NORMALIZE(adapter, reg) \
96 pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg)) 118 pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
97 119
120#define DB_NORMALIZE(adapter, off) \
121 (adapter->ahw.db_base + (off))
122
123#define NX_P2_C0 0x24
124#define NX_P2_C1 0x25
125
98#define FIRST_PAGE_GROUP_START 0 126#define FIRST_PAGE_GROUP_START 0
99#define FIRST_PAGE_GROUP_END 0x400000 127#define FIRST_PAGE_GROUP_END 0x100000
100 128
101#define SECOND_PAGE_GROUP_START 0x4000000 129#define SECOND_PAGE_GROUP_START 0x4000000
102#define SECOND_PAGE_GROUP_END 0x66BC000 130#define SECOND_PAGE_GROUP_END 0x66BC000
@@ -108,11 +136,13 @@
108#define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START 136#define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START
109#define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START 137#define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START
110 138
111#define MAX_RX_BUFFER_LENGTH 2000 139#define MAX_RX_BUFFER_LENGTH 1760
112#define MAX_RX_JUMBO_BUFFER_LENGTH 9046 140#define MAX_RX_JUMBO_BUFFER_LENGTH 9046
113#define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - NET_IP_ALIGN) 141#define MAX_RX_LRO_BUFFER_LENGTH ((48*1024)-512)
142#define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - 2)
114#define RX_JUMBO_DMA_MAP_LEN \ 143#define RX_JUMBO_DMA_MAP_LEN \
115 (MAX_RX_JUMBO_BUFFER_LENGTH - NET_IP_ALIGN) 144 (MAX_RX_JUMBO_BUFFER_LENGTH - 2)
145#define RX_LRO_DMA_MAP_LEN (MAX_RX_LRO_BUFFER_LENGTH - 2)
116#define NETXEN_ROM_ROUNDUP 0x80000000ULL 146#define NETXEN_ROM_ROUNDUP 0x80000000ULL
117 147
118/* 148/*
@@ -151,30 +181,38 @@ enum {
151/* Host writes the following to notify that it has done the init-handshake */ 181/* Host writes the following to notify that it has done the init-handshake */
152#define PHAN_INITIALIZE_ACK 0xf00f 182#define PHAN_INITIALIZE_ACK 0xf00f
153 183
154#define NUM_RCV_DESC_RINGS 2 /* No of Rcv Descriptor contexts */ 184#define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */
155 185
156/* descriptor types */ 186/* descriptor types */
157#define RCV_DESC_NORMAL 0x01 187#define RCV_DESC_NORMAL 0x01
158#define RCV_DESC_JUMBO 0x02 188#define RCV_DESC_JUMBO 0x02
189#define RCV_DESC_LRO 0x04
159#define RCV_DESC_NORMAL_CTXID 0 190#define RCV_DESC_NORMAL_CTXID 0
160#define RCV_DESC_JUMBO_CTXID 1 191#define RCV_DESC_JUMBO_CTXID 1
192#define RCV_DESC_LRO_CTXID 2
161 193
162#define RCV_DESC_TYPE(ID) \ 194#define RCV_DESC_TYPE(ID) \
163 ((ID == RCV_DESC_JUMBO_CTXID) ? RCV_DESC_JUMBO : RCV_DESC_NORMAL) 195 ((ID == RCV_DESC_JUMBO_CTXID) \
196 ? RCV_DESC_JUMBO \
197 : ((ID == RCV_DESC_LRO_CTXID) \
198 ? RCV_DESC_LRO : \
199 (RCV_DESC_NORMAL)))
164 200
165#define MAX_CMD_DESCRIPTORS 1024 201#define MAX_CMD_DESCRIPTORS 1024
166#define MAX_RCV_DESCRIPTORS 32768 202#define MAX_RCV_DESCRIPTORS 32768
167#define MAX_JUMBO_RCV_DESCRIPTORS 1024 203#define MAX_JUMBO_RCV_DESCRIPTORS 4096
204#define MAX_LRO_RCV_DESCRIPTORS 2048
168#define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS 205#define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS
169#define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS 206#define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS
170#define MAX_RCV_DESC MAX_RCV_DESCRIPTORS 207#define MAX_RCV_DESC MAX_RCV_DESCRIPTORS
171#define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS 208#define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS
172#define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS)
173#define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8) 209#define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8)
174 210#define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS + \
211 MAX_LRO_RCV_DESCRIPTORS)
175#define MIN_TX_COUNT 4096 212#define MIN_TX_COUNT 4096
176#define MIN_RX_COUNT 4096 213#define MIN_RX_COUNT 4096
177 214#define NETXEN_CTX_SIGNATURE 0xdee0
215#define NETXEN_RCV_PRODUCER(ringid) (ringid)
178#define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */ 216#define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */
179 217
180#define PHAN_PEG_RCV_INITIALIZED 0xff01 218#define PHAN_PEG_RCV_INITIALIZED 0xff01
@@ -186,6 +224,67 @@ enum {
186#define get_index_range(index,length,count) \ 224#define get_index_range(index,length,count) \
187 (((index) + (count)) & ((length) - 1)) 225 (((index) + (count)) & ((length) - 1))
188 226
227#define MPORT_SINGLE_FUNCTION_MODE 0x1111
228
229extern unsigned long long netxen_dma_mask;
230
231/*
232 * NetXen host-peg signal message structure
233 *
234 * Bit 0-1 : peg_id => 0x2 for tx and 01 for rx
235 * Bit 2 : priv_id => must be 1
236 * Bit 3-17 : count => for doorbell
237 * Bit 18-27 : ctx_id => Context id
238 * Bit 28-31 : opcode
239 */
240
241typedef u32 netxen_ctx_msg;
242
243#define _netxen_set_bits(config_word, start, bits, val) {\
244 unsigned long long mask = (((1ULL << (bits)) - 1) << (start)); \
245 unsigned long long value = (val); \
246 (config_word) &= ~mask; \
247 (config_word) |= (((value) << (start)) & mask); \
248}
249
250#define netxen_set_msg_peg_id(config_word, val) \
251 _netxen_set_bits(config_word, 0, 2, val)
252#define netxen_set_msg_privid(config_word) \
253 set_bit(2, (unsigned long*)&config_word)
254#define netxen_set_msg_count(config_word, val) \
255 _netxen_set_bits(config_word, 3, 15, val)
256#define netxen_set_msg_ctxid(config_word, val) \
257 _netxen_set_bits(config_word, 18, 10, val)
258#define netxen_set_msg_opcode(config_word, val) \
259 _netxen_set_bits(config_word, 28, 4, val)
260
261struct netxen_rcv_context {
262 u32 rcv_ring_addr_lo;
263 u32 rcv_ring_addr_hi;
264 u32 rcv_ring_size;
265 u32 rsrvd;
266};
267
268struct netxen_ring_ctx {
269
270 /* one command ring */
271 u64 cmd_consumer_offset;
272 u32 cmd_ring_addr_lo;
273 u32 cmd_ring_addr_hi;
274 u32 cmd_ring_size;
275 u32 rsrvd;
276
277 /* three receive rings */
278 struct netxen_rcv_context rcv_ctx[3];
279
280 /* one status ring */
281 u32 sts_ring_addr_lo;
282 u32 sts_ring_addr_hi;
283 u32 sts_ring_size;
284
285 u32 ctx_id;
286} __attribute__ ((aligned(64)));
287
189/* 288/*
190 * Following data structures describe the descriptors that will be used. 289 * Following data structures describe the descriptors that will be used.
191 * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when 290 * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when
@@ -203,22 +302,32 @@ enum {
203#define FLAGS_IPSEC_SA_DELETE 0x08 302#define FLAGS_IPSEC_SA_DELETE 0x08
204#define FLAGS_VLAN_TAGGED 0x10 303#define FLAGS_VLAN_TAGGED 0x10
205 304
206#define CMD_DESC_TOTAL_LENGTH(cmd_desc) \ 305#define netxen_set_cmd_desc_port(cmd_desc, var) \
207 ((cmd_desc)->length_tcp_hdr & 0x00FFFFFF) 306 ((cmd_desc)->port_ctxid |= ((var) & 0x0F))
208#define CMD_DESC_TCP_HDR_OFFSET(cmd_desc) \
209 (((cmd_desc)->length_tcp_hdr >> 24) & 0x0FF)
210#define CMD_DESC_PORT(cmd_desc) ((cmd_desc)->port_ctxid & 0x0F)
211#define CMD_DESC_CTX_ID(cmd_desc) (((cmd_desc)->port_ctxid >> 4) & 0x0F)
212 307
213#define CMD_DESC_TOTAL_LENGTH_WRT(cmd_desc, var) \ 308#define netxen_set_cmd_desc_flags(cmd_desc, val) \
214 ((cmd_desc)->length_tcp_hdr |= ((var) & 0x00FFFFFF)) 309 _netxen_set_bits((cmd_desc)->flags_opcode, 0, 7, val)
215#define CMD_DESC_TCP_HDR_OFFSET_WRT(cmd_desc, var) \ 310#define netxen_set_cmd_desc_opcode(cmd_desc, val) \
216 ((cmd_desc)->length_tcp_hdr |= (((var) << 24) & 0xFF000000)) 311 _netxen_set_bits((cmd_desc)->flags_opcode, 7, 6, val)
217#define CMD_DESC_PORT_WRT(cmd_desc, var) \ 312
218 ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) 313#define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \
314 _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 0, 8, val);
315#define netxen_set_cmd_desc_totallength(cmd_desc, val) \
316 _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 8, 24, val);
317
318#define netxen_get_cmd_desc_opcode(cmd_desc) \
319 (((cmd_desc)->flags_opcode >> 7) & 0x003F)
320#define netxen_get_cmd_desc_totallength(cmd_desc) \
321 (((cmd_desc)->num_of_buffers_total_length >> 8) & 0x0FFFFFF)
219 322
220struct cmd_desc_type0 { 323struct cmd_desc_type0 {
221 u64 netxen_next; /* for fragments handled by Phantom */ 324 u8 tcp_hdr_offset; /* For LSO only */
325 u8 ip_hdr_offset; /* For LSO only */
326 /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */
327 u16 flags_opcode;
328 /* Bit pattern: 0-7 total number of segments,
329 8-31 Total size of the packet */
330 u32 num_of_buffers_total_length;
222 union { 331 union {
223 struct { 332 struct {
224 u32 addr_low_part2; 333 u32 addr_low_part2;
@@ -227,13 +336,6 @@ struct cmd_desc_type0 {
227 u64 addr_buffer2; 336 u64 addr_buffer2;
228 }; 337 };
229 338
230 /* Bit pattern: 0-23 total length, 24-32 tcp header offset */
231 u32 length_tcp_hdr;
232 u8 ip_hdr_offset; /* For LSO only */
233 u8 num_of_buffers; /* total number of segments */
234 u8 flags; /* as defined above */
235 u8 opcode;
236
237 u16 reference_handle; /* changed to u16 to add mss */ 339 u16 reference_handle; /* changed to u16 to add mss */
238 u16 mss; /* passed by NDIS_PACKET for LSO */ 340 u16 mss; /* passed by NDIS_PACKET for LSO */
239 /* Bit pattern 0-3 port, 0-3 ctx id */ 341 /* Bit pattern 0-3 port, 0-3 ctx id */
@@ -248,7 +350,6 @@ struct cmd_desc_type0 {
248 }; 350 };
249 u64 addr_buffer3; 351 u64 addr_buffer3;
250 }; 352 };
251
252 union { 353 union {
253 struct { 354 struct {
254 u32 addr_low_part1; 355 u32 addr_low_part1;
@@ -270,6 +371,8 @@ struct cmd_desc_type0 {
270 u64 addr_buffer4; 371 u64 addr_buffer4;
271 }; 372 };
272 373
374 u64 unused;
375
273} __attribute__ ((aligned(64))); 376} __attribute__ ((aligned(64)));
274 377
275/* Note: sizeof(rcv_desc) should always be a mutliple of 2 */ 378/* Note: sizeof(rcv_desc) should always be a mutliple of 2 */
@@ -296,22 +399,49 @@ struct rcv_desc {
296#define NETXEN_PROT_UNKNOWN (0) 399#define NETXEN_PROT_UNKNOWN (0)
297 400
298/* Note: sizeof(status_desc) should always be a mutliple of 2 */ 401/* Note: sizeof(status_desc) should always be a mutliple of 2 */
299#define STATUS_DESC_PORT(status_desc) \ 402
300 ((status_desc)->port_status_type_op & 0x0F) 403#define netxen_get_sts_desc_lro_cnt(status_desc) \
301#define STATUS_DESC_STATUS(status_desc) \ 404 ((status_desc)->lro & 0x7F)
302 (((status_desc)->port_status_type_op >> 4) & 0x0F) 405#define netxen_get_sts_desc_lro_last_frag(status_desc) \
303#define STATUS_DESC_TYPE(status_desc) \ 406 (((status_desc)->lro & 0x80) >> 7)
304 (((status_desc)->port_status_type_op >> 8) & 0x0F) 407
305#define STATUS_DESC_OPCODE(status_desc) \ 408#define netxen_get_sts_port(status_desc) \
306 (((status_desc)->port_status_type_op >> 12) & 0x0F) 409 ((status_desc)->status_desc_data & 0x0F)
410#define netxen_get_sts_status(status_desc) \
411 (((status_desc)->status_desc_data >> 4) & 0x0F)
412#define netxen_get_sts_type(status_desc) \
413 (((status_desc)->status_desc_data >> 8) & 0x0F)
414#define netxen_get_sts_totallength(status_desc) \
415 (((status_desc)->status_desc_data >> 12) & 0xFFFF)
416#define netxen_get_sts_refhandle(status_desc) \
417 (((status_desc)->status_desc_data >> 28) & 0xFFFF)
418#define netxen_get_sts_prot(status_desc) \
419 (((status_desc)->status_desc_data >> 44) & 0x0F)
420#define netxen_get_sts_owner(status_desc) \
421 (((status_desc)->status_desc_data >> 56) & 0x03)
422#define netxen_get_sts_opcode(status_desc) \
423 (((status_desc)->status_desc_data >> 58) & 0x03F)
424
425#define netxen_clear_sts_owner(status_desc) \
426 ((status_desc)->status_desc_data &= \
427 ~(((unsigned long long)3) << 56 ))
428#define netxen_set_sts_owner(status_desc, val) \
429 ((status_desc)->status_desc_data |= \
430 (((unsigned long long)((val) & 0x3)) << 56 ))
307 431
308struct status_desc { 432struct status_desc {
309 /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-15 opcode */ 433 /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length
310 u16 port_status_type_op; 434 28-43 reference_handle, 44-47 protocol, 48-52 unused
311 u16 total_length; /* NIC mode */ 435 53-55 desc_cnt, 56-57 owner, 58-63 opcode
312 u16 reference_handle; /* handle for the associated packet */ 436 */
313 /* Bit pattern: 0-1 owner, 2-5 protocol */ 437 u64 status_desc_data;
314 u16 owner; /* Owner of the descriptor */ 438 u32 hash_value;
439 u8 hash_type;
440 u8 msg_type;
441 u8 unused;
442 /* Bit pattern: 0-6 lro_count indicates frag sequence,
443 7 last_frag indicates last frag */
444 u8 lro;
315} __attribute__ ((aligned(8))); 445} __attribute__ ((aligned(8)));
316 446
317enum { 447enum {
@@ -559,11 +689,12 @@ typedef enum {
559#define PRIMARY_START (BOOTLD_START) 689#define PRIMARY_START (BOOTLD_START)
560#define FLASH_CRBINIT_SIZE (0x4000) 690#define FLASH_CRBINIT_SIZE (0x4000)
561#define FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info)) 691#define FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info))
562#define FLASH_USER_SIZE (sizeof(netxen_user_info)/sizeof(u32)) 692#define FLASH_USER_SIZE (sizeof(struct netxen_user_info)/sizeof(u32))
563#define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START) 693#define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START)
564#define NUM_PRIMARY_SECTORS (0x20) 694#define NUM_PRIMARY_SECTORS (0x20)
565#define NUM_CONFIG_SECTORS (1) 695#define NUM_CONFIG_SECTORS (1)
566#define PFX "netxen: " 696#define PFX "NetXen: "
697extern char netxen_nic_driver_name[];
567 698
568/* Note: Make sure to not call this before adapter->port is valid */ 699/* Note: Make sure to not call this before adapter->port is valid */
569#if !defined(NETXEN_DEBUG) 700#if !defined(NETXEN_DEBUG)
@@ -572,7 +703,7 @@ typedef enum {
572#else 703#else
573#define DPRINTK(klevel, fmt, args...) do { \ 704#define DPRINTK(klevel, fmt, args...) do { \
574 printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\ 705 printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\
575 (adapter != NULL && adapter->port != NULL && \ 706 (adapter != NULL && \
576 adapter->port[0] != NULL && \ 707 adapter->port[0] != NULL && \
577 adapter->port[0]->netdev != NULL) ? \ 708 adapter->port[0]->netdev != NULL) ? \
578 adapter->port[0]->netdev->name : NULL, \ 709 adapter->port[0]->netdev->name : NULL, \
@@ -609,7 +740,6 @@ struct netxen_cmd_buffer {
609 u8 frag_count; 740 u8 frag_count;
610 unsigned long time_stamp; 741 unsigned long time_stamp;
611 u32 state; 742 u32 state;
612 u32 no_of_descriptors;
613}; 743};
614 744
615/* In rx_buffer, we do not need multiple fragments as is a single buffer */ 745/* In rx_buffer, we do not need multiple fragments as is a single buffer */
@@ -618,6 +748,9 @@ struct netxen_rx_buffer {
618 u64 dma; 748 u64 dma;
619 u16 ref_handle; 749 u16 ref_handle;
620 u16 state; 750 u16 state;
751 u32 lro_expected_frags;
752 u32 lro_current_frags;
753 u32 lro_length;
621}; 754};
622 755
623/* Board types */ 756/* Board types */
@@ -633,6 +766,8 @@ struct netxen_hardware_context {
633 void __iomem *pci_base0; 766 void __iomem *pci_base0;
634 void __iomem *pci_base1; 767 void __iomem *pci_base1;
635 void __iomem *pci_base2; 768 void __iomem *pci_base2;
769 void __iomem *db_base;
770 unsigned long db_len;
636 771
637 u8 revision_id; 772 u8 revision_id;
638 u16 board_type; 773 u16 board_type;
@@ -642,14 +777,13 @@ struct netxen_hardware_context {
642 u32 qg_linksup; 777 u32 qg_linksup;
643 /* Address of cmd ring in Phantom */ 778 /* Address of cmd ring in Phantom */
644 struct cmd_desc_type0 *cmd_desc_head; 779 struct cmd_desc_type0 *cmd_desc_head;
645 char *pauseaddr;
646 struct pci_dev *cmd_desc_pdev; 780 struct pci_dev *cmd_desc_pdev;
647 dma_addr_t cmd_desc_phys_addr; 781 dma_addr_t cmd_desc_phys_addr;
648 dma_addr_t pause_physaddr;
649 struct pci_dev *pause_pdev;
650 struct netxen_adapter *adapter; 782 struct netxen_adapter *adapter;
651}; 783};
652 784
785#define RCV_RING_LRO RCV_DESC_LRO
786
653#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ 787#define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */
654#define ETHERNET_FCS_SIZE 4 788#define ETHERNET_FCS_SIZE 4
655 789
@@ -702,8 +836,13 @@ struct netxen_recv_context {
702}; 836};
703 837
704#define NETXEN_NIC_MSI_ENABLED 0x02 838#define NETXEN_NIC_MSI_ENABLED 0x02
839#define NETXEN_DMA_MASK 0xfffffffe
840#define NETXEN_DB_MAPSIZE_BYTES 0x1000
705 841
706struct netxen_drvops; 842struct netxen_dummy_dma {
843 void *addr;
844 dma_addr_t phys_addr;
845};
707 846
708struct netxen_adapter { 847struct netxen_adapter {
709 struct netxen_hardware_context ahw; 848 struct netxen_hardware_context ahw;
@@ -720,12 +859,13 @@ struct netxen_adapter {
720 u32 curr_window; 859 u32 curr_window;
721 860
722 u32 cmd_producer; 861 u32 cmd_producer;
723 u32 cmd_consumer; 862 u32 *cmd_consumer;
724 863
725 u32 last_cmd_consumer; 864 u32 last_cmd_consumer;
726 u32 max_tx_desc_count; 865 u32 max_tx_desc_count;
727 u32 max_rx_desc_count; 866 u32 max_rx_desc_count;
728 u32 max_jumbo_rx_desc_count; 867 u32 max_jumbo_rx_desc_count;
868 u32 max_lro_rx_desc_count;
729 /* Num of instances active on cmd buffer ring */ 869 /* Num of instances active on cmd buffer ring */
730 u32 proc_cmd_buf_counter; 870 u32 proc_cmd_buf_counter;
731 871
@@ -747,8 +887,27 @@ struct netxen_adapter {
747 struct netxen_recv_context recv_ctx[MAX_RCV_CTX]; 887 struct netxen_recv_context recv_ctx[MAX_RCV_CTX];
748 888
749 int is_up; 889 int is_up;
750 int work_done; 890 int number;
751 struct netxen_drvops *ops; 891 struct netxen_dummy_dma dummy_dma;
892
893 /* Context interface shared between card and host */
894 struct netxen_ring_ctx *ctx_desc;
895 struct pci_dev *ctx_desc_pdev;
896 dma_addr_t ctx_desc_phys_addr;
897 int (*enable_phy_interrupts) (struct netxen_adapter *, int);
898 int (*disable_phy_interrupts) (struct netxen_adapter *, int);
899 void (*handle_phy_intr) (struct netxen_adapter *);
900 int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t);
901 int (*set_mtu) (struct netxen_port *, int);
902 int (*set_promisc) (struct netxen_adapter *, int,
903 netxen_niu_prom_mode_t);
904 int (*unset_promisc) (struct netxen_adapter *, int,
905 netxen_niu_prom_mode_t);
906 int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *);
907 int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val);
908 int (*init_port) (struct netxen_adapter *, int);
909 void (*init_niu) (struct netxen_adapter *);
910 int (*stop_port) (struct netxen_adapter *, int);
752}; /* netxen_adapter structure */ 911}; /* netxen_adapter structure */
753 912
754/* Max number of xmit producer threads that can run simultaneously */ 913/* Max number of xmit producer threads that can run simultaneously */
@@ -830,25 +989,6 @@ static inline void __iomem *pci_base(struct netxen_adapter *adapter,
830 return NULL; 989 return NULL;
831} 990}
832 991
833struct netxen_drvops {
834 int (*enable_phy_interrupts) (struct netxen_adapter *, int);
835 int (*disable_phy_interrupts) (struct netxen_adapter *, int);
836 void (*handle_phy_intr) (struct netxen_adapter *);
837 int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t);
838 int (*set_mtu) (struct netxen_port *, int);
839 int (*set_promisc) (struct netxen_adapter *, int,
840 netxen_niu_prom_mode_t);
841 int (*unset_promisc) (struct netxen_adapter *, int,
842 netxen_niu_prom_mode_t);
843 int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *);
844 int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val);
845 int (*init_port) (struct netxen_adapter *, int);
846 void (*init_niu) (struct netxen_adapter *);
847 int (*stop_port) (struct netxen_adapter *, int);
848};
849
850extern char netxen_nic_driver_name[];
851
852int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter, 992int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter,
853 int port); 993 int port);
854int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, 994int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter,
@@ -887,10 +1027,20 @@ int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
887 int len); 1027 int len);
888int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, 1028int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
889 int len); 1029 int len);
1030int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off,
1031 void *data, int len);
1032int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off,
1033 void *data, int len);
1034int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter,
1035 u64 off, void *data, int size);
1036int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter,
1037 u64 off, void *data, int size);
890void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, 1038void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
891 unsigned long off, int data); 1039 unsigned long off, int data);
892 1040
893/* Functions from netxen_nic_init.c */ 1041/* Functions from netxen_nic_init.c */
1042void netxen_free_adapter_offload(struct netxen_adapter *adapter);
1043int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
894void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); 1044void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
895void netxen_load_firmware(struct netxen_adapter *adapter); 1045void netxen_load_firmware(struct netxen_adapter *adapter);
896int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); 1046int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
@@ -925,7 +1075,9 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter);
925void netxen_watchdog_task(struct work_struct *work); 1075void netxen_watchdog_task(struct work_struct *work);
926void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, 1076void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx,
927 u32 ringid); 1077 u32 ringid);
928void netxen_process_cmd_ring(unsigned long data); 1078void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, u32 ctx,
1079 u32 ringid);
1080int netxen_process_cmd_ring(unsigned long data);
929u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); 1081u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max);
930void netxen_nic_set_multi(struct net_device *netdev); 1082void netxen_nic_set_multi(struct net_device *netdev);
931int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); 1083int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu);
@@ -1019,7 +1171,6 @@ static inline void get_brd_name_by_type(u32 type, char *name)
1019 1171
1020int netxen_is_flash_supported(struct netxen_adapter *adapter); 1172int netxen_is_flash_supported(struct netxen_adapter *adapter);
1021int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]); 1173int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]);
1022
1023extern void netxen_change_ringparam(struct netxen_adapter *adapter); 1174extern void netxen_change_ringparam(struct netxen_adapter *adapter);
1024extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, 1175extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr,
1025 int *valp); 1176 int *valp);
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index 9a914aeba5bc..2ab4885cc950 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -1,25 +1,25 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
@@ -118,7 +118,7 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
118 u32 fw_minor = 0; 118 u32 fw_minor = 0;
119 u32 fw_build = 0; 119 u32 fw_build = 0;
120 120
121 strncpy(drvinfo->driver, "netxen_nic", 32); 121 strncpy(drvinfo->driver, netxen_nic_driver_name, 32);
122 strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); 122 strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
123 fw_major = readl(NETXEN_CRB_NORMALIZE(adapter, 123 fw_major = readl(NETXEN_CRB_NORMALIZE(adapter,
124 NETXEN_FW_VERSION_MAJOR)); 124 NETXEN_FW_VERSION_MAJOR));
@@ -210,7 +210,6 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
210 printk(KERN_ERR "netxen-nic: Unsupported board model %d\n", 210 printk(KERN_ERR "netxen-nic: Unsupported board model %d\n",
211 (netxen_brdtype_t) boardinfo->board_type); 211 (netxen_brdtype_t) boardinfo->board_type);
212 return -EIO; 212 return -EIO;
213
214 } 213 }
215 214
216 return 0; 215 return 0;
@@ -226,18 +225,18 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
226 /* read which mode */ 225 /* read which mode */
227 if (adapter->ahw.board_type == NETXEN_NIC_GBE) { 226 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
228 /* autonegotiation */ 227 /* autonegotiation */
229 if (adapter->ops->phy_write 228 if (adapter->phy_write
230 && adapter->ops->phy_write(adapter, port->portnum, 229 && adapter->phy_write(adapter, port->portnum,
231 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, 230 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
232 (__le32) ecmd->autoneg) != 0) 231 (__le32) ecmd->autoneg) != 0)
233 return -EIO; 232 return -EIO;
234 else 233 else
235 port->link_autoneg = ecmd->autoneg; 234 port->link_autoneg = ecmd->autoneg;
236 235
237 if (adapter->ops->phy_read 236 if (adapter->phy_read
238 && adapter->ops->phy_read(adapter, port->portnum, 237 && adapter->phy_read(adapter, port->portnum,
239 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 238 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
240 &status) != 0) 239 &status) != 0)
241 return -EIO; 240 return -EIO;
242 241
243 /* speed */ 242 /* speed */
@@ -257,10 +256,10 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
257 netxen_clear_phy_duplex(status); 256 netxen_clear_phy_duplex(status);
258 if (ecmd->duplex == DUPLEX_FULL) 257 if (ecmd->duplex == DUPLEX_FULL)
259 netxen_set_phy_duplex(status); 258 netxen_set_phy_duplex(status);
260 if (adapter->ops->phy_write 259 if (adapter->phy_write
261 && adapter->ops->phy_write(adapter, port->portnum, 260 && adapter->phy_write(adapter, port->portnum,
262 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 261 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
263 *((int *)&status)) != 0) 262 *((int *)&status)) != 0)
264 return -EIO; 263 return -EIO;
265 else { 264 else {
266 port->link_speed = ecmd->speed; 265 port->link_speed = ecmd->speed;
@@ -422,10 +421,10 @@ static u32 netxen_nic_get_link(struct net_device *dev)
422 421
423 /* read which mode */ 422 /* read which mode */
424 if (adapter->ahw.board_type == NETXEN_NIC_GBE) { 423 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
425 if (adapter->ops->phy_read 424 if (adapter->phy_read
426 && adapter->ops->phy_read(adapter, port->portnum, 425 && adapter->phy_read(adapter, port->portnum,
427 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 426 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
428 &status) != 0) 427 &status) != 0)
429 return -EIO; 428 return -EIO;
430 else 429 else
431 return (netxen_get_phy_link(status)); 430 return (netxen_get_phy_link(status));
@@ -460,20 +459,22 @@ netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
460{ 459{
461 struct netxen_port *port = netdev_priv(dev); 460 struct netxen_port *port = netdev_priv(dev);
462 struct netxen_adapter *adapter = port->adapter; 461 struct netxen_adapter *adapter = port->adapter;
463 int i, j; 462 int i;
464 463
465 ring->rx_pending = 0; 464 ring->rx_pending = 0;
465 ring->rx_jumbo_pending = 0;
466 for (i = 0; i < MAX_RCV_CTX; ++i) { 466 for (i = 0; i < MAX_RCV_CTX; ++i) {
467 for (j = 0; j < NUM_RCV_DESC_RINGS; j++) 467 ring->rx_pending += adapter->recv_ctx[i].
468 ring->rx_pending += 468 rcv_desc[RCV_DESC_NORMAL_CTXID].rcv_pending;
469 adapter->recv_ctx[i].rcv_desc[j].rcv_pending; 469 ring->rx_jumbo_pending += adapter->recv_ctx[i].
470 rcv_desc[RCV_DESC_JUMBO_CTXID].rcv_pending;
470 } 471 }
471 472
472 ring->rx_max_pending = adapter->max_rx_desc_count; 473 ring->rx_max_pending = adapter->max_rx_desc_count;
473 ring->tx_max_pending = adapter->max_tx_desc_count; 474 ring->tx_max_pending = adapter->max_tx_desc_count;
475 ring->rx_jumbo_max_pending = adapter->max_jumbo_rx_desc_count;
474 ring->rx_mini_max_pending = 0; 476 ring->rx_mini_max_pending = 0;
475 ring->rx_mini_pending = 0; 477 ring->rx_mini_pending = 0;
476 ring->rx_jumbo_max_pending = 0;
477 ring->rx_jumbo_pending = 0; 478 ring->rx_jumbo_pending = 0;
478} 479}
479 480
@@ -526,10 +527,10 @@ netxen_nic_set_pauseparam(struct net_device *dev,
526 *(u32 *) (&val)); 527 *(u32 *) (&val));
527 /* set autoneg */ 528 /* set autoneg */
528 autoneg = pause->autoneg; 529 autoneg = pause->autoneg;
529 if (adapter->ops->phy_write 530 if (adapter->phy_write
530 && adapter->ops->phy_write(adapter, port->portnum, 531 && adapter->phy_write(adapter, port->portnum,
531 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, 532 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
532 (__le32) autoneg) != 0) 533 (__le32) autoneg) != 0)
533 return -EIO; 534 return -EIO;
534 else { 535 else {
535 port->link_autoneg = pause->autoneg; 536 port->link_autoneg = pause->autoneg;
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 72c6ec4ee2a0..fe8b675f9e72 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
@@ -16,10 +16,10 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 105c24f0ad4c..9147b6048dfb 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
@@ -16,10 +16,10 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
@@ -42,7 +42,7 @@
42 42
43#define NETXEN_FLASH_BASE (BOOTLD_START) 43#define NETXEN_FLASH_BASE (BOOTLD_START)
44#define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE) 44#define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE)
45#define NETXEN_MAX_MTU 8000 45#define NETXEN_MAX_MTU 8000 + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE
46#define NETXEN_MIN_MTU 64 46#define NETXEN_MIN_MTU 64
47#define NETXEN_ETH_FCS_SIZE 4 47#define NETXEN_ETH_FCS_SIZE 4
48#define NETXEN_ENET_HEADER_SIZE 14 48#define NETXEN_ENET_HEADER_SIZE 14
@@ -81,8 +81,8 @@ int netxen_nic_set_mac(struct net_device *netdev, void *p)
81 DPRINTK(INFO, "valid ether addr\n"); 81 DPRINTK(INFO, "valid ether addr\n");
82 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 82 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
83 83
84 if (adapter->ops->macaddr_set) 84 if (adapter->macaddr_set)
85 adapter->ops->macaddr_set(port, addr->sa_data); 85 adapter->macaddr_set(port, addr->sa_data);
86 86
87 return 0; 87 return 0;
88} 88}
@@ -99,17 +99,17 @@ void netxen_nic_set_multi(struct net_device *netdev)
99 99
100 mc_ptr = netdev->mc_list; 100 mc_ptr = netdev->mc_list;
101 if (netdev->flags & IFF_PROMISC) { 101 if (netdev->flags & IFF_PROMISC) {
102 if (adapter->ops->set_promisc) 102 if (adapter->set_promisc)
103 adapter->ops->set_promisc(adapter, 103 adapter->set_promisc(adapter,
104 port->portnum, 104 port->portnum,
105 NETXEN_NIU_PROMISC_MODE); 105 NETXEN_NIU_PROMISC_MODE);
106 } else { 106 } else {
107 if (adapter->ops->unset_promisc && 107 if (adapter->unset_promisc &&
108 adapter->ahw.boardcfg.board_type 108 adapter->ahw.boardcfg.board_type
109 != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) 109 != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ)
110 adapter->ops->unset_promisc(adapter, 110 adapter->unset_promisc(adapter,
111 port->portnum, 111 port->portnum,
112 NETXEN_NIU_NON_PROMISC_MODE); 112 NETXEN_NIU_NON_PROMISC_MODE);
113 } 113 }
114 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { 114 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
115 netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03); 115 netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03);
@@ -160,8 +160,8 @@ int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
160 return -EINVAL; 160 return -EINVAL;
161 } 161 }
162 162
163 if (adapter->ops->set_mtu) 163 if (adapter->set_mtu)
164 adapter->ops->set_mtu(port, mtu); 164 adapter->set_mtu(port, mtu);
165 netdev->mtu = mtu; 165 netdev->mtu = mtu;
166 166
167 return 0; 167 return 0;
@@ -176,22 +176,18 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
176 struct netxen_hardware_context *hw = &adapter->ahw; 176 struct netxen_hardware_context *hw = &adapter->ahw;
177 u32 state = 0; 177 u32 state = 0;
178 void *addr; 178 void *addr;
179 void *pause_addr;
180 int loops = 0, err = 0; 179 int loops = 0, err = 0;
181 int ctx, ring; 180 int ctx, ring;
182 u32 card_cmdring = 0; 181 u32 card_cmdring = 0;
183 struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
184 struct netxen_recv_context *recv_ctx; 182 struct netxen_recv_context *recv_ctx;
185 struct netxen_rcv_desc_ctx *rcv_desc; 183 struct netxen_rcv_desc_ctx *rcv_desc;
186 184
187 DPRINTK(INFO, "crb_base: %lx %lx", NETXEN_PCI_CRBSPACE, 185 DPRINTK(INFO, "crb_base: %lx %x", NETXEN_PCI_CRBSPACE,
188 PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE)); 186 PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE));
189 DPRINTK(INFO, "cam base: %lx %lx", NETXEN_CRB_CAM, 187 DPRINTK(INFO, "cam base: %lx %x", NETXEN_CRB_CAM,
190 pci_base_offset(adapter, NETXEN_CRB_CAM)); 188 pci_base_offset(adapter, NETXEN_CRB_CAM));
191 DPRINTK(INFO, "cam RAM: %lx %lx", NETXEN_CAM_RAM_BASE, 189 DPRINTK(INFO, "cam RAM: %lx %x", NETXEN_CAM_RAM_BASE,
192 pci_base_offset(adapter, NETXEN_CAM_RAM_BASE)); 190 pci_base_offset(adapter, NETXEN_CAM_RAM_BASE));
193 DPRINTK(INFO, "NIC base:%lx %lx\n", NIC_CRB_BASE_PORT1,
194 pci_base_offset(adapter, NIC_CRB_BASE_PORT1));
195 191
196 /* Window 1 call */ 192 /* Window 1 call */
197 card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING)); 193 card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING));
@@ -226,33 +222,42 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
226 DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n"); 222 DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n");
227 223
228 addr = netxen_alloc(adapter->ahw.pdev, 224 addr = netxen_alloc(adapter->ahw.pdev,
229 sizeof(struct cmd_desc_type0) * 225 sizeof(struct netxen_ring_ctx) +
230 adapter->max_tx_desc_count, 226 sizeof(uint32_t),
231 &hw->cmd_desc_phys_addr, &hw->cmd_desc_pdev); 227 (dma_addr_t *) & adapter->ctx_desc_phys_addr,
228 &adapter->ctx_desc_pdev);
232 229
230 printk("ctx_desc_phys_addr: 0x%llx\n",
231 (u64) adapter->ctx_desc_phys_addr);
233 if (addr == NULL) { 232 if (addr == NULL) {
234 DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); 233 DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
235 return -ENOMEM; 234 err = -ENOMEM;
235 return err;
236 } 236 }
237 memset(addr, 0, sizeof(struct netxen_ring_ctx));
238 adapter->ctx_desc = (struct netxen_ring_ctx *)addr;
239 adapter->ctx_desc->cmd_consumer_offset = adapter->ctx_desc_phys_addr
240 + sizeof(struct netxen_ring_ctx);
241 adapter->cmd_consumer = (uint32_t *) (((char *)addr) +
242 sizeof(struct netxen_ring_ctx));
243
244 addr = pci_alloc_consistent(adapter->ahw.pdev,
245 sizeof(struct cmd_desc_type0) *
246 adapter->max_tx_desc_count,
247 (dma_addr_t *) & hw->cmd_desc_phys_addr);
248 printk("cmd_desc_phys_addr: 0x%llx\n", (u64) hw->cmd_desc_phys_addr);
237 249
238 pause_addr = netxen_alloc(adapter->ahw.pdev, 512, 250 if (addr == NULL) {
239 (dma_addr_t *) & hw->pause_physaddr, 251 DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
240 &hw->pause_pdev); 252 netxen_free_hw_resources(adapter);
241 if (pause_addr == NULL) {
242 DPRINTK(1, ERR, "bad return from pci_alloc_consistent\n");
243 return -ENOMEM; 253 return -ENOMEM;
244 } 254 }
245 255
246 hw->pauseaddr = (char *)pause_addr; 256 adapter->ctx_desc->cmd_ring_addr_lo =
247 { 257 hw->cmd_desc_phys_addr & 0xffffffffUL;
248 u64 *ptr = (u64 *) pause_addr; 258 adapter->ctx_desc->cmd_ring_addr_hi =
249 *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR; 259 ((u64) hw->cmd_desc_phys_addr >> 32);
250 *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR; 260 adapter->ctx_desc->cmd_ring_size = adapter->max_tx_desc_count;
251 *ptr++ = NETXEN_NIC_UNIT_PAUSE_ADDR;
252 *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
253 *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR1;
254 *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR2;
255 }
256 261
257 hw->cmd_desc_head = (struct cmd_desc_type0 *)addr; 262 hw->cmd_desc_head = (struct cmd_desc_type0 *)addr;
258 263
@@ -273,6 +278,12 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
273 return err; 278 return err;
274 } 279 }
275 rcv_desc->desc_head = (struct rcv_desc *)addr; 280 rcv_desc->desc_head = (struct rcv_desc *)addr;
281 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_lo =
282 rcv_desc->phys_addr & 0xffffffffUL;
283 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_hi =
284 ((u64) rcv_desc->phys_addr >> 32);
285 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size =
286 rcv_desc->max_rx_desc_count;
276 } 287 }
277 288
278 addr = netxen_alloc(adapter->ahw.pdev, STATUS_DESC_RINGSIZE, 289 addr = netxen_alloc(adapter->ahw.pdev, STATUS_DESC_RINGSIZE,
@@ -286,47 +297,21 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
286 return err; 297 return err;
287 } 298 }
288 recv_ctx->rcv_status_desc_head = (struct status_desc *)addr; 299 recv_ctx->rcv_status_desc_head = (struct status_desc *)addr;
289 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 300 adapter->ctx_desc->sts_ring_addr_lo =
290 rcv_desc = &recv_ctx->rcv_desc[ring]; 301 recv_ctx->rcv_status_desc_phys_addr & 0xffffffffUL;
291 rcv_desc_crb = 302 adapter->ctx_desc->sts_ring_addr_hi =
292 &recv_crb_registers[ctx].rcv_desc_crb[ring]; 303 ((u64) recv_ctx->rcv_status_desc_phys_addr >> 32);
293 DPRINTK(INFO, "ring #%d crb global ring reg 0x%x\n", 304 adapter->ctx_desc->sts_ring_size = adapter->max_rx_desc_count;
294 ring, rcv_desc_crb->crb_globalrcv_ring);
295 /* Window = 1 */
296 writel(lower32(rcv_desc->phys_addr),
297 NETXEN_CRB_NORMALIZE(adapter,
298 rcv_desc_crb->
299 crb_globalrcv_ring));
300 DPRINTK(INFO, "GLOBAL_RCV_RING ctx %d, addr 0x%x"
301 " val 0x%llx,"
302 " virt %p\n", ctx,
303 rcv_desc_crb->crb_globalrcv_ring,
304 (unsigned long long)rcv_desc->phys_addr,
305 +rcv_desc->desc_head);
306 }
307 305
308 /* Window = 1 */
309 writel(lower32(recv_ctx->rcv_status_desc_phys_addr),
310 NETXEN_CRB_NORMALIZE(adapter,
311 recv_crb_registers[ctx].
312 crb_rcvstatus_ring));
313 DPRINTK(INFO, "RCVSTATUS_RING, ctx %d, addr 0x%x,"
314 " val 0x%x,virt%p\n",
315 ctx,
316 recv_crb_registers[ctx].crb_rcvstatus_ring,
317 (unsigned long long)recv_ctx->rcv_status_desc_phys_addr,
318 recv_ctx->rcv_status_desc_head);
319 } 306 }
320 /* Window = 1 */ 307 /* Window = 1 */
321 writel(lower32(hw->pause_physaddr), 308
322 NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_LO)); 309 writel(lower32(adapter->ctx_desc_phys_addr),
323 writel(upper32(hw->pause_physaddr), 310 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_LO));
324 NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_HI)); 311 writel(upper32(adapter->ctx_desc_phys_addr),
325 312 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_HI));
326 writel(lower32(hw->cmd_desc_phys_addr), 313 writel(NETXEN_CTX_SIGNATURE,
327 NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); 314 NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_SIGNATURE_REG));
328 writel(upper32(hw->cmd_desc_phys_addr),
329 NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_HI));
330 return err; 315 return err;
331} 316}
332 317
@@ -336,6 +321,15 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
336 struct netxen_rcv_desc_ctx *rcv_desc; 321 struct netxen_rcv_desc_ctx *rcv_desc;
337 int ctx, ring; 322 int ctx, ring;
338 323
324 if (adapter->ctx_desc != NULL) {
325 pci_free_consistent(adapter->ctx_desc_pdev,
326 sizeof(struct netxen_ring_ctx) +
327 sizeof(uint32_t),
328 adapter->ctx_desc,
329 adapter->ctx_desc_phys_addr);
330 adapter->ctx_desc = NULL;
331 }
332
339 if (adapter->ahw.cmd_desc_head != NULL) { 333 if (adapter->ahw.cmd_desc_head != NULL) {
340 pci_free_consistent(adapter->ahw.cmd_desc_pdev, 334 pci_free_consistent(adapter->ahw.cmd_desc_pdev,
341 sizeof(struct cmd_desc_type0) * 335 sizeof(struct cmd_desc_type0) *
@@ -344,11 +338,9 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
344 adapter->ahw.cmd_desc_phys_addr); 338 adapter->ahw.cmd_desc_phys_addr);
345 adapter->ahw.cmd_desc_head = NULL; 339 adapter->ahw.cmd_desc_head = NULL;
346 } 340 }
347 if (adapter->ahw.pauseaddr != NULL) { 341 /* Special handling: there are 2 ports on this board */
348 pci_free_consistent(adapter->ahw.pause_pdev, 512, 342 if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) {
349 adapter->ahw.pauseaddr, 343 adapter->ahw.max_ports = 2;
350 adapter->ahw.pause_physaddr);
351 adapter->ahw.pauseaddr = NULL;
352 } 344 }
353 345
354 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { 346 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
@@ -383,19 +375,22 @@ void netxen_tso_check(struct netxen_adapter *adapter,
383 desc->total_hdr_length = sizeof(struct ethhdr) + 375 desc->total_hdr_length = sizeof(struct ethhdr) +
384 ((skb->nh.iph)->ihl * sizeof(u32)) + 376 ((skb->nh.iph)->ihl * sizeof(u32)) +
385 ((skb->h.th)->doff * sizeof(u32)); 377 ((skb->h.th)->doff * sizeof(u32));
386 desc->opcode = TX_TCP_LSO; 378 netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO);
387 } else if (skb->ip_summed == CHECKSUM_COMPLETE) { 379 } else if (skb->ip_summed == CHECKSUM_COMPLETE) {
388 if (skb->nh.iph->protocol == IPPROTO_TCP) { 380 if (skb->nh.iph->protocol == IPPROTO_TCP) {
389 desc->opcode = TX_TCP_PKT; 381 netxen_set_cmd_desc_opcode(desc, TX_TCP_PKT);
390 } else if (skb->nh.iph->protocol == IPPROTO_UDP) { 382 } else if (skb->nh.iph->protocol == IPPROTO_UDP) {
391 desc->opcode = TX_UDP_PKT; 383 netxen_set_cmd_desc_opcode(desc, TX_UDP_PKT);
392 } else { 384 } else {
393 return; 385 return;
394 } 386 }
395 } 387 }
396 adapter->stats.xmitcsummed++; 388 adapter->stats.xmitcsummed++;
397 CMD_DESC_TCP_HDR_OFFSET_WRT(desc, skb->h.raw - skb->data); 389 desc->tcp_hdr_offset = skb->h.raw - skb->data;
398 desc->length_tcp_hdr = cpu_to_le32(desc->length_tcp_hdr); 390 netxen_set_cmd_desc_totallength(desc,
391 cpu_to_le32
392 (netxen_get_cmd_desc_totallength
393 (desc)));
399 desc->ip_hdr_offset = skb->nh.raw - skb->data; 394 desc->ip_hdr_offset = skb->nh.raw - skb->data;
400} 395}
401 396
@@ -648,7 +643,7 @@ void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val)
648 643
649 addr = NETXEN_CRB_NORMALIZE(adapter, off); 644 addr = NETXEN_CRB_NORMALIZE(adapter, off);
650 DPRINTK(INFO, "writing to base %lx offset %llx addr %p data %x\n", 645 DPRINTK(INFO, "writing to base %lx offset %llx addr %p data %x\n",
651 pci_base(adapter, off), off, addr); 646 pci_base(adapter, off), off, addr, val);
652 writel(val, addr); 647 writel(val, addr);
653 648
654} 649}
@@ -660,7 +655,7 @@ int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off)
660 655
661 addr = NETXEN_CRB_NORMALIZE(adapter, off); 656 addr = NETXEN_CRB_NORMALIZE(adapter, off);
662 DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n", 657 DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n",
663 adapter->ahw.pci_base, off, addr); 658 pci_base(adapter, off), off, addr);
664 val = readl(addr); 659 val = readl(addr);
665 writel(val, addr); 660 writel(val, addr);
666 661
@@ -848,8 +843,8 @@ void netxen_nic_stop_all_ports(struct netxen_adapter *adapter)
848 843
849 for (port_nr = 0; port_nr < adapter->ahw.max_ports; port_nr++) { 844 for (port_nr = 0; port_nr < adapter->ahw.max_ports; port_nr++) {
850 port = adapter->port[port_nr]; 845 port = adapter->port[port_nr];
851 if (adapter->ops->stop_port) 846 if (adapter->stop_port)
852 adapter->ops->stop_port(adapter, port->portnum); 847 adapter->stop_port(adapter, port->portnum);
853 } 848 }
854} 849}
855 850
@@ -873,13 +868,13 @@ void netxen_nic_set_link_parameters(struct netxen_port *port)
873{ 868{
874 struct netxen_adapter *adapter = port->adapter; 869 struct netxen_adapter *adapter = port->adapter;
875 __le32 status; 870 __le32 status;
876 u16 autoneg; 871 __le32 autoneg;
877 __le32 mode; 872 __le32 mode;
878 873
879 netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode); 874 netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode);
880 if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */ 875 if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */
881 if (adapter->ops->phy_read 876 if (adapter->phy_read
882 && adapter->ops-> 877 && adapter->
883 phy_read(adapter, port->portnum, 878 phy_read(adapter, port->portnum,
884 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 879 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
885 &status) == 0) { 880 &status) == 0) {
@@ -909,11 +904,11 @@ void netxen_nic_set_link_parameters(struct netxen_port *port)
909 port->link_duplex = -1; 904 port->link_duplex = -1;
910 break; 905 break;
911 } 906 }
912 if (adapter->ops->phy_read 907 if (adapter->phy_read
913 && adapter->ops-> 908 && adapter->
914 phy_read(adapter, port->portnum, 909 phy_read(adapter, port->portnum,
915 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, 910 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
916 (__le32 *) & autoneg) != 0) 911 &autoneg) != 0)
917 port->link_autoneg = autoneg; 912 port->link_autoneg = autoneg;
918 } else 913 } else
919 goto link_down; 914 goto link_down;
@@ -1008,3 +1003,291 @@ int netxen_crb_read_val(struct netxen_adapter *adapter, unsigned long off)
1008 netxen_nic_hw_read_wx(adapter, off, &data, 4); 1003 netxen_nic_hw_read_wx(adapter, off, &data, 4);
1009 return data; 1004 return data;
1010} 1005}
1006
1007int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off,
1008 void *data, int len)
1009{
1010 void *addr;
1011 u64 offset = off;
1012 u8 *mem_ptr = NULL;
1013 unsigned long mem_base;
1014 unsigned long mem_page;
1015
1016 if (ADDR_IN_WINDOW1(off)) {
1017 addr = NETXEN_CRB_NORMALIZE(adapter, off);
1018 if (!addr) {
1019 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1020 offset = NETXEN_CRB_NORMAL(off);
1021 mem_page = offset & PAGE_MASK;
1022 if (mem_page != ((offset + len - 1) & PAGE_MASK))
1023 mem_ptr =
1024 ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1025 else
1026 mem_ptr =
1027 ioremap(mem_base + mem_page, PAGE_SIZE);
1028 if (mem_ptr == 0UL) {
1029 return 1;
1030 }
1031 addr = mem_ptr;
1032 addr += offset & (PAGE_SIZE - 1);
1033 }
1034 } else {
1035 addr = pci_base_offset(adapter, off);
1036 if (!addr) {
1037 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1038 mem_page = off & PAGE_MASK;
1039 if (mem_page != ((off + len - 1) & PAGE_MASK))
1040 mem_ptr =
1041 ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1042 else
1043 mem_ptr =
1044 ioremap(mem_base + mem_page, PAGE_SIZE);
1045 if (mem_ptr == 0UL) {
1046 return 1;
1047 }
1048 addr = mem_ptr;
1049 addr += off & (PAGE_SIZE - 1);
1050 }
1051 netxen_nic_pci_change_crbwindow(adapter, 0);
1052 }
1053 switch (len) {
1054 case 1:
1055 writeb(*(u8 *) data, addr);
1056 break;
1057 case 2:
1058 writew(*(u16 *) data, addr);
1059 break;
1060 case 4:
1061 writel(*(u32 *) data, addr);
1062 break;
1063 case 8:
1064 writeq(*(u64 *) data, addr);
1065 break;
1066 default:
1067 DPRINTK(INFO,
1068 "writing data %lx to offset %llx, num words=%d\n",
1069 *(unsigned long *)data, off, (len >> 3));
1070
1071 netxen_nic_hw_block_write64((u64 __iomem *) data, addr,
1072 (len >> 3));
1073 break;
1074 }
1075
1076 if (!ADDR_IN_WINDOW1(off))
1077 netxen_nic_pci_change_crbwindow(adapter, 1);
1078 if (mem_ptr)
1079 iounmap(mem_ptr);
1080 return 0;
1081}
1082
1083int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off,
1084 void *data, int len)
1085{
1086 void *addr;
1087 u64 offset;
1088 u8 *mem_ptr = NULL;
1089 unsigned long mem_base;
1090 unsigned long mem_page;
1091
1092 if (ADDR_IN_WINDOW1(off)) {
1093 addr = NETXEN_CRB_NORMALIZE(adapter, off);
1094 if (!addr) {
1095 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1096 offset = NETXEN_CRB_NORMAL(off);
1097 mem_page = offset & PAGE_MASK;
1098 if (mem_page != ((offset + len - 1) & PAGE_MASK))
1099 mem_ptr =
1100 ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1101 else
1102 mem_ptr =
1103 ioremap(mem_base + mem_page, PAGE_SIZE);
1104 if (mem_ptr == 0UL) {
1105 *(u8 *) data = 0;
1106 return 1;
1107 }
1108 addr = mem_ptr;
1109 addr += offset & (PAGE_SIZE - 1);
1110 }
1111 } else {
1112 addr = pci_base_offset(adapter, off);
1113 if (!addr) {
1114 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1115 mem_page = off & PAGE_MASK;
1116 if (mem_page != ((off + len - 1) & PAGE_MASK))
1117 mem_ptr =
1118 ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1119 else
1120 mem_ptr =
1121 ioremap(mem_base + mem_page, PAGE_SIZE);
1122 if (mem_ptr == 0UL)
1123 return 1;
1124 addr = mem_ptr;
1125 addr += off & (PAGE_SIZE - 1);
1126 }
1127 netxen_nic_pci_change_crbwindow(adapter, 0);
1128 }
1129 switch (len) {
1130 case 1:
1131 *(u8 *) data = readb(addr);
1132 break;
1133 case 2:
1134 *(u16 *) data = readw(addr);
1135 break;
1136 case 4:
1137 *(u32 *) data = readl(addr);
1138 break;
1139 case 8:
1140 *(u64 *) data = readq(addr);
1141 break;
1142 default:
1143 netxen_nic_hw_block_read64((u64 __iomem *) data, addr,
1144 (len >> 3));
1145 break;
1146 }
1147 if (!ADDR_IN_WINDOW1(off))
1148 netxen_nic_pci_change_crbwindow(adapter, 1);
1149 if (mem_ptr)
1150 iounmap(mem_ptr);
1151 return 0;
1152}
1153
1154int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, u64 off,
1155 void *data, int size)
1156{
1157 void *addr;
1158 int ret = 0;
1159 u8 *mem_ptr = NULL;
1160 unsigned long mem_base;
1161 unsigned long mem_page;
1162
1163 if (data == NULL || off > (128 * 1024 * 1024)) {
1164 printk(KERN_ERR "%s: data: %p off:%llx\n",
1165 netxen_nic_driver_name, data, off);
1166 return 1;
1167 }
1168 off = netxen_nic_pci_set_window(adapter, off);
1169 /* Corner case : Malicious user tried to break the driver by reading
1170 last few bytes in ranges and tries to read further addresses.
1171 */
1172 if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) {
1173 printk(KERN_ERR "%s: Invalid access to memory address range"
1174 " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off,
1175 off + size);
1176 return 1;
1177 }
1178 addr = pci_base_offset(adapter, off);
1179 DPRINTK(INFO, "writing data %llx to offset %llx\n",
1180 *(unsigned long long *)data, off);
1181 if (!addr) {
1182 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1183 mem_page = off & PAGE_MASK;
1184 /* Map two pages whenever user tries to access addresses in two
1185 consecutive pages.
1186 */
1187 if (mem_page != ((off + size - 1) & PAGE_MASK))
1188 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1189 else
1190 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
1191 if (mem_ptr == 0UL) {
1192 return 1;
1193 }
1194 addr = mem_ptr;
1195 addr += off & (PAGE_SIZE - 1);
1196 }
1197 switch (size) {
1198 case 1:
1199 writeb(*(u8 *) data, addr);
1200 break;
1201 case 2:
1202 writew(*(u16 *) data, addr);
1203 break;
1204 case 4:
1205 writel(*(u32 *) data, addr);
1206 break;
1207 case 8:
1208 writeq(*(u64 *) data, addr);
1209 break;
1210 default:
1211 DPRINTK(INFO,
1212 "writing data %lx to offset %llx, num words=%d\n",
1213 *(unsigned long *)data, off, (size >> 3));
1214
1215 netxen_nic_hw_block_write64((u64 __iomem *) data, addr,
1216 (size >> 3));
1217 break;
1218 }
1219
1220 if (mem_ptr)
1221 iounmap(mem_ptr);
1222 DPRINTK(INFO, "wrote %llx\n", *(unsigned long long *)data);
1223
1224 return ret;
1225}
1226
1227int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter,
1228 u64 off, void *data, int size)
1229{
1230 void *addr;
1231 int ret = 0;
1232 u8 *mem_ptr = NULL;
1233 unsigned long mem_base;
1234 unsigned long mem_page;
1235
1236 if (data == NULL || off > (128 * 1024 * 1024)) {
1237 printk(KERN_ERR "%s: data: %p off:%llx\n",
1238 netxen_nic_driver_name, data, off);
1239 return 1;
1240 }
1241 off = netxen_nic_pci_set_window(adapter, off);
1242 /* Corner case : Malicious user tried to break the driver by reading
1243 last few bytes in ranges and tries to read further addresses.
1244 */
1245 if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) {
1246 printk(KERN_ERR "%s: Invalid access to memory address range"
1247 " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off,
1248 off + size);
1249 return 1;
1250 }
1251 addr = pci_base_offset(adapter, off);
1252 if (!addr) {
1253 mem_base = pci_resource_start(adapter->ahw.pdev, 0);
1254 mem_page = off & PAGE_MASK;
1255 /* Map two pages whenever user tries to access addresses in two
1256 consecutive pages.
1257 */
1258 if (mem_page != ((off + size - 1) & PAGE_MASK))
1259 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2);
1260 else
1261 mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
1262 if (mem_ptr == 0UL) {
1263 *(u8 *) data = 0;
1264 return 1;
1265 }
1266 addr = mem_ptr;
1267 addr += off & (PAGE_SIZE - 1);
1268 }
1269 switch (size) {
1270 case 1:
1271 *(u8 *) data = readb(addr);
1272 break;
1273 case 2:
1274 *(u16 *) data = readw(addr);
1275 break;
1276 case 4:
1277 *(u32 *) data = readl(addr);
1278 break;
1279 case 8:
1280 *(u64 *) data = readq(addr);
1281 break;
1282 default:
1283 netxen_nic_hw_block_read64((u64 __iomem *) data, addr,
1284 (size >> 3));
1285 break;
1286 }
1287
1288 if (mem_ptr)
1289 iounmap(mem_ptr);
1290 DPRINTK(INFO, "read %llx\n", *(unsigned long long *)data);
1291
1292 return ret;
1293}
diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h
index 201a636b7ab8..0685633a9c1e 100644
--- a/drivers/net/netxen/netxen_nic_hw.h
+++ b/drivers/net/netxen/netxen_nic_hw.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
@@ -16,10 +16,10 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
@@ -83,8 +83,8 @@ struct netxen_adapter;
83#define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20) 83#define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)
84 84
85#define NETXEN_NIC_LOCKED_READ_REG(X, Y) \ 85#define NETXEN_NIC_LOCKED_READ_REG(X, Y) \
86 addr = pci_base_offset(adapter, (X)); \ 86 addr = pci_base_offset(adapter, X); \
87 *(u32 *)Y = readl(addr); 87 *(u32 *)Y = readl((void __iomem*) addr);
88 88
89struct netxen_port; 89struct netxen_port;
90void netxen_nic_set_link_parameters(struct netxen_port *port); 90void netxen_nic_set_link_parameters(struct netxen_port *port);
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index eae18236aefa..869725f0bb18 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -1,25 +1,25 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
@@ -137,6 +137,8 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
137 return err; 137 return err;
138 } 138 }
139 /* Window 1 call */ 139 /* Window 1 call */
140 writel(MPORT_SINGLE_FUNCTION_MODE,
141 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE));
140 writel(PHAN_INITIALIZE_ACK, 142 writel(PHAN_INITIALIZE_ACK,
141 NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); 143 NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
142 144
@@ -184,15 +186,12 @@ void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
184 for (i = 0; i < num_rx_bufs; i++) { 186 for (i = 0; i < num_rx_bufs; i++) {
185 rx_buf->ref_handle = i; 187 rx_buf->ref_handle = i;
186 rx_buf->state = NETXEN_BUFFER_FREE; 188 rx_buf->state = NETXEN_BUFFER_FREE;
187
188 DPRINTK(INFO, "Rx buf:ctx%d i(%d) rx_buf:" 189 DPRINTK(INFO, "Rx buf:ctx%d i(%d) rx_buf:"
189 "%p\n", ctxid, i, rx_buf); 190 "%p\n", ctxid, i, rx_buf);
190 rx_buf++; 191 rx_buf++;
191 } 192 }
192 } 193 }
193 } 194 }
194 DPRINTK(INFO, "initialized buffers for %s and %s\n",
195 "adapter->free_cmd_buf_list", "adapter->free_rxbuf");
196} 195}
197 196
198void netxen_initialize_adapter_hw(struct netxen_adapter *adapter) 197void netxen_initialize_adapter_hw(struct netxen_adapter *adapter)
@@ -212,37 +211,36 @@ void netxen_initialize_adapter_hw(struct netxen_adapter *adapter)
212 211
213void netxen_initialize_adapter_ops(struct netxen_adapter *adapter) 212void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
214{ 213{
215 struct netxen_drvops *ops = adapter->ops;
216 switch (adapter->ahw.board_type) { 214 switch (adapter->ahw.board_type) {
217 case NETXEN_NIC_GBE: 215 case NETXEN_NIC_GBE:
218 ops->enable_phy_interrupts = 216 adapter->enable_phy_interrupts =
219 netxen_niu_gbe_enable_phy_interrupts; 217 netxen_niu_gbe_enable_phy_interrupts;
220 ops->disable_phy_interrupts = 218 adapter->disable_phy_interrupts =
221 netxen_niu_gbe_disable_phy_interrupts; 219 netxen_niu_gbe_disable_phy_interrupts;
222 ops->handle_phy_intr = netxen_nic_gbe_handle_phy_intr; 220 adapter->handle_phy_intr = netxen_nic_gbe_handle_phy_intr;
223 ops->macaddr_set = netxen_niu_macaddr_set; 221 adapter->macaddr_set = netxen_niu_macaddr_set;
224 ops->set_mtu = netxen_nic_set_mtu_gb; 222 adapter->set_mtu = netxen_nic_set_mtu_gb;
225 ops->set_promisc = netxen_niu_set_promiscuous_mode; 223 adapter->set_promisc = netxen_niu_set_promiscuous_mode;
226 ops->unset_promisc = netxen_niu_set_promiscuous_mode; 224 adapter->unset_promisc = netxen_niu_set_promiscuous_mode;
227 ops->phy_read = netxen_niu_gbe_phy_read; 225 adapter->phy_read = netxen_niu_gbe_phy_read;
228 ops->phy_write = netxen_niu_gbe_phy_write; 226 adapter->phy_write = netxen_niu_gbe_phy_write;
229 ops->init_port = netxen_niu_gbe_init_port; 227 adapter->init_port = netxen_niu_gbe_init_port;
230 ops->init_niu = netxen_nic_init_niu_gb; 228 adapter->init_niu = netxen_nic_init_niu_gb;
231 ops->stop_port = netxen_niu_disable_gbe_port; 229 adapter->stop_port = netxen_niu_disable_gbe_port;
232 break; 230 break;
233 231
234 case NETXEN_NIC_XGBE: 232 case NETXEN_NIC_XGBE:
235 ops->enable_phy_interrupts = 233 adapter->enable_phy_interrupts =
236 netxen_niu_xgbe_enable_phy_interrupts; 234 netxen_niu_xgbe_enable_phy_interrupts;
237 ops->disable_phy_interrupts = 235 adapter->disable_phy_interrupts =
238 netxen_niu_xgbe_disable_phy_interrupts; 236 netxen_niu_xgbe_disable_phy_interrupts;
239 ops->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr; 237 adapter->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr;
240 ops->macaddr_set = netxen_niu_xg_macaddr_set; 238 adapter->macaddr_set = netxen_niu_xg_macaddr_set;
241 ops->set_mtu = netxen_nic_set_mtu_xgb; 239 adapter->set_mtu = netxen_nic_set_mtu_xgb;
242 ops->init_port = netxen_niu_xg_init_port; 240 adapter->init_port = netxen_niu_xg_init_port;
243 ops->set_promisc = netxen_niu_xg_set_promiscuous_mode; 241 adapter->set_promisc = netxen_niu_xg_set_promiscuous_mode;
244 ops->unset_promisc = netxen_niu_xg_set_promiscuous_mode; 242 adapter->unset_promisc = netxen_niu_xg_set_promiscuous_mode;
245 ops->stop_port = netxen_niu_disable_xg_port; 243 adapter->stop_port = netxen_niu_disable_xg_port;
246 break; 244 break;
247 245
248 default: 246 default:
@@ -383,8 +381,8 @@ int netxen_rom_wip_poll(struct netxen_adapter *adapter)
383 return 0; 381 return 0;
384} 382}
385 383
386static inline int do_rom_fast_write(struct netxen_adapter *adapter, 384static inline int do_rom_fast_write(struct netxen_adapter *adapter, int addr,
387 int addr, int data) 385 int data)
388{ 386{
389 if (netxen_rom_wren(adapter)) { 387 if (netxen_rom_wren(adapter)) {
390 return -1; 388 return -1;
@@ -622,6 +620,43 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
622 return 0; 620 return 0;
623} 621}
624 622
623int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
624{
625 uint64_t addr;
626 uint32_t hi;
627 uint32_t lo;
628
629 adapter->dummy_dma.addr =
630 pci_alloc_consistent(adapter->ahw.pdev,
631 NETXEN_HOST_DUMMY_DMA_SIZE,
632 &adapter->dummy_dma.phys_addr);
633 if (adapter->dummy_dma.addr == NULL) {
634 printk("%s: ERROR: Could not allocate dummy DMA memory\n",
635 __FUNCTION__);
636 return -ENOMEM;
637 }
638
639 addr = (uint64_t) adapter->dummy_dma.phys_addr;
640 hi = (addr >> 32) & 0xffffffff;
641 lo = addr & 0xffffffff;
642
643 writel(hi, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI));
644 writel(lo, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO));
645
646 return 0;
647}
648
649void netxen_free_adapter_offload(struct netxen_adapter *adapter)
650{
651 if (adapter->dummy_dma.addr) {
652 pci_free_consistent(adapter->ahw.pdev,
653 NETXEN_HOST_DUMMY_DMA_SIZE,
654 adapter->dummy_dma.addr,
655 adapter->dummy_dma.phys_addr);
656 adapter->dummy_dma.addr = NULL;
657 }
658}
659
625void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) 660void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
626{ 661{
627 u32 val = 0; 662 u32 val = 0;
@@ -656,7 +691,8 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
656 desc_head = recv_ctx->rcv_status_desc_head; 691 desc_head = recv_ctx->rcv_status_desc_head;
657 desc = &desc_head[consumer]; 692 desc = &desc_head[consumer];
658 693
659 if (((le16_to_cpu(desc->owner)) & STATUS_OWNER_HOST)) 694 if (((le16_to_cpu(netxen_get_sts_owner(desc)))
695 & STATUS_OWNER_HOST))
660 return 1; 696 return 1;
661 } 697 }
662 698
@@ -735,8 +771,8 @@ void netxen_watchdog_task(struct work_struct *work)
735 netif_wake_queue(netdev); 771 netif_wake_queue(netdev);
736 } 772 }
737 773
738 if (adapter->ops->handle_phy_intr) 774 if (adapter->handle_phy_intr)
739 adapter->ops->handle_phy_intr(adapter); 775 adapter->handle_phy_intr(adapter);
740 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 776 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
741} 777}
742 778
@@ -749,19 +785,19 @@ void
749netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, 785netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
750 struct status_desc *desc) 786 struct status_desc *desc)
751{ 787{
752 struct netxen_port *port = adapter->port[STATUS_DESC_PORT(desc)]; 788 struct netxen_port *port = adapter->port[netxen_get_sts_port(desc)];
753 struct pci_dev *pdev = port->pdev; 789 struct pci_dev *pdev = port->pdev;
754 struct net_device *netdev = port->netdev; 790 struct net_device *netdev = port->netdev;
755 int index = le16_to_cpu(desc->reference_handle); 791 int index = le16_to_cpu(netxen_get_sts_refhandle(desc));
756 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); 792 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
757 struct netxen_rx_buffer *buffer; 793 struct netxen_rx_buffer *buffer;
758 struct sk_buff *skb; 794 struct sk_buff *skb;
759 u32 length = le16_to_cpu(desc->total_length); 795 u32 length = le16_to_cpu(netxen_get_sts_totallength(desc));
760 u32 desc_ctx; 796 u32 desc_ctx;
761 struct netxen_rcv_desc_ctx *rcv_desc; 797 struct netxen_rcv_desc_ctx *rcv_desc;
762 int ret; 798 int ret;
763 799
764 desc_ctx = STATUS_DESC_TYPE(desc); 800 desc_ctx = netxen_get_sts_type(desc);
765 if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) { 801 if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) {
766 printk("%s: %s Bad Rcv descriptor ring\n", 802 printk("%s: %s Bad Rcv descriptor ring\n",
767 netxen_nic_driver_name, netdev->name); 803 netxen_nic_driver_name, netdev->name);
@@ -769,20 +805,49 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
769 } 805 }
770 806
771 rcv_desc = &recv_ctx->rcv_desc[desc_ctx]; 807 rcv_desc = &recv_ctx->rcv_desc[desc_ctx];
808 if (unlikely(index > rcv_desc->max_rx_desc_count)) {
809 DPRINTK(ERR, "Got a buffer index:%x Max is %x\n",
810 index, rcv_desc->max_rx_desc_count);
811 return;
812 }
772 buffer = &rcv_desc->rx_buf_arr[index]; 813 buffer = &rcv_desc->rx_buf_arr[index];
814 if (desc_ctx == RCV_DESC_LRO_CTXID) {
815 buffer->lro_current_frags++;
816 if (netxen_get_sts_desc_lro_last_frag(desc)) {
817 buffer->lro_expected_frags =
818 netxen_get_sts_desc_lro_cnt(desc);
819 buffer->lro_length = length;
820 }
821 if (buffer->lro_current_frags != buffer->lro_expected_frags) {
822 if (buffer->lro_expected_frags != 0) {
823 printk("LRO: (refhandle:%x) recv frag."
824 "wait for last. flags: %x expected:%d"
825 "have:%d\n", index,
826 netxen_get_sts_desc_lro_last_frag(desc),
827 buffer->lro_expected_frags,
828 buffer->lro_current_frags);
829 }
830 return;
831 }
832 }
773 833
774 pci_unmap_single(pdev, buffer->dma, rcv_desc->dma_size, 834 pci_unmap_single(pdev, buffer->dma, rcv_desc->dma_size,
775 PCI_DMA_FROMDEVICE); 835 PCI_DMA_FROMDEVICE);
776 836
777 skb = (struct sk_buff *)buffer->skb; 837 skb = (struct sk_buff *)buffer->skb;
778 838
779 if (likely(STATUS_DESC_STATUS(desc) == STATUS_CKSUM_OK)) { 839 if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) {
780 port->stats.csummed++; 840 port->stats.csummed++;
781 skb->ip_summed = CHECKSUM_UNNECESSARY; 841 skb->ip_summed = CHECKSUM_UNNECESSARY;
782 } else 842 }
783 skb->ip_summed = CHECKSUM_NONE;
784 skb->dev = netdev; 843 skb->dev = netdev;
785 skb_put(skb, length); 844 if (desc_ctx == RCV_DESC_LRO_CTXID) {
845 /* True length was only available on the last pkt */
846 skb_put(skb, buffer->lro_length);
847 } else {
848 skb_put(skb, length);
849 }
850
786 skb->protocol = eth_type_trans(skb, netdev); 851 skb->protocol = eth_type_trans(skb, netdev);
787 852
788 ret = netif_receive_skb(skb); 853 ret = netif_receive_skb(skb);
@@ -828,6 +893,8 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
828 adapter->stats.post_called++; 893 adapter->stats.post_called++;
829 buffer->skb = NULL; 894 buffer->skb = NULL;
830 buffer->state = NETXEN_BUFFER_FREE; 895 buffer->state = NETXEN_BUFFER_FREE;
896 buffer->lro_current_frags = 0;
897 buffer->lro_expected_frags = 0;
831 898
832 port->stats.no_rcv++; 899 port->stats.no_rcv++;
833 port->stats.rxbytes += length; 900 port->stats.rxbytes += length;
@@ -840,6 +907,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
840 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head; 907 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head;
841 struct status_desc *desc; /* used to read status desc here */ 908 struct status_desc *desc; /* used to read status desc here */
842 u32 consumer = recv_ctx->status_rx_consumer; 909 u32 consumer = recv_ctx->status_rx_consumer;
910 u32 producer = 0;
843 int count = 0, ring; 911 int count = 0, ring;
844 912
845 DPRINTK(INFO, "procesing receive\n"); 913 DPRINTK(INFO, "procesing receive\n");
@@ -851,18 +919,22 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
851 */ 919 */
852 while (count < max) { 920 while (count < max) {
853 desc = &desc_head[consumer]; 921 desc = &desc_head[consumer];
854 if (!((le16_to_cpu(desc->owner)) & STATUS_OWNER_HOST)) { 922 if (!
855 DPRINTK(ERR, "desc %p ownedby %x\n", desc, desc->owner); 923 (le16_to_cpu(netxen_get_sts_owner(desc)) &
924 STATUS_OWNER_HOST)) {
925 DPRINTK(ERR, "desc %p ownedby %x\n", desc,
926 netxen_get_sts_owner(desc));
856 break; 927 break;
857 } 928 }
858 netxen_process_rcv(adapter, ctxid, desc); 929 netxen_process_rcv(adapter, ctxid, desc);
859 desc->owner = STATUS_OWNER_PHANTOM; 930 netxen_clear_sts_owner(desc);
931 netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM);
860 consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1); 932 consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1);
861 count++; 933 count++;
862 } 934 }
863 if (count) { 935 if (count) {
864 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 936 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
865 netxen_post_rx_buffers(adapter, ctxid, ring); 937 netxen_post_rx_buffers_nodb(adapter, ctxid, ring);
866 } 938 }
867 } 939 }
868 940
@@ -870,6 +942,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
870 if (count) { 942 if (count) {
871 adapter->stats.process_rcv++; 943 adapter->stats.process_rcv++;
872 recv_ctx->status_rx_consumer = consumer; 944 recv_ctx->status_rx_consumer = consumer;
945 recv_ctx->status_rx_producer = producer;
873 946
874 /* Window = 1 */ 947 /* Window = 1 */
875 writel(consumer, 948 writel(consumer,
@@ -882,12 +955,13 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
882} 955}
883 956
884/* Process Command status ring */ 957/* Process Command status ring */
885void netxen_process_cmd_ring(unsigned long data) 958int netxen_process_cmd_ring(unsigned long data)
886{ 959{
887 u32 last_consumer; 960 u32 last_consumer;
888 u32 consumer; 961 u32 consumer;
889 struct netxen_adapter *adapter = (struct netxen_adapter *)data; 962 struct netxen_adapter *adapter = (struct netxen_adapter *)data;
890 int count = 0; 963 int count1 = 0;
964 int count2 = 0;
891 struct netxen_cmd_buffer *buffer; 965 struct netxen_cmd_buffer *buffer;
892 struct netxen_port *port; /* port #1 */ 966 struct netxen_port *port; /* port #1 */
893 struct netxen_port *nport; 967 struct netxen_port *nport;
@@ -896,6 +970,7 @@ void netxen_process_cmd_ring(unsigned long data)
896 u32 i; 970 u32 i;
897 struct sk_buff *skb = NULL; 971 struct sk_buff *skb = NULL;
898 int p; 972 int p;
973 int done;
899 974
900 spin_lock(&adapter->tx_lock); 975 spin_lock(&adapter->tx_lock);
901 last_consumer = adapter->last_cmd_consumer; 976 last_consumer = adapter->last_cmd_consumer;
@@ -905,14 +980,13 @@ void netxen_process_cmd_ring(unsigned long data)
905 * number as part of the descriptor. This way we will be able to get 980 * number as part of the descriptor. This way we will be able to get
906 * the netdev which is associated with that device. 981 * the netdev which is associated with that device.
907 */ 982 */
908 consumer =
909 readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
910 983
984 consumer = *(adapter->cmd_consumer);
911 if (last_consumer == consumer) { /* Ring is empty */ 985 if (last_consumer == consumer) { /* Ring is empty */
912 DPRINTK(INFO, "last_consumer %d == consumer %d\n", 986 DPRINTK(INFO, "last_consumer %d == consumer %d\n",
913 last_consumer, consumer); 987 last_consumer, consumer);
914 spin_unlock(&adapter->tx_lock); 988 spin_unlock(&adapter->tx_lock);
915 return; 989 return 1;
916 } 990 }
917 991
918 adapter->proc_cmd_buf_counter++; 992 adapter->proc_cmd_buf_counter++;
@@ -923,7 +997,7 @@ void netxen_process_cmd_ring(unsigned long data)
923 */ 997 */
924 spin_unlock(&adapter->tx_lock); 998 spin_unlock(&adapter->tx_lock);
925 999
926 while ((last_consumer != consumer) && (count < MAX_STATUS_HANDLE)) { 1000 while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) {
927 buffer = &adapter->cmd_buf_arr[last_consumer]; 1001 buffer = &adapter->cmd_buf_arr[last_consumer];
928 port = adapter->port[buffer->port]; 1002 port = adapter->port[buffer->port];
929 pdev = port->pdev; 1003 pdev = port->pdev;
@@ -949,24 +1023,24 @@ void netxen_process_cmd_ring(unsigned long data)
949 && netif_carrier_ok(port->netdev)) 1023 && netif_carrier_ok(port->netdev))
950 && ((jiffies - port->netdev->trans_start) > 1024 && ((jiffies - port->netdev->trans_start) >
951 port->netdev->watchdog_timeo)) { 1025 port->netdev->watchdog_timeo)) {
952 schedule_work(&port->adapter->tx_timeout_task); 1026 SCHEDULE_WORK(&port->adapter->tx_timeout_task);
953 } 1027 }
954 1028
955 last_consumer = get_next_index(last_consumer, 1029 last_consumer = get_next_index(last_consumer,
956 adapter->max_tx_desc_count); 1030 adapter->max_tx_desc_count);
957 count++; 1031 count1++;
958 } 1032 }
959 adapter->stats.noxmitdone += count; 1033 adapter->stats.noxmitdone += count1;
960 1034
961 count = 0; 1035 count2 = 0;
962 spin_lock(&adapter->tx_lock); 1036 spin_lock(&adapter->tx_lock);
963 if ((--adapter->proc_cmd_buf_counter) == 0) { 1037 if ((--adapter->proc_cmd_buf_counter) == 0) {
964 adapter->last_cmd_consumer = last_consumer; 1038 adapter->last_cmd_consumer = last_consumer;
965 while ((adapter->last_cmd_consumer != consumer) 1039 while ((adapter->last_cmd_consumer != consumer)
966 && (count < MAX_STATUS_HANDLE)) { 1040 && (count2 < MAX_STATUS_HANDLE)) {
967 buffer = 1041 buffer =
968 &adapter->cmd_buf_arr[adapter->last_cmd_consumer]; 1042 &adapter->cmd_buf_arr[adapter->last_cmd_consumer];
969 count++; 1043 count2++;
970 if (buffer->skb) 1044 if (buffer->skb)
971 break; 1045 break;
972 else 1046 else
@@ -975,7 +1049,7 @@ void netxen_process_cmd_ring(unsigned long data)
975 adapter->max_tx_desc_count); 1049 adapter->max_tx_desc_count);
976 } 1050 }
977 } 1051 }
978 if (count) { 1052 if (count1 || count2) {
979 for (p = 0; p < adapter->ahw.max_ports; p++) { 1053 for (p = 0; p < adapter->ahw.max_ports; p++) {
980 nport = adapter->port[p]; 1054 nport = adapter->port[p];
981 if (netif_queue_stopped(nport->netdev) 1055 if (netif_queue_stopped(nport->netdev)
@@ -985,10 +1059,30 @@ void netxen_process_cmd_ring(unsigned long data)
985 } 1059 }
986 } 1060 }
987 } 1061 }
1062 /*
1063 * If everything is freed up to consumer then check if the ring is full
1064 * If the ring is full then check if more needs to be freed and
1065 * schedule the call back again.
1066 *
1067 * This happens when there are 2 CPUs. One could be freeing and the
1068 * other filling it. If the ring is full when we get out of here and
1069 * the card has already interrupted the host then the host can miss the
1070 * interrupt.
1071 *
1072 * There is still a possible race condition and the host could miss an
1073 * interrupt. The card has to take care of this.
1074 */
1075 if (adapter->last_cmd_consumer == consumer &&
1076 (((adapter->cmd_producer + 1) %
1077 adapter->max_tx_desc_count) == adapter->last_cmd_consumer)) {
1078 consumer = *(adapter->cmd_consumer);
1079 }
1080 done = (adapter->last_cmd_consumer == consumer);
988 1081
989 spin_unlock(&adapter->tx_lock); 1082 spin_unlock(&adapter->tx_lock);
990 DPRINTK(INFO, "last consumer is %d in %s\n", last_consumer, 1083 DPRINTK(INFO, "last consumer is %d in %s\n", last_consumer,
991 __FUNCTION__); 1084 __FUNCTION__);
1085 return (done);
992} 1086}
993 1087
994/* 1088/*
@@ -1000,17 +1094,16 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1000 struct sk_buff *skb; 1094 struct sk_buff *skb;
1001 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); 1095 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]);
1002 struct netxen_rcv_desc_ctx *rcv_desc = NULL; 1096 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
1003 struct netxen_recv_crb *crbarea = &recv_crb_registers[ctx]; 1097 uint producer;
1004 struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
1005 u32 producer;
1006 struct rcv_desc *pdesc; 1098 struct rcv_desc *pdesc;
1007 struct netxen_rx_buffer *buffer; 1099 struct netxen_rx_buffer *buffer;
1008 int count = 0; 1100 int count = 0;
1009 int index = 0; 1101 int index = 0;
1102 netxen_ctx_msg msg = 0;
1103 dma_addr_t dma;
1010 1104
1011 adapter->stats.post_called++; 1105 adapter->stats.post_called++;
1012 rcv_desc = &recv_ctx->rcv_desc[ringid]; 1106 rcv_desc = &recv_ctx->rcv_desc[ringid];
1013 rcv_desc_crb = &crbarea->rcv_desc_crb[ringid];
1014 1107
1015 producer = rcv_desc->producer; 1108 producer = rcv_desc->producer;
1016 index = rcv_desc->begin_alloc; 1109 index = rcv_desc->begin_alloc;
@@ -1020,6 +1113,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1020 skb = dev_alloc_skb(rcv_desc->skb_size); 1113 skb = dev_alloc_skb(rcv_desc->skb_size);
1021 if (unlikely(!skb)) { 1114 if (unlikely(!skb)) {
1022 /* 1115 /*
1116 * TODO
1023 * We need to schedule the posting of buffers to the pegs. 1117 * We need to schedule the posting of buffers to the pegs.
1024 */ 1118 */
1025 rcv_desc->begin_alloc = index; 1119 rcv_desc->begin_alloc = index;
@@ -1027,9 +1121,105 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1027 " allocated only %d buffers\n", count); 1121 " allocated only %d buffers\n", count);
1028 break; 1122 break;
1029 } 1123 }
1124
1030 count++; /* now there should be no failure */ 1125 count++; /* now there should be no failure */
1031 pdesc = &rcv_desc->desc_head[producer]; 1126 pdesc = &rcv_desc->desc_head[producer];
1032 skb_reserve(skb, NET_IP_ALIGN); 1127
1128#if defined(XGB_DEBUG)
1129 *(unsigned long *)(skb->head) = 0xc0debabe;
1130 if (skb_is_nonlinear(skb)) {
1131 printk("Allocated SKB @%p is nonlinear\n");
1132 }
1133#endif
1134 skb_reserve(skb, 2);
1135 /* This will be setup when we receive the
1136 * buffer after it has been filled FSL TBD TBD
1137 * skb->dev = netdev;
1138 */
1139 dma = pci_map_single(pdev, skb->data, rcv_desc->dma_size,
1140 PCI_DMA_FROMDEVICE);
1141 pdesc->addr_buffer = dma;
1142 buffer->skb = skb;
1143 buffer->state = NETXEN_BUFFER_BUSY;
1144 buffer->dma = dma;
1145 /* make a rcv descriptor */
1146 pdesc->reference_handle = buffer->ref_handle;
1147 pdesc->buffer_length = rcv_desc->dma_size;
1148 DPRINTK(INFO, "done writing descripter\n");
1149 producer =
1150 get_next_index(producer, rcv_desc->max_rx_desc_count);
1151 index = get_next_index(index, rcv_desc->max_rx_desc_count);
1152 buffer = &rcv_desc->rx_buf_arr[index];
1153 }
1154 /* if we did allocate buffers, then write the count to Phantom */
1155 if (count) {
1156 rcv_desc->begin_alloc = index;
1157 rcv_desc->rcv_pending += count;
1158 adapter->stats.lastposted = count;
1159 adapter->stats.posted += count;
1160 rcv_desc->producer = producer;
1161 if (rcv_desc->rcv_free >= 32) {
1162 rcv_desc->rcv_free = 0;
1163 /* Window = 1 */
1164 writel((producer - 1) &
1165 (rcv_desc->max_rx_desc_count - 1),
1166 NETXEN_CRB_NORMALIZE(adapter,
1167 recv_crb_registers[0].
1168 rcv_desc_crb[ringid].
1169 crb_rcv_producer_offset));
1170 /*
1171 * Write a doorbell msg to tell phanmon of change in
1172 * receive ring producer
1173 */
1174 netxen_set_msg_peg_id(msg, NETXEN_RCV_PEG_DB_ID);
1175 netxen_set_msg_privid(msg);
1176 netxen_set_msg_count(msg,
1177 ((producer -
1178 1) & (rcv_desc->
1179 max_rx_desc_count - 1)));
1180 netxen_set_msg_ctxid(msg, 0);
1181 netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid));
1182 writel(msg,
1183 DB_NORMALIZE(adapter,
1184 NETXEN_RCV_PRODUCER_OFFSET));
1185 }
1186 }
1187}
1188
1189void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx,
1190 uint32_t ringid)
1191{
1192 struct pci_dev *pdev = adapter->ahw.pdev;
1193 struct sk_buff *skb;
1194 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]);
1195 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
1196 u32 producer;
1197 struct rcv_desc *pdesc;
1198 struct netxen_rx_buffer *buffer;
1199 int count = 0;
1200 int index = 0;
1201
1202 adapter->stats.post_called++;
1203 rcv_desc = &recv_ctx->rcv_desc[ringid];
1204
1205 producer = rcv_desc->producer;
1206 index = rcv_desc->begin_alloc;
1207 buffer = &rcv_desc->rx_buf_arr[index];
1208 /* We can start writing rx descriptors into the phantom memory. */
1209 while (buffer->state == NETXEN_BUFFER_FREE) {
1210 skb = dev_alloc_skb(rcv_desc->skb_size);
1211 if (unlikely(!skb)) {
1212 /*
1213 * We need to schedule the posting of buffers to the pegs.
1214 */
1215 rcv_desc->begin_alloc = index;
1216 DPRINTK(ERR, "netxen_post_rx_buffers_nodb: "
1217 " allocated only %d buffers\n", count);
1218 break;
1219 }
1220 count++; /* now there should be no failure */
1221 pdesc = &rcv_desc->desc_head[producer];
1222 skb_reserve(skb, 2);
1033 /* 1223 /*
1034 * This will be setup when we receive the 1224 * This will be setup when we receive the
1035 * buffer after it has been filled 1225 * buffer after it has been filled
@@ -1040,6 +1230,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1040 buffer->dma = pci_map_single(pdev, skb->data, 1230 buffer->dma = pci_map_single(pdev, skb->data,
1041 rcv_desc->dma_size, 1231 rcv_desc->dma_size,
1042 PCI_DMA_FROMDEVICE); 1232 PCI_DMA_FROMDEVICE);
1233
1043 /* make a rcv descriptor */ 1234 /* make a rcv descriptor */
1044 pdesc->reference_handle = le16_to_cpu(buffer->ref_handle); 1235 pdesc->reference_handle = le16_to_cpu(buffer->ref_handle);
1045 pdesc->buffer_length = le16_to_cpu(rcv_desc->dma_size); 1236 pdesc->buffer_length = le16_to_cpu(rcv_desc->dma_size);
@@ -1064,7 +1255,8 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1064 writel((producer - 1) & 1255 writel((producer - 1) &
1065 (rcv_desc->max_rx_desc_count - 1), 1256 (rcv_desc->max_rx_desc_count - 1),
1066 NETXEN_CRB_NORMALIZE(adapter, 1257 NETXEN_CRB_NORMALIZE(adapter,
1067 rcv_desc_crb-> 1258 recv_crb_registers[0].
1259 rcv_desc_crb[ringid].
1068 crb_rcv_producer_offset)); 1260 crb_rcv_producer_offset));
1069 wmb(); 1261 wmb();
1070 } 1262 }
@@ -1197,8 +1389,8 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
1197 1389
1198 switch (data.cmd) { 1390 switch (data.cmd) {
1199 case netxen_nic_cmd_pci_read: 1391 case netxen_nic_cmd_pci_read:
1200 if ((retval = netxen_nic_hw_read_wx(adapter, data.off, 1392 if ((retval = netxen_nic_hw_read_ioctl(adapter, data.off,
1201 &(data.u), data.size))) 1393 &(data.u), data.size)))
1202 goto error_out; 1394 goto error_out;
1203 if (copy_to_user 1395 if (copy_to_user
1204 ((void __user *)&(up_data->u), &(data.u), data.size)) { 1396 ((void __user *)&(up_data->u), &(data.u), data.size)) {
@@ -1211,8 +1403,35 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
1211 break; 1403 break;
1212 1404
1213 case netxen_nic_cmd_pci_write: 1405 case netxen_nic_cmd_pci_write:
1214 data.rv = netxen_nic_hw_write_wx(adapter, data.off, &(data.u), 1406 if ((retval = netxen_nic_hw_write_ioctl(adapter, data.off,
1215 data.size); 1407 &(data.u), data.size)))
1408 goto error_out;
1409 data.rv = 0;
1410 break;
1411
1412 case netxen_nic_cmd_pci_mem_read:
1413 if (netxen_nic_pci_mem_read_ioctl(adapter, data.off, &(data.u),
1414 data.size)) {
1415 DPRINTK(ERR, "Failed to read the data.\n");
1416 retval = -EFAULT;
1417 goto error_out;
1418 }
1419 if (copy_to_user
1420 ((void __user *)&(up_data->u), &(data.u), data.size)) {
1421 DPRINTK(ERR, "bad copy to userland: %d\n",
1422 (int)sizeof(data));
1423 retval = -EFAULT;
1424 goto error_out;
1425 }
1426 data.rv = 0;
1427 break;
1428
1429 case netxen_nic_cmd_pci_mem_write:
1430 if ((retval = netxen_nic_pci_mem_write_ioctl(adapter, data.off,
1431 &(data.u),
1432 data.size)))
1433 goto error_out;
1434 data.rv = 0;
1216 break; 1435 break;
1217 1436
1218 case netxen_nic_cmd_pci_config_read: 1437 case netxen_nic_cmd_pci_config_read:
@@ -1297,7 +1516,7 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data,
1297 retval = -EOPNOTSUPP; 1516 retval = -EOPNOTSUPP;
1298 goto error_out; 1517 goto error_out;
1299 } 1518 }
1300 put_user(data.rv, (u16 __user *) (&(up_data->rv))); 1519 put_user(data.rv, (&(up_data->rv)));
1301 DPRINTK(INFO, "done ioctl for %p well.\n", adapter); 1520 DPRINTK(INFO, "done ioctl for %p well.\n", adapter);
1302 1521
1303 error_out: 1522 error_out:
diff --git a/drivers/net/netxen/netxen_nic_ioctl.h b/drivers/net/netxen/netxen_nic_ioctl.h
index 23e53adbf123..1221fa527552 100644
--- a/drivers/net/netxen/netxen_nic_ioctl.h
+++ b/drivers/net/netxen/netxen_nic_ioctl.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
@@ -16,10 +16,10 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
@@ -36,7 +36,7 @@
36#define NETXEN_NIC_CMD (NETXEN_CMD_START + 1) 36#define NETXEN_NIC_CMD (NETXEN_CMD_START + 1)
37#define NETXEN_NIC_NAME (NETXEN_CMD_START + 2) 37#define NETXEN_NIC_NAME (NETXEN_CMD_START + 2)
38#define NETXEN_NIC_NAME_LEN 16 38#define NETXEN_NIC_NAME_LEN 16
39#define NETXEN_NIC_NAME_RSP "NETXEN" 39#define NETXEN_NIC_NAME_RSP "NETXEN-UNM"
40 40
41typedef enum { 41typedef enum {
42 netxen_nic_cmd_none = 0, 42 netxen_nic_cmd_none = 0,
diff --git a/drivers/net/netxen/netxen_nic_isr.c b/drivers/net/netxen/netxen_nic_isr.c
index ae180fee8008..1b45f50fa6aa 100644
--- a/drivers/net/netxen/netxen_nic_isr.c
+++ b/drivers/net/netxen/netxen_nic_isr.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
@@ -16,10 +16,10 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
@@ -68,8 +68,7 @@ struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
68void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno, 68void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno,
69 u32 link) 69 u32 link)
70{ 70{
71 struct netxen_port *pport = adapter->port[portno]; 71 struct net_device *netdev = (adapter->port[portno])->netdev;
72 struct net_device *netdev = pport->netdev;
73 72
74 if (link) 73 if (link)
75 netif_carrier_on(netdev); 74 netif_carrier_on(netdev);
@@ -84,46 +83,41 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
84 struct netxen_port *port; 83 struct netxen_port *port;
85 84
86 /* This should clear the interrupt source */ 85 /* This should clear the interrupt source */
87 if (adapter->ops->phy_read) 86 if (adapter->phy_read)
88 adapter->ops->phy_read(adapter, portno, 87 adapter->phy_read(adapter, portno,
89 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, 88 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
90 &int_src); 89 &int_src);
91 if (int_src == 0) { 90 if (int_src == 0) {
92 DPRINTK(INFO, "No phy interrupts for port #%d\n", portno); 91 DPRINTK(INFO, "No phy interrupts for port #%d\n", portno);
93 return; 92 return;
94 } 93 }
95 if (adapter->ops->disable_phy_interrupts) 94 if (adapter->disable_phy_interrupts)
96 adapter->ops->disable_phy_interrupts(adapter, portno); 95 adapter->disable_phy_interrupts(adapter, portno);
97 96
98 port = adapter->port[portno]; 97 port = adapter->port[portno];
99 98
100 if (netxen_get_phy_int_jabber(int_src)) 99 if (netxen_get_phy_int_jabber(int_src))
101 DPRINTK(INFO, "NetXen: %s Jabber interrupt \n", 100 DPRINTK(INFO, "Jabber interrupt \n");
102 port->netdev->name);
103 101
104 if (netxen_get_phy_int_polarity_changed(int_src)) 102 if (netxen_get_phy_int_polarity_changed(int_src))
105 DPRINTK(INFO, "NetXen: %s POLARITY CHANGED int \n", 103 DPRINTK(INFO, "POLARITY CHANGED int \n");
106 port->netdev->name);
107 104
108 if (netxen_get_phy_int_energy_detect(int_src)) 105 if (netxen_get_phy_int_energy_detect(int_src))
109 DPRINTK(INFO, "NetXen: %s ENERGY DETECT INT \n", 106 DPRINTK(INFO, "ENERGY DETECT INT \n");
110 port->netdev->name);
111 107
112 if (netxen_get_phy_int_downshift(int_src)) 108 if (netxen_get_phy_int_downshift(int_src))
113 DPRINTK(INFO, "NetXen: %s DOWNSHIFT INT \n", 109 DPRINTK(INFO, "DOWNSHIFT INT \n");
114 port->netdev->name);
115 /* write it down later.. */ 110 /* write it down later.. */
116 if ((netxen_get_phy_int_speed_changed(int_src)) 111 if ((netxen_get_phy_int_speed_changed(int_src))
117 || (netxen_get_phy_int_link_status_changed(int_src))) { 112 || (netxen_get_phy_int_link_status_changed(int_src))) {
118 __le32 status; 113 __le32 status;
119 114
120 DPRINTK(INFO, "NetXen: %s SPEED CHANGED OR" 115 DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n");
121 " LINK STATUS CHANGED \n", port->netdev->name);
122 116
123 if (adapter->ops->phy_read 117 if (adapter->phy_read
124 && adapter->ops->phy_read(adapter, portno, 118 && adapter->phy_read(adapter, portno,
125 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 119 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
126 &status) == 0) { 120 &status) == 0) {
127 if (netxen_get_phy_int_link_status_changed(int_src)) { 121 if (netxen_get_phy_int_link_status_changed(int_src)) {
128 if (netxen_get_phy_link(status)) { 122 if (netxen_get_phy_link(status)) {
129 netxen_niu_gbe_init_port(adapter, 123 netxen_niu_gbe_init_port(adapter,
@@ -143,8 +137,8 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
143 } 137 }
144 } 138 }
145 } 139 }
146 if (adapter->ops->enable_phy_interrupts) 140 if (adapter->enable_phy_interrupts)
147 adapter->ops->enable_phy_interrupts(adapter, portno); 141 adapter->enable_phy_interrupts(adapter, portno);
148} 142}
149 143
150void netxen_nic_isr_other(struct netxen_adapter *adapter) 144void netxen_nic_isr_other(struct netxen_adapter *adapter)
@@ -159,8 +153,7 @@ void netxen_nic_isr_other(struct netxen_adapter *adapter)
159 153
160 qg_linksup = adapter->ahw.qg_linksup; 154 qg_linksup = adapter->ahw.qg_linksup;
161 adapter->ahw.qg_linksup = val; 155 adapter->ahw.qg_linksup = val;
162 DPRINTK(1, INFO, "%s: link update 0x%08x\n", netxen_nic_driver_name, 156 DPRINTK(INFO, "link update 0x%08x\n", val);
163 val);
164 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) { 157 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) {
165 linkup = val & 1; 158 linkup = val & 1;
166 if (linkup != (qg_linksup & 1)) { 159 if (linkup != (qg_linksup & 1)) {
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index df0bb36a1cfb..575b71b67202 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -1,25 +1,25 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/highmem.h>
35#include "netxen_nic_hw.h" 36#include "netxen_nic_hw.h"
36 37
37#include "netxen_nic.h" 38#include "netxen_nic.h"
@@ -48,14 +49,21 @@ MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
48MODULE_LICENSE("GPL"); 49MODULE_LICENSE("GPL");
49MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); 50MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID);
50 51
51char netxen_nic_driver_name[] = "netxen"; 52char netxen_nic_driver_name[] = "netxen-nic";
52static char netxen_nic_driver_string[] = "NetXen Network Driver version " 53static char netxen_nic_driver_string[] = "NetXen Network Driver version "
53 NETXEN_NIC_LINUX_VERSIONID; 54 NETXEN_NIC_LINUX_VERSIONID;
54 55
56struct netxen_adapter *g_adapter = NULL;
57
55#define NETXEN_NETDEV_WEIGHT 120 58#define NETXEN_NETDEV_WEIGHT 120
56#define NETXEN_ADAPTER_UP_MAGIC 777 59#define NETXEN_ADAPTER_UP_MAGIC 777
57#define NETXEN_NIC_PEG_TUNE 0 60#define NETXEN_NIC_PEG_TUNE 0
58 61
62u8 nx_p2_id = NX_P2_C0;
63
64#define DMA_32BIT_MASK 0x00000000ffffffffULL
65#define DMA_35BIT_MASK 0x00000007ffffffffULL
66
59/* Local functions to NetXen NIC driver */ 67/* Local functions to NetXen NIC driver */
60static int __devinit netxen_nic_probe(struct pci_dev *pdev, 68static int __devinit netxen_nic_probe(struct pci_dev *pdev,
61 const struct pci_device_id *ent); 69 const struct pci_device_id *ent);
@@ -87,6 +95,9 @@ static struct pci_device_id netxen_pci_tbl[] __devinitdata = {
87 95
88MODULE_DEVICE_TABLE(pci, netxen_pci_tbl); 96MODULE_DEVICE_TABLE(pci, netxen_pci_tbl);
89 97
98struct workqueue_struct *netxen_workq;
99static void netxen_watchdog(unsigned long);
100
90/* 101/*
91 * netxen_nic_probe() 102 * netxen_nic_probe()
92 * 103 *
@@ -105,20 +116,28 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
105 struct net_device *netdev = NULL; 116 struct net_device *netdev = NULL;
106 struct netxen_adapter *adapter = NULL; 117 struct netxen_adapter *adapter = NULL;
107 struct netxen_port *port = NULL; 118 struct netxen_port *port = NULL;
108 u8 *mem_ptr0 = NULL; 119 void __iomem *mem_ptr0 = NULL;
109 u8 *mem_ptr1 = NULL; 120 void __iomem *mem_ptr1 = NULL;
110 u8 *mem_ptr2 = NULL; 121 void __iomem *mem_ptr2 = NULL;
111 122
112 unsigned long mem_base, mem_len; 123 u8 *db_ptr = NULL;
124 unsigned long mem_base, mem_len, db_base, db_len;
113 int pci_using_dac, i, err; 125 int pci_using_dac, i, err;
114 int ring; 126 int ring;
115 struct netxen_recv_context *recv_ctx = NULL; 127 struct netxen_recv_context *recv_ctx = NULL;
116 struct netxen_rcv_desc_ctx *rcv_desc = NULL; 128 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
117 struct netxen_cmd_buffer *cmd_buf_arr = NULL; 129 struct netxen_cmd_buffer *cmd_buf_arr = NULL;
118 u64 mac_addr[FLASH_NUM_PORTS + 1]; 130 u64 mac_addr[FLASH_NUM_PORTS + 1];
119 int valid_mac; 131 int valid_mac = 0;
132 static int netxen_cards_found = 0;
120 133
121 printk(KERN_INFO "%s \n", netxen_nic_driver_string); 134 printk(KERN_INFO "%s \n", netxen_nic_driver_string);
135 /* In current scheme, we use only PCI function 0 */
136 if (PCI_FUNC(pdev->devfn) != 0) {
137 DPRINTK(ERR, "NetXen function %d will not be enabled.\n",
138 PCI_FUNC(pdev->devfn));
139 return -ENODEV;
140 }
122 if ((err = pci_enable_device(pdev))) 141 if ((err = pci_enable_device(pdev)))
123 return err; 142 return err;
124 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 143 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
@@ -130,10 +149,12 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
130 goto err_out_disable_pdev; 149 goto err_out_disable_pdev;
131 150
132 pci_set_master(pdev); 151 pci_set_master(pdev);
133 if ((pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) && 152 pci_read_config_byte(pdev, PCI_REVISION_ID, &nx_p2_id);
134 (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) == 0)) 153 if (nx_p2_id == NX_P2_C1 &&
154 (pci_set_dma_mask(pdev, DMA_35BIT_MASK) == 0) &&
155 (pci_set_consistent_dma_mask(pdev, DMA_35BIT_MASK) == 0)) {
135 pci_using_dac = 1; 156 pci_using_dac = 1;
136 else { 157 } else {
137 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) || 158 if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) ||
138 (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) 159 (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)))
139 goto err_out_free_res; 160 goto err_out_free_res;
@@ -153,21 +174,34 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
153 ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); 174 ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
154 175
155 if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) { 176 if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) {
156 DPRINTK(1, ERR, 177 DPRINTK(ERR,
157 "Cannot remap adapter memory aborting.:" 178 "Cannot remap adapter memory aborting.:"
158 "0 -> %p, 1 -> %p, 2 -> %p\n", 179 "0 -> %p, 1 -> %p, 2 -> %p\n",
159 mem_ptr0, mem_ptr1, mem_ptr2); 180 mem_ptr0, mem_ptr1, mem_ptr2);
160 181
161 err = -EIO; 182 err = -EIO;
162 if (mem_ptr0) 183 goto err_out_iounmap;
163 iounmap(mem_ptr0); 184 }
164 if (mem_ptr1) 185 db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */
165 iounmap(mem_ptr1); 186 db_len = pci_resource_len(pdev, 4);
166 if (mem_ptr2) 187
167 iounmap(mem_ptr2); 188 if (db_len == 0) {
168 189 printk(KERN_ERR "%s: doorbell is disabled\n",
169 goto err_out_free_res; 190 netxen_nic_driver_name);
191 err = -EIO;
192 goto err_out_iounmap;
193 }
194 DPRINTK(INFO, "doorbell ioremap from %lx a size of %lx\n", db_base,
195 db_len);
196
197 db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES);
198 if (db_ptr == 0UL) {
199 printk(KERN_ERR "%s: Failed to allocate doorbell map.",
200 netxen_nic_driver_name);
201 err = -EIO;
202 goto err_out_iounmap;
170 } 203 }
204 DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr);
171 205
172/* 206/*
173 * Allocate a adapter structure which will manage all the initialization 207 * Allocate a adapter structure which will manage all the initialization
@@ -183,17 +217,24 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
183 netxen_nic_driver_name, 217 netxen_nic_driver_name,
184 (int)sizeof(struct netxen_adapter)); 218 (int)sizeof(struct netxen_adapter));
185 err = -ENOMEM; 219 err = -ENOMEM;
186 goto err_out_iounmap; 220 goto err_out_dbunmap;
187 } 221 }
188 222
223 if (netxen_cards_found == 0) {
224 g_adapter = adapter;
225 }
189 adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS; 226 adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS;
190 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS; 227 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS;
191 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; 228 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS;
229 adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS;
192 230
193 pci_set_drvdata(pdev, adapter); 231 pci_set_drvdata(pdev, adapter);
194 232
195 cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE); 233 cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE);
196 if (cmd_buf_arr == NULL) { 234 if (cmd_buf_arr == NULL) {
235 printk(KERN_ERR
236 "%s: Could not allocate cmd_buf_arr memory:%d\n",
237 netxen_nic_driver_name, (int)TX_RINGSIZE);
197 err = -ENOMEM; 238 err = -ENOMEM;
198 goto err_out_free_adapter; 239 goto err_out_free_adapter;
199 } 240 }
@@ -220,11 +261,23 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
220 rcv_desc->skb_size = MAX_RX_JUMBO_BUFFER_LENGTH; 261 rcv_desc->skb_size = MAX_RX_JUMBO_BUFFER_LENGTH;
221 break; 262 break;
222 263
264 case RCV_RING_LRO:
265 rcv_desc->max_rx_desc_count =
266 adapter->max_lro_rx_desc_count;
267 rcv_desc->flags = RCV_DESC_LRO;
268 rcv_desc->dma_size = RX_LRO_DMA_MAP_LEN;
269 rcv_desc->skb_size = MAX_RX_LRO_BUFFER_LENGTH;
270 break;
271
223 } 272 }
224 rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *) 273 rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *)
225 vmalloc(RCV_BUFFSIZE); 274 vmalloc(RCV_BUFFSIZE);
226 275
227 if (rcv_desc->rx_buf_arr == NULL) { 276 if (rcv_desc->rx_buf_arr == NULL) {
277 printk(KERN_ERR "%s: Could not allocate"
278 "rcv_desc->rx_buf_arr memory:%d\n",
279 netxen_nic_driver_name,
280 (int)RCV_BUFFSIZE);
228 err = -ENOMEM; 281 err = -ENOMEM;
229 goto err_out_free_rx_buffer; 282 goto err_out_free_rx_buffer;
230 } 283 }
@@ -233,30 +286,21 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
233 286
234 } 287 }
235 288
236 adapter->ops = kzalloc(sizeof(struct netxen_drvops), GFP_KERNEL);
237 if (adapter->ops == NULL) {
238 printk(KERN_ERR
239 "%s: Could not allocate memory for adapter->ops:%d\n",
240 netxen_nic_driver_name,
241 (int)sizeof(struct netxen_adapter));
242 err = -ENOMEM;
243 goto err_out_free_rx_buffer;
244 }
245
246 adapter->cmd_buf_arr = cmd_buf_arr; 289 adapter->cmd_buf_arr = cmd_buf_arr;
247 adapter->ahw.pci_base0 = mem_ptr0; 290 adapter->ahw.pci_base0 = mem_ptr0;
248 adapter->ahw.pci_base1 = mem_ptr1; 291 adapter->ahw.pci_base1 = mem_ptr1;
249 adapter->ahw.pci_base2 = mem_ptr2; 292 adapter->ahw.pci_base2 = mem_ptr2;
293 adapter->ahw.db_base = db_ptr;
294 adapter->ahw.db_len = db_len;
250 spin_lock_init(&adapter->tx_lock); 295 spin_lock_init(&adapter->tx_lock);
251 spin_lock_init(&adapter->lock); 296 spin_lock_init(&adapter->lock);
297 netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */
252#ifdef CONFIG_IA64 298#ifdef CONFIG_IA64
253 netxen_pinit_from_rom(adapter, 0); 299 netxen_pinit_from_rom(adapter, 0);
254 udelay(500); 300 udelay(500);
255 netxen_load_firmware(adapter); 301 netxen_load_firmware(adapter);
256#endif 302#endif
257 303
258 /* initialize the buffers in adapter */
259 netxen_initialize_adapter_sw(adapter);
260 /* 304 /*
261 * Set the CRB window to invalid. If any register in window 0 is 305 * Set the CRB window to invalid. If any register in window 0 is
262 * accessed it should set the window to 0 and then reset it to 1. 306 * accessed it should set the window to 0 and then reset it to 1.
@@ -277,7 +321,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
277 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task); 321 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task);
278 adapter->ahw.pdev = pdev; 322 adapter->ahw.pdev = pdev;
279 adapter->proc_cmd_buf_counter = 0; 323 adapter->proc_cmd_buf_counter = 0;
280 pci_read_config_byte(pdev, PCI_REVISION_ID, &adapter->ahw.revision_id); 324 adapter->ahw.revision_id = nx_p2_id;
281 325
282 if (pci_enable_msi(pdev)) { 326 if (pci_enable_msi(pdev)) {
283 adapter->flags &= ~NETXEN_NIC_MSI_ENABLED; 327 adapter->flags &= ~NETXEN_NIC_MSI_ENABLED;
@@ -299,6 +343,12 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
299 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET)); 343 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
300 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); 344 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
301 345
346 /* do this before waking up pegs so that we have valid dummy dma addr */
347 err = netxen_initialize_adapter_offload(adapter);
348 if (err) {
349 goto err_out_free_dev;
350 }
351
302 /* Unlock the HW, prompting the boot sequence */ 352 /* Unlock the HW, prompting the boot sequence */
303 writel(1, 353 writel(1,
304 NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE)); 354 NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
@@ -307,6 +357,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
307 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 357 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
308 358
309 /* initialize the all the ports */ 359 /* initialize the all the ports */
360 adapter->active_ports = 0;
310 361
311 for (i = 0; i < adapter->ahw.max_ports; i++) { 362 for (i = 0; i < adapter->ahw.max_ports; i++) {
312 netdev = alloc_etherdev(sizeof(struct netxen_port)); 363 netdev = alloc_etherdev(sizeof(struct netxen_port));
@@ -372,10 +423,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
372 netdev->dev_addr[4], 423 netdev->dev_addr[4],
373 netdev->dev_addr[5]); 424 netdev->dev_addr[5]);
374 } else { 425 } else {
375 if (adapter->ops->macaddr_set) 426 if (adapter->macaddr_set)
376 adapter->ops->macaddr_set(port, 427 adapter->macaddr_set(port,
377 netdev-> 428 netdev->dev_addr);
378 dev_addr);
379 } 429 }
380 } 430 }
381 adapter->netdev = netdev; 431 adapter->netdev = netdev;
@@ -391,7 +441,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
391 goto err_out_free_dev; 441 goto err_out_free_dev;
392 } 442 }
393 adapter->port_count++; 443 adapter->port_count++;
394 adapter->active_ports = 0;
395 adapter->port[i] = port; 444 adapter->port[i] = port;
396 } 445 }
397 446
@@ -412,6 +461,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
412 break; 461 break;
413 } 462 }
414 463
464 adapter->number = netxen_cards_found;
415 adapter->driver_mismatch = 0; 465 adapter->driver_mismatch = 0;
416 466
417 return 0; 467 return 0;
@@ -426,7 +476,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
426 free_netdev(port->netdev); 476 free_netdev(port->netdev);
427 } 477 }
428 } 478 }
429 kfree(adapter->ops); 479
480 netxen_free_adapter_offload(adapter);
430 481
431 err_out_free_rx_buffer: 482 err_out_free_rx_buffer:
432 for (i = 0; i < MAX_RCV_CTX; ++i) { 483 for (i = 0; i < MAX_RCV_CTX; ++i) {
@@ -439,19 +490,23 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
439 } 490 }
440 } 491 }
441 } 492 }
442
443 vfree(cmd_buf_arr); 493 vfree(cmd_buf_arr);
444 494
445 kfree(adapter->port);
446
447 err_out_free_adapter: 495 err_out_free_adapter:
448 pci_set_drvdata(pdev, NULL); 496 pci_set_drvdata(pdev, NULL);
449 kfree(adapter); 497 kfree(adapter);
450 498
499 err_out_dbunmap:
500 if (db_ptr)
501 iounmap(db_ptr);
502
451 err_out_iounmap: 503 err_out_iounmap:
452 iounmap(mem_ptr0); 504 if (mem_ptr0)
453 iounmap(mem_ptr1); 505 iounmap(mem_ptr0);
454 iounmap(mem_ptr2); 506 if (mem_ptr1)
507 iounmap(mem_ptr1);
508 if (mem_ptr2)
509 iounmap(mem_ptr2);
455 510
456 err_out_free_res: 511 err_out_free_res:
457 pci_release_regions(pdev); 512 pci_release_regions(pdev);
@@ -476,12 +531,8 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
476 531
477 netxen_nic_stop_all_ports(adapter); 532 netxen_nic_stop_all_ports(adapter);
478 /* leave the hw in the same state as reboot */ 533 /* leave the hw in the same state as reboot */
479 netxen_pinit_from_rom(adapter, 0);
480 udelay(500);
481 netxen_load_firmware(adapter); 534 netxen_load_firmware(adapter);
482 535 netxen_free_adapter_offload(adapter);
483 if ((adapter->flags & NETXEN_NIC_MSI_ENABLED))
484 netxen_nic_disable_int(adapter);
485 536
486 udelay(500); /* Delay for a while to drain the DMA engines */ 537 udelay(500); /* Delay for a while to drain the DMA engines */
487 for (i = 0; i < adapter->port_count; i++) { 538 for (i = 0; i < adapter->port_count; i++) {
@@ -498,6 +549,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
498 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) 549 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC)
499 netxen_free_hw_resources(adapter); 550 netxen_free_hw_resources(adapter);
500 551
552 iounmap(adapter->ahw.db_base);
501 iounmap(adapter->ahw.pci_base0); 553 iounmap(adapter->ahw.pci_base0);
502 iounmap(adapter->ahw.pci_base1); 554 iounmap(adapter->ahw.pci_base1);
503 iounmap(adapter->ahw.pci_base2); 555 iounmap(adapter->ahw.pci_base2);
@@ -524,7 +576,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
524 } 576 }
525 577
526 vfree(adapter->cmd_buf_arr); 578 vfree(adapter->cmd_buf_arr);
527 kfree(adapter->ops);
528 kfree(adapter); 579 kfree(adapter);
529} 580}
530 581
@@ -546,6 +597,8 @@ static int netxen_nic_open(struct net_device *netdev)
546 return -EIO; 597 return -EIO;
547 } 598 }
548 netxen_nic_flash_print(adapter); 599 netxen_nic_flash_print(adapter);
600 if (adapter->init_niu)
601 adapter->init_niu(adapter);
549 602
550 /* setup all the resources for the Phantom... */ 603 /* setup all the resources for the Phantom... */
551 /* this include the descriptors for rcv, tx, and status */ 604 /* this include the descriptors for rcv, tx, and status */
@@ -556,32 +609,31 @@ static int netxen_nic_open(struct net_device *netdev)
556 err); 609 err);
557 return err; 610 return err;
558 } 611 }
559 if (adapter->ops->init_port 612 if (adapter->init_port
560 && adapter->ops->init_port(adapter, port->portnum) != 0) { 613 && adapter->init_port(adapter, port->portnum) != 0) {
561 printk(KERN_ERR "%s: Failed to initialize port %d\n", 614 printk(KERN_ERR "%s: Failed to initialize port %d\n",
562 netxen_nic_driver_name, port->portnum); 615 netxen_nic_driver_name, port->portnum);
563 netxen_free_hw_resources(adapter); 616 netxen_free_hw_resources(adapter);
564 return -EIO; 617 return -EIO;
565 } 618 }
566 if (adapter->ops->init_niu)
567 adapter->ops->init_niu(adapter);
568 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { 619 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
569 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) 620 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++)
570 netxen_post_rx_buffers(adapter, ctx, ring); 621 netxen_post_rx_buffers(adapter, ctx, ring);
571 } 622 }
572 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; 623 adapter->irq = adapter->ahw.pdev->irq;
573 }
574 adapter->active_ports++;
575 if (adapter->active_ports == 1) {
576 err = request_irq(adapter->ahw.pdev->irq, &netxen_intr, 624 err = request_irq(adapter->ahw.pdev->irq, &netxen_intr,
577 SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, 625 SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name,
578 adapter); 626 adapter);
579 if (err) { 627 if (err) {
580 printk(KERN_ERR "request_irq failed with: %d\n", err); 628 printk(KERN_ERR "request_irq failed with: %d\n", err);
581 adapter->active_ports--; 629 netxen_free_hw_resources(adapter);
582 return err; 630 return err;
583 } 631 }
584 adapter->irq = adapter->ahw.pdev->irq; 632
633 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
634 }
635 adapter->active_ports++;
636 if (adapter->active_ports == 1) {
585 if (!adapter->driver_mismatch) 637 if (!adapter->driver_mismatch)
586 mod_timer(&adapter->watchdog_timer, jiffies); 638 mod_timer(&adapter->watchdog_timer, jiffies);
587 639
@@ -590,11 +642,14 @@ static int netxen_nic_open(struct net_device *netdev)
590 642
591 /* Done here again so that even if phantom sw overwrote it, 643 /* Done here again so that even if phantom sw overwrote it,
592 * we set it */ 644 * we set it */
593 if (adapter->ops->macaddr_set) 645 if (adapter->macaddr_set)
594 adapter->ops->macaddr_set(port, netdev->dev_addr); 646 adapter->macaddr_set(port, netdev->dev_addr);
595 netxen_nic_set_link_parameters(port); 647 netxen_nic_set_link_parameters(port);
596 648
597 netxen_nic_set_multi(netdev); 649 netxen_nic_set_multi(netdev);
650 if (adapter->set_mtu)
651 adapter->set_mtu(port, netdev->mtu);
652
598 if (!adapter->driver_mismatch) 653 if (!adapter->driver_mismatch)
599 netif_start_queue(netdev); 654 netif_start_queue(netdev);
600 655
@@ -647,6 +702,7 @@ static int netxen_nic_close(struct net_device *netdev)
647 } 702 }
648 cmd_buff++; 703 cmd_buff++;
649 } 704 }
705 FLUSH_SCHEDULED_WORK();
650 del_timer_sync(&adapter->watchdog_timer); 706 del_timer_sync(&adapter->watchdog_timer);
651 } 707 }
652 708
@@ -667,7 +723,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
667 struct cmd_desc_type0 *hwdesc; 723 struct cmd_desc_type0 *hwdesc;
668 int k; 724 int k;
669 struct netxen_cmd_buffer *pbuf = NULL; 725 struct netxen_cmd_buffer *pbuf = NULL;
670 unsigned int tries = 0;
671 static int dropped_packet = 0; 726 static int dropped_packet = 0;
672 int frag_count; 727 int frag_count;
673 u32 local_producer = 0; 728 u32 local_producer = 0;
@@ -729,7 +784,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
729 if (((skb->nh.iph)->ihl * sizeof(u32)) + 784 if (((skb->nh.iph)->ihl * sizeof(u32)) +
730 ((skb->h.th)->doff * sizeof(u32)) + 785 ((skb->h.th)->doff * sizeof(u32)) +
731 sizeof(struct ethhdr) > 786 sizeof(struct ethhdr) >
732 (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) { 787 (sizeof(struct cmd_desc_type0) - 2)) {
733 no_of_desc++; 788 no_of_desc++;
734 } 789 }
735 } 790 }
@@ -740,27 +795,17 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
740 if ((k + no_of_desc) >= 795 if ((k + no_of_desc) >=
741 ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count : 796 ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count :
742 last_cmd_consumer)) { 797 last_cmd_consumer)) {
798 port->stats.nocmddescriptor++;
799 DPRINTK(ERR, "No command descriptors available,"
800 " producer = %d, consumer = %d count=%llu,"
801 " dropping packet\n", producer,
802 adapter->last_cmd_consumer,
803 port->stats.nocmddescriptor);
804
805 netif_stop_queue(netdev);
806 port->flags |= NETXEN_NETDEV_STATUS;
743 spin_unlock_bh(&adapter->tx_lock); 807 spin_unlock_bh(&adapter->tx_lock);
744 if (tries == 0) { 808 return NETDEV_TX_BUSY;
745 local_bh_disable();
746 netxen_process_cmd_ring((unsigned long)adapter);
747 local_bh_enable();
748 ++tries;
749 goto retry_getting_window;
750 } else {
751 port->stats.nocmddescriptor++;
752 DPRINTK(ERR, "No command descriptors available,"
753 " producer = %d, consumer = %d count=%llu,"
754 " dropping packet\n", producer,
755 adapter->last_cmd_consumer,
756 port->stats.nocmddescriptor);
757
758 spin_lock_bh(&adapter->tx_lock);
759 netif_stop_queue(netdev);
760 port->flags |= NETXEN_NETDEV_STATUS;
761 spin_unlock_bh(&adapter->tx_lock);
762 return NETDEV_TX_BUSY;
763 }
764 } 809 }
765 k = get_index_range(k, max_tx_desc_count, no_of_desc); 810 k = get_index_range(k, max_tx_desc_count, no_of_desc);
766 adapter->cmd_producer = k; 811 adapter->cmd_producer = k;
@@ -782,7 +827,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
782 pbuf->mss = 0; 827 pbuf->mss = 0;
783 hwdesc->mss = 0; 828 hwdesc->mss = 0;
784 } 829 }
785 pbuf->no_of_descriptors = no_of_desc;
786 pbuf->total_length = skb->len; 830 pbuf->total_length = skb->len;
787 pbuf->skb = skb; 831 pbuf->skb = skb;
788 pbuf->cmd = TX_ETHER_PKT; 832 pbuf->cmd = TX_ETHER_PKT;
@@ -792,11 +836,11 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
792 buffrag->dma = pci_map_single(port->pdev, skb->data, first_seg_len, 836 buffrag->dma = pci_map_single(port->pdev, skb->data, first_seg_len,
793 PCI_DMA_TODEVICE); 837 PCI_DMA_TODEVICE);
794 buffrag->length = first_seg_len; 838 buffrag->length = first_seg_len;
795 CMD_DESC_TOTAL_LENGTH_WRT(hwdesc, skb->len); 839 netxen_set_cmd_desc_totallength(hwdesc, skb->len);
796 hwdesc->num_of_buffers = frag_count; 840 netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count);
797 hwdesc->opcode = TX_ETHER_PKT; 841 netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT);
798 842
799 CMD_DESC_PORT_WRT(hwdesc, port->portnum); 843 netxen_set_cmd_desc_port(hwdesc, port->portnum);
800 hwdesc->buffer1_length = cpu_to_le16(first_seg_len); 844 hwdesc->buffer1_length = cpu_to_le16(first_seg_len);
801 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); 845 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma);
802 846
@@ -855,12 +899,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
855 /* For LSO, we need to copy the MAC/IP/TCP headers into 899 /* For LSO, we need to copy the MAC/IP/TCP headers into
856 * the descriptor ring 900 * the descriptor ring
857 */ 901 */
858 if (hw->cmd_desc_head[saved_producer].opcode == TX_TCP_LSO) { 902 if (netxen_get_cmd_desc_opcode(&hw->cmd_desc_head[saved_producer])
903 == TX_TCP_LSO) {
859 int hdr_len, first_hdr_len, more_hdr; 904 int hdr_len, first_hdr_len, more_hdr;
860 hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length; 905 hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length;
861 if (hdr_len > (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) { 906 if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) {
862 first_hdr_len = 907 first_hdr_len = sizeof(struct cmd_desc_type0) - 2;
863 sizeof(struct cmd_desc_type0) - NET_IP_ALIGN;
864 more_hdr = 1; 908 more_hdr = 1;
865 } else { 909 } else {
866 first_hdr_len = hdr_len; 910 first_hdr_len = hdr_len;
@@ -870,7 +914,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
870 hwdesc = &hw->cmd_desc_head[producer]; 914 hwdesc = &hw->cmd_desc_head[producer];
871 915
872 /* copy the first 64 bytes */ 916 /* copy the first 64 bytes */
873 memcpy(((void *)hwdesc) + NET_IP_ALIGN, 917 memcpy(((void *)hwdesc) + 2,
874 (void *)(skb->data), first_hdr_len); 918 (void *)(skb->data), first_hdr_len);
875 producer = get_next_index(producer, max_tx_desc_count); 919 producer = get_next_index(producer, max_tx_desc_count);
876 920
@@ -886,7 +930,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
886 } 930 }
887 spin_lock_bh(&adapter->tx_lock); 931 spin_lock_bh(&adapter->tx_lock);
888 port->stats.txbytes += 932 port->stats.txbytes +=
889 CMD_DESC_TOTAL_LENGTH(&hw->cmd_desc_head[saved_producer]); 933 netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]);
890 /* Code to update the adapter considering how many producer threads 934 /* Code to update the adapter considering how many producer threads
891 are currently working */ 935 are currently working */
892 if ((--adapter->num_threads) == 0) { 936 if ((--adapter->num_threads) == 0) {
@@ -896,20 +940,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
896 NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET)); 940 NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET));
897 wmb(); 941 wmb();
898 adapter->total_threads = 0; 942 adapter->total_threads = 0;
899 } else {
900 u32 crb_producer = 0;
901 crb_producer =
902 readl(NETXEN_CRB_NORMALIZE
903 (adapter, CRB_CMD_PRODUCER_OFFSET));
904 if (crb_producer == local_producer) {
905 crb_producer = get_index_range(crb_producer,
906 max_tx_desc_count,
907 no_of_desc);
908 writel(crb_producer,
909 NETXEN_CRB_NORMALIZE(adapter,
910 CRB_CMD_PRODUCER_OFFSET));
911 wmb();
912 }
913 } 943 }
914 944
915 port->stats.xmitfinished++; 945 port->stats.xmitfinished++;
@@ -926,15 +956,20 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
926static void netxen_watchdog(unsigned long v) 956static void netxen_watchdog(unsigned long v)
927{ 957{
928 struct netxen_adapter *adapter = (struct netxen_adapter *)v; 958 struct netxen_adapter *adapter = (struct netxen_adapter *)v;
929 schedule_work(&adapter->watchdog_task); 959 if (adapter != g_adapter) {
960 printk("%s: ***BUG*** adapter[%p] != g_adapter[%p]\n",
961 __FUNCTION__, adapter, g_adapter);
962 return;
963 }
964
965 SCHEDULE_WORK(&adapter->watchdog_task);
930} 966}
931 967
932static void netxen_tx_timeout(struct net_device *netdev) 968static void netxen_tx_timeout(struct net_device *netdev)
933{ 969{
934 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev); 970 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev);
935 struct netxen_adapter *adapter = port->adapter;
936 971
937 schedule_work(&adapter->tx_timeout_task); 972 SCHEDULE_WORK(&port->adapter->tx_timeout_task);
938} 973}
939 974
940static void netxen_tx_timeout_task(struct work_struct *work) 975static void netxen_tx_timeout_task(struct work_struct *work)
@@ -967,6 +1002,11 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
967 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 1002 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
968 int count = 0; 1003 int count = 0;
969 u32 mask; 1004 u32 mask;
1005 mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR));
1006 if ((mask & 0x80) == 0) {
1007 /* not our interrupt */
1008 return ret;
1009 }
970 netxen_nic_disable_int(adapter); 1010 netxen_nic_disable_int(adapter);
971 /* Window = 0 or 1 */ 1011 /* Window = 0 or 1 */
972 do { 1012 do {
@@ -1026,7 +1066,10 @@ irqreturn_t netxen_intr(int irq, void *data)
1026 netdev = port->netdev; 1066 netdev = port->netdev;
1027 1067
1028 /* process our status queue (for all 4 ports) */ 1068 /* process our status queue (for all 4 ports) */
1029 netxen_handle_int(adapter, netdev); 1069 if (netif_running(netdev)) {
1070 netxen_handle_int(adapter, netdev);
1071 break;
1072 }
1030 } 1073 }
1031 1074
1032 return IRQ_HANDLED; 1075 return IRQ_HANDLED;
@@ -1040,11 +1083,12 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget)
1040 int done = 1; 1083 int done = 1;
1041 int ctx; 1084 int ctx;
1042 int this_work_done; 1085 int this_work_done;
1086 int work_done = 0;
1043 1087
1044 DPRINTK(INFO, "polling for %d descriptors\n", *budget); 1088 DPRINTK(INFO, "polling for %d descriptors\n", *budget);
1045 port->stats.polled++; 1089 port->stats.polled++;
1046 1090
1047 adapter->work_done = 0; 1091 work_done = 0;
1048 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { 1092 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
1049 /* 1093 /*
1050 * Fairness issue. This will give undue weight to the 1094 * Fairness issue. This will give undue weight to the
@@ -1061,20 +1105,20 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget)
1061 this_work_done = netxen_process_rcv_ring(adapter, ctx, 1105 this_work_done = netxen_process_rcv_ring(adapter, ctx,
1062 work_to_do / 1106 work_to_do /
1063 MAX_RCV_CTX); 1107 MAX_RCV_CTX);
1064 adapter->work_done += this_work_done; 1108 work_done += this_work_done;
1065 } 1109 }
1066 1110
1067 netdev->quota -= adapter->work_done; 1111 netdev->quota -= work_done;
1068 *budget -= adapter->work_done; 1112 *budget -= work_done;
1069 1113
1070 if (adapter->work_done >= work_to_do 1114 if (work_done >= work_to_do && netxen_nic_rx_has_work(adapter) != 0)
1071 && netxen_nic_rx_has_work(adapter) != 0)
1072 done = 0; 1115 done = 0;
1073 1116
1074 netxen_process_cmd_ring((unsigned long)adapter); 1117 if (netxen_process_cmd_ring((unsigned long)adapter) == 0)
1118 done = 0;
1075 1119
1076 DPRINTK(INFO, "new work_done: %d work_to_do: %d\n", 1120 DPRINTK(INFO, "new work_done: %d work_to_do: %d\n",
1077 adapter->work_done, work_to_do); 1121 work_done, work_to_do);
1078 if (done) { 1122 if (done) {
1079 netif_rx_complete(netdev); 1123 netif_rx_complete(netdev);
1080 netxen_nic_enable_int(adapter); 1124 netxen_nic_enable_int(adapter);
@@ -1117,8 +1161,9 @@ netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1117 if (ifr->ifr_data) { 1161 if (ifr->ifr_data) {
1118 sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP, 1162 sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP,
1119 port->portnum); 1163 port->portnum);
1120 nr_bytes = copy_to_user((char *)ifr->ifr_data, dev_name, 1164 nr_bytes =
1121 NETXEN_NIC_NAME_LEN); 1165 copy_to_user((char __user *)ifr->ifr_data, dev_name,
1166 NETXEN_NIC_NAME_LEN);
1122 if (nr_bytes) 1167 if (nr_bytes)
1123 err = -EIO; 1168 err = -EIO;
1124 1169
@@ -1145,6 +1190,9 @@ static struct pci_driver netxen_driver = {
1145 1190
1146static int __init netxen_init_module(void) 1191static int __init netxen_init_module(void)
1147{ 1192{
1193 if ((netxen_workq = create_singlethread_workqueue("netxen")) == 0)
1194 return -ENOMEM;
1195
1148 return pci_module_init(&netxen_driver); 1196 return pci_module_init(&netxen_driver);
1149} 1197}
1150 1198
@@ -1155,7 +1203,7 @@ static void __exit netxen_exit_module(void)
1155 /* 1203 /*
1156 * Wait for some time to allow the dma to drain, if any. 1204 * Wait for some time to allow the dma to drain, if any.
1157 */ 1205 */
1158 mdelay(5); 1206 destroy_workqueue(netxen_workq);
1159 pci_unregister_driver(&netxen_driver); 1207 pci_unregister_driver(&netxen_driver);
1160} 1208}
1161 1209
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c
index 7950a04532e6..4987dc765d99 100644
--- a/drivers/net/netxen/netxen_nic_niu.c
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (C) 2003 - 2006 NetXen, Inc. 2 * Copyright (C) 2003 - 2006 NetXen, Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
@@ -16,10 +16,10 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 * MA 02111-1307, USA. 18 * MA 02111-1307, USA.
19 * 19 *
20 * The full GNU General Public License is included in this distribution 20 * The full GNU General Public License is included in this distribution
21 * in the file called LICENSE. 21 * in the file called LICENSE.
22 * 22 *
23 * Contact Information: 23 * Contact Information:
24 * info@netxen.com 24 * info@netxen.com
25 * NetXen, 25 * NetXen,
@@ -40,13 +40,15 @@
40 40
41static long phy_lock_timeout = 100000000; 41static long phy_lock_timeout = 100000000;
42 42
43static inline int phy_lock(void) 43static inline int phy_lock(struct netxen_adapter *adapter)
44{ 44{
45 int i; 45 int i;
46 int done = 0, timeout = 0; 46 int done = 0, timeout = 0;
47 47
48 while (!done) { 48 while (!done) {
49 done = readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_LOCK)); 49 done =
50 readl(pci_base_offset
51 (adapter, NETXEN_PCIE_REG(PCIE_SEM3_LOCK)));
50 if (done == 1) 52 if (done == 1)
51 break; 53 break;
52 if (timeout >= phy_lock_timeout) { 54 if (timeout >= phy_lock_timeout) {
@@ -61,13 +63,15 @@ static inline int phy_lock(void)
61 } 63 }
62 } 64 }
63 65
64 writel(NETXEN_PHY_LOCK_ID, (void __iomem *)PHY_LOCK_DRIVER); 66 writel(PHY_LOCK_DRIVER,
67 NETXEN_CRB_NORMALIZE(adapter, NETXEN_PHY_LOCK_ID));
65 return 0; 68 return 0;
66} 69}
67 70
68static inline int phy_unlock(void) 71static inline int phy_unlock(struct netxen_adapter *adapter)
69{ 72{
70 readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK)); 73 readl(pci_base_offset(adapter, NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK)));
74
71 return 0; 75 return 0;
72} 76}
73 77
@@ -95,7 +99,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
95 __le32 status; 99 __le32 status;
96 __le32 mac_cfg0; 100 __le32 mac_cfg0;
97 101
98 if (phy_lock() != 0) { 102 if (phy_lock(adapter) != 0) {
99 return -1; 103 return -1;
100 } 104 }
101 105
@@ -162,7 +166,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
162 NETXEN_NIU_GB_MAC_CONFIG_0(0), 166 NETXEN_NIU_GB_MAC_CONFIG_0(0),
163 &mac_cfg0, 4)) 167 &mac_cfg0, 4))
164 return -EIO; 168 return -EIO;
165 phy_unlock(); 169 phy_unlock(adapter);
166 return result; 170 return result;
167} 171}
168 172
@@ -399,8 +403,8 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
399{ 403{
400 int result = 0; 404 int result = 0;
401 __le32 status; 405 __le32 status;
402 if (adapter->ops->disable_phy_interrupts) 406 if (adapter->disable_phy_interrupts)
403 adapter->ops->disable_phy_interrupts(adapter, port); 407 adapter->disable_phy_interrupts(adapter, port);
404 mdelay(2); 408 mdelay(2);
405 409
406 if (0 == 410 if (0 ==
@@ -612,7 +616,7 @@ int netxen_niu_macaddr_set(struct netxen_port *port,
612 __le32 temp = 0; 616 __le32 temp = 0;
613 struct netxen_adapter *adapter = port->adapter; 617 struct netxen_adapter *adapter = port->adapter;
614 int phy = port->portnum; 618 int phy = port->portnum;
615 unsigned char mac_addr[MAX_ADDR_LEN]; 619 unsigned char mac_addr[6];
616 int i; 620 int i;
617 621
618 for (i = 0; i < 10; i++) { 622 for (i = 0; i < 10; i++) {
@@ -631,7 +635,7 @@ int netxen_niu_macaddr_set(struct netxen_port *port,
631 635
632 netxen_niu_macaddr_get(adapter, phy, 636 netxen_niu_macaddr_get(adapter, phy,
633 (netxen_ethernet_macaddr_t *) mac_addr); 637 (netxen_ethernet_macaddr_t *) mac_addr);
634 if (memcmp(mac_addr, addr, MAX_ADDR_LEN == 0)) 638 if (memcmp(mac_addr, addr, 6) == 0)
635 break; 639 break;
636 } 640 }
637 641
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h
index 8181d436783f..7879f855af0b 100644
--- a/drivers/net/netxen/netxen_nic_phan_reg.h
+++ b/drivers/net/netxen/netxen_nic_phan_reg.h
@@ -33,15 +33,74 @@
33/* 33/*
34 * CRB Registers or queue message done only at initialization time. 34 * CRB Registers or queue message done only at initialization time.
35 */ 35 */
36#define NIC_CRB_BASE NETXEN_CAM_RAM(0x200)
37#define NETXEN_NIC_REG(X) (NIC_CRB_BASE+(X))
36 38
37/* 39#define CRB_PHAN_CNTRL_LO_OFFSET NETXEN_NIC_REG(0x00)
38 * The following 2 are the base adresses for the CRB registers and their 40#define CRB_PHAN_CNTRL_HI_OFFSET NETXEN_NIC_REG(0x04)
39 * offsets will be added to get addresses for the index addresses. 41#define CRB_CMD_PRODUCER_OFFSET NETXEN_NIC_REG(0x08)
40 */ 42#define CRB_CMD_CONSUMER_OFFSET NETXEN_NIC_REG(0x0c)
41#define NIC_CRB_BASE_PORT1 NETXEN_CAM_RAM(0x200) 43#define CRB_PAUSE_ADDR_LO NETXEN_NIC_REG(0x10) /* C0 EPG BUG */
42#define NIC_CRB_BASE_PORT2 NETXEN_CAM_RAM(0x250) 44#define CRB_PAUSE_ADDR_HI NETXEN_NIC_REG(0x14)
45#define CRB_HOST_CMD_ADDR_HI NETXEN_NIC_REG(0x18) /* host add:cmd ring */
46#define CRB_HOST_CMD_ADDR_LO NETXEN_NIC_REG(0x1c)
47#define CRB_CMD_INTR_LOOP NETXEN_NIC_REG(0x20) /* 4 regs for perf */
48#define CRB_CMD_DMA_LOOP NETXEN_NIC_REG(0x24)
49#define CRB_RCV_INTR_LOOP NETXEN_NIC_REG(0x28)
50#define CRB_RCV_DMA_LOOP NETXEN_NIC_REG(0x2c)
51#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x30) /* phantom init status */
52#define CRB_MMAP_ADDR_3 NETXEN_NIC_REG(0x34)
53#define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x38)
54#define CRB_HOST_DUMMY_BUF_ADDR_HI NETXEN_NIC_REG(0x3c)
55#define CRB_HOST_DUMMY_BUF_ADDR_LO NETXEN_NIC_REG(0x40)
56#define CRB_MMAP_ADDR_0 NETXEN_NIC_REG(0x44)
57#define CRB_MMAP_ADDR_1 NETXEN_NIC_REG(0x48)
58#define CRB_MMAP_ADDR_2 NETXEN_NIC_REG(0x4c)
59#define CRB_CMDPEG_STATE NETXEN_NIC_REG(0x50)
60#define CRB_MMAP_SIZE_0 NETXEN_NIC_REG(0x54)
61#define CRB_MMAP_SIZE_1 NETXEN_NIC_REG(0x58)
62#define CRB_MMAP_SIZE_2 NETXEN_NIC_REG(0x5c)
63#define CRB_MMAP_SIZE_3 NETXEN_NIC_REG(0x60)
64#define CRB_GLOBAL_INT_COAL NETXEN_NIC_REG(0x64) /* interrupt coalescing */
65#define CRB_INT_COAL_MODE NETXEN_NIC_REG(0x68)
66#define CRB_MAX_RCV_BUFS NETXEN_NIC_REG(0x6c)
67#define CRB_TX_INT_THRESHOLD NETXEN_NIC_REG(0x70)
68#define CRB_RX_PKT_TIMER NETXEN_NIC_REG(0x74)
69#define CRB_TX_PKT_TIMER NETXEN_NIC_REG(0x78)
70#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x7c)
71#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x80)
72#define CRB_RX_LRO_TIMER NETXEN_NIC_REG(0x84)
73#define CRB_RX_LRO_MID_TIMER NETXEN_NIC_REG(0x88)
74#define CRB_DMA_MAX_RCV_BUFS NETXEN_NIC_REG(0x8c)
75#define CRB_MAX_DMA_ENTRIES NETXEN_NIC_REG(0x90)
76#define CRB_XG_STATE NETXEN_NIC_REG(0x94) /* XG Link status */
77#define CRB_AGENT_GO NETXEN_NIC_REG(0x98) /* NIC pkt gen agent */
78#define CRB_AGENT_TX_SIZE NETXEN_NIC_REG(0x9c)
79#define CRB_AGENT_TX_TYPE NETXEN_NIC_REG(0xa0)
80#define CRB_AGENT_TX_ADDR NETXEN_NIC_REG(0xa4)
81#define CRB_AGENT_TX_MSS NETXEN_NIC_REG(0xa8)
82#define CRB_TX_STATE NETXEN_NIC_REG(0xac) /* Debug -performance */
83#define CRB_TX_COUNT NETXEN_NIC_REG(0xb0)
84#define CRB_RX_STATE NETXEN_NIC_REG(0xb4)
85#define CRB_RX_PERF_DEBUG_1 NETXEN_NIC_REG(0xb8)
86#define CRB_RX_LRO_CONTROL NETXEN_NIC_REG(0xbc) /* LRO On/OFF */
87#define CRB_RX_LRO_START_NUM NETXEN_NIC_REG(0xc0)
88#define CRB_MPORT_MODE NETXEN_NIC_REG(0xc4) /* Multiport Mode */
89#define CRB_CMD_RING_SIZE NETXEN_NIC_REG(0xc8)
90#define CRB_INT_VECTOR NETXEN_NIC_REG(0xd4)
91#define CRB_CTX_RESET NETXEN_NIC_REG(0xd8)
92#define CRB_HOST_STS_PROD NETXEN_NIC_REG(0xdc)
93#define CRB_HOST_STS_CONS NETXEN_NIC_REG(0xe0)
94#define CRB_PEG_CMD_PROD NETXEN_NIC_REG(0xe4)
95#define CRB_PEG_CMD_CONS NETXEN_NIC_REG(0xe8)
96#define CRB_HOST_BUFFER_PROD NETXEN_NIC_REG(0xec)
97#define CRB_HOST_BUFFER_CONS NETXEN_NIC_REG(0xf0)
98#define CRB_JUMBO_BUFFER_PROD NETXEN_NIC_REG(0xf4)
99#define CRB_JUMBO_BUFFER_CONS NETXEN_NIC_REG(0xf8)
43 100
44#define NETXEN_NIC_REG(X) (NIC_CRB_BASE_PORT1+(X)) 101#define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac)
102#define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0)
103#define CRB_TEMP_STATE NETXEN_NIC_REG(0x1b4)
45 104
46/* 105/*
47 * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address 106 * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address
@@ -51,74 +110,20 @@
51 * on the Phantom. 110 * on the Phantom.
52 */ 111 */
53 112
54#define CRB_PHAN_CNTRL_LO_OFFSET NETXEN_NIC_REG(0x00) 113#define nx_get_temp_val(x) ((x) >> 16)
55#define CRB_PHAN_CNTRL_HI_OFFSET NETXEN_NIC_REG(0x04) 114#define nx_get_temp_state(x) ((x) & 0xffff)
56 115#define nx_encode_temp(val, state) (((val) << 16) | (state))
57/* point to the indexes */
58#define CRB_CMD_PRODUCER_OFFSET NETXEN_NIC_REG(0x08)
59#define CRB_CMD_CONSUMER_OFFSET NETXEN_NIC_REG(0x0c)
60
61#define CRB_PAUSE_ADDR_LO NETXEN_NIC_REG(0x10)
62#define CRB_PAUSE_ADDR_HI NETXEN_NIC_REG(0x14)
63
64/* address of command descriptors in the host memory */
65#define CRB_HOST_CMD_ADDR_HI NETXEN_NIC_REG(0x30)
66#define CRB_HOST_CMD_ADDR_LO NETXEN_NIC_REG(0x34)
67
68/* The following 4 CRB registers are for doing performance coal */
69#define CRB_CMD_INTR_LOOP NETXEN_NIC_REG(0x38)
70#define CRB_CMD_DMA_LOOP NETXEN_NIC_REG(0x3c)
71#define CRB_RCV_INTR_LOOP NETXEN_NIC_REG(0x40)
72#define CRB_RCV_DMA_LOOP NETXEN_NIC_REG(0x44)
73
74/* Needed by the host to find out the state of Phantom's initialization */
75#define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x4c)
76#define CRB_CMDPEG_STATE NETXEN_NIC_REG(0x50)
77#define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x54)
78
79/* Interrupt coalescing parameters */
80#define CRB_GLOBAL_INT_COAL NETXEN_NIC_REG(0x80)
81#define CRB_INT_COAL_MODE NETXEN_NIC_REG(0x84)
82#define CRB_MAX_RCV_BUFS NETXEN_NIC_REG(0x88)
83#define CRB_TX_INT_THRESHOLD NETXEN_NIC_REG(0x8c)
84#define CRB_RX_PKT_TIMER NETXEN_NIC_REG(0x90)
85#define CRB_TX_PKT_TIMER NETXEN_NIC_REG(0x94)
86#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x98)
87#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x9c)
88#define CRB_INT_THRESH NETXEN_NIC_REG(0xa4)
89
90/* Register for communicating XG link status */
91#define CRB_XG_STATE NETXEN_NIC_REG(0xa0)
92
93/* Register for communicating card temperature */
94/* Upper 16 bits are temperature value. Lower 16 bits are the state */
95#define CRB_TEMP_STATE NETXEN_NIC_REG(0xa8)
96#define nx_get_temp_val(x) ((x) >> 16)
97#define nx_get_temp_state(x) ((x) & 0xffff)
98#define nx_encode_temp(val, state) (((val) << 16) | (state))
99
100/* Debug registers for controlling NIC pkt gen agent */
101#define CRB_AGENT_GO NETXEN_NIC_REG(0xb0)
102#define CRB_AGENT_TX_SIZE NETXEN_NIC_REG(0xb4)
103#define CRB_AGENT_TX_TYPE NETXEN_NIC_REG(0xb8)
104#define CRB_AGENT_TX_ADDR NETXEN_NIC_REG(0xbc)
105#define CRB_AGENT_TX_MSS NETXEN_NIC_REG(0xc0)
106
107/* Debug registers for observing NIC performance */
108#define CRB_TX_STATE NETXEN_NIC_REG(0xd0)
109#define CRB_TX_COUNT NETXEN_NIC_REG(0xd4)
110#define CRB_RX_STATE NETXEN_NIC_REG(0xd8)
111 116
112/* CRB registers per Rcv Descriptor ring */ 117/* CRB registers per Rcv Descriptor ring */
113struct netxen_rcv_desc_crb { 118struct netxen_rcv_desc_crb {
114 u32 crb_rcv_producer_offset __attribute__ ((aligned(512))); 119 u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
115 u32 crb_rcv_consumer_offset; 120 u32 crb_rcv_consumer_offset;
116 u32 crb_globalrcv_ring; 121 u32 crb_globalrcv_ring;
122 u32 crb_rcv_ring_size;
117}; 123};
118 124
119/* 125/*
120 * CRB registers used by the receive peg logic. One instance of these 126 * CRB registers used by the receive peg logic.
121 * needs to be instantiated per instance of the receive peg.
122 */ 127 */
123 128
124struct netxen_recv_crb { 129struct netxen_recv_crb {
@@ -127,6 +132,7 @@ struct netxen_recv_crb {
127 u32 crb_rcv_status_producer; 132 u32 crb_rcv_status_producer;
128 u32 crb_rcv_status_consumer; 133 u32 crb_rcv_status_consumer;
129 u32 crb_rcvpeg_state; 134 u32 crb_rcvpeg_state;
135 u32 crb_status_ring_size;
130}; 136};
131 137
132#if defined(DEFINE_GLOBAL_RECV_CRB) 138#if defined(DEFINE_GLOBAL_RECV_CRB)
@@ -139,30 +145,48 @@ struct netxen_recv_crb recv_crb_registers[] = {
139 { 145 {
140 { 146 {
141 /* crb_rcv_producer_offset: */ 147 /* crb_rcv_producer_offset: */
142 NETXEN_NIC_REG(0x18), 148 NETXEN_NIC_REG(0x100),
143 /* crb_rcv_consumer_offset: */ 149 /* crb_rcv_consumer_offset: */
144 NETXEN_NIC_REG(0x1c), 150 NETXEN_NIC_REG(0x104),
145 /* crb_gloablrcv_ring: */ 151 /* crb_gloablrcv_ring: */
146 NETXEN_NIC_REG(0x20), 152 NETXEN_NIC_REG(0x108),
153 /* crb_rcv_ring_size */
154 NETXEN_NIC_REG(0x10c),
155
147 }, 156 },
148 /* Jumbo frames */ 157 /* Jumbo frames */
149 { 158 {
150 /* crb_rcv_producer_offset: */ 159 /* crb_rcv_producer_offset: */
151 NETXEN_NIC_REG(0x100), 160 NETXEN_NIC_REG(0x110),
152 /* crb_rcv_consumer_offset: */ 161 /* crb_rcv_consumer_offset: */
153 NETXEN_NIC_REG(0x104), 162 NETXEN_NIC_REG(0x114),
154 /* crb_gloablrcv_ring: */ 163 /* crb_gloablrcv_ring: */
155 NETXEN_NIC_REG(0x108), 164 NETXEN_NIC_REG(0x118),
165 /* crb_rcv_ring_size */
166 NETXEN_NIC_REG(0x11c),
167 },
168 /* LRO */
169 {
170 /* crb_rcv_producer_offset: */
171 NETXEN_NIC_REG(0x120),
172 /* crb_rcv_consumer_offset: */
173 NETXEN_NIC_REG(0x124),
174 /* crb_gloablrcv_ring: */
175 NETXEN_NIC_REG(0x128),
176 /* crb_rcv_ring_size */
177 NETXEN_NIC_REG(0x12c),
156 } 178 }
157 }, 179 },
158 /* crb_rcvstatus_ring: */ 180 /* crb_rcvstatus_ring: */
159 NETXEN_NIC_REG(0x24), 181 NETXEN_NIC_REG(0x130),
160 /* crb_rcv_status_producer: */ 182 /* crb_rcv_status_producer: */
161 NETXEN_NIC_REG(0x28), 183 NETXEN_NIC_REG(0x134),
162 /* crb_rcv_status_consumer: */ 184 /* crb_rcv_status_consumer: */
163 NETXEN_NIC_REG(0x2c), 185 NETXEN_NIC_REG(0x138),
164 /* crb_rcvpeg_state: */ 186 /* crb_rcvpeg_state: */
165 NETXEN_NIC_REG(0x48), 187 NETXEN_NIC_REG(0x13c),
188 /* crb_status_ring_size */
189 NETXEN_NIC_REG(0x140),
166 190
167 }, 191 },
168 /* 192 /*
@@ -173,34 +197,66 @@ struct netxen_recv_crb recv_crb_registers[] = {
173 { 197 {
174 { 198 {
175 /* crb_rcv_producer_offset: */ 199 /* crb_rcv_producer_offset: */
176 NETXEN_NIC_REG(0x80), 200 NETXEN_NIC_REG(0x144),
177 /* crb_rcv_consumer_offset: */ 201 /* crb_rcv_consumer_offset: */
178 NETXEN_NIC_REG(0x84), 202 NETXEN_NIC_REG(0x148),
179 /* crb_globalrcv_ring: */ 203 /* crb_globalrcv_ring: */
180 NETXEN_NIC_REG(0x88), 204 NETXEN_NIC_REG(0x14c),
205 /* crb_rcv_ring_size */
206 NETXEN_NIC_REG(0x150),
207
181 }, 208 },
182 /* Jumbo frames */ 209 /* Jumbo frames */
183 { 210 {
184 /* crb_rcv_producer_offset: */ 211 /* crb_rcv_producer_offset: */
185 NETXEN_NIC_REG(0x10C), 212 NETXEN_NIC_REG(0x154),
186 /* crb_rcv_consumer_offset: */ 213 /* crb_rcv_consumer_offset: */
187 NETXEN_NIC_REG(0x110), 214 NETXEN_NIC_REG(0x158),
188 /* crb_globalrcv_ring: */ 215 /* crb_globalrcv_ring: */
189 NETXEN_NIC_REG(0x114), 216 NETXEN_NIC_REG(0x15c),
217 /* crb_rcv_ring_size */
218 NETXEN_NIC_REG(0x160),
219 },
220 /* LRO */
221 {
222 /* crb_rcv_producer_offset: */
223 NETXEN_NIC_REG(0x164),
224 /* crb_rcv_consumer_offset: */
225 NETXEN_NIC_REG(0x168),
226 /* crb_globalrcv_ring: */
227 NETXEN_NIC_REG(0x16c),
228 /* crb_rcv_ring_size */
229 NETXEN_NIC_REG(0x170),
190 } 230 }
231
191 }, 232 },
192 /* crb_rcvstatus_ring: */ 233 /* crb_rcvstatus_ring: */
193 NETXEN_NIC_REG(0x8c), 234 NETXEN_NIC_REG(0x174),
194 /* crb_rcv_status_producer: */ 235 /* crb_rcv_status_producer: */
195 NETXEN_NIC_REG(0x90), 236 NETXEN_NIC_REG(0x178),
196 /* crb_rcv_status_consumer: */ 237 /* crb_rcv_status_consumer: */
197 NETXEN_NIC_REG(0x94), 238 NETXEN_NIC_REG(0x17c),
198 /* crb_rcvpeg_state: */ 239 /* crb_rcvpeg_state: */
199 NETXEN_NIC_REG(0x98), 240 NETXEN_NIC_REG(0x180),
241 /* crb_status_ring_size */
242 NETXEN_NIC_REG(0x184),
243
200 }, 244 },
201}; 245};
246
247u64 ctx_addr_sig_regs[][3] = {
248 {NETXEN_NIC_REG(0x188), NETXEN_NIC_REG(0x18c), NETXEN_NIC_REG(0x1c0)},
249 {NETXEN_NIC_REG(0x190), NETXEN_NIC_REG(0x194), NETXEN_NIC_REG(0x1c4)},
250 {NETXEN_NIC_REG(0x198), NETXEN_NIC_REG(0x19c), NETXEN_NIC_REG(0x1c8)},
251 {NETXEN_NIC_REG(0x1a0), NETXEN_NIC_REG(0x1a4), NETXEN_NIC_REG(0x1cc)}
252};
253
202#else 254#else
203extern struct netxen_recv_crb recv_crb_registers[]; 255extern struct netxen_recv_crb recv_crb_registers[];
256extern u64 ctx_addr_sig_regs[][3];
257#define CRB_CTX_ADDR_REG_LO (ctx_addr_sig_regs[0][0])
258#define CRB_CTX_ADDR_REG_HI (ctx_addr_sig_regs[0][2])
259#define CRB_CTX_SIGNATURE_REG (ctx_addr_sig_regs[0][1])
204#endif /* DEFINE_GLOBAL_RECEIVE_CRB */ 260#endif /* DEFINE_GLOBAL_RECEIVE_CRB */
205 261
206/* 262/*
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c
index 26e42f6e9fb1..196993a29b09 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -1335,7 +1335,7 @@ int __init init_module(void)
1335 return 0; 1335 return 0;
1336} 1336}
1337 1337
1338void cleanup_module(void) 1338void __exit cleanup_module(void)
1339{ 1339{
1340 unregister_netdev(dev_ni52); 1340 unregister_netdev(dev_ni52);
1341 release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE); 1341 release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE);
diff --git a/drivers/net/ni65.c b/drivers/net/ni65.c
index 340ad0d5388a..1578f4d98498 100644
--- a/drivers/net/ni65.c
+++ b/drivers/net/ni65.c
@@ -1259,7 +1259,7 @@ int __init init_module(void)
1259 return IS_ERR(dev_ni65) ? PTR_ERR(dev_ni65) : 0; 1259 return IS_ERR(dev_ni65) ? PTR_ERR(dev_ni65) : 0;
1260} 1260}
1261 1261
1262void cleanup_module(void) 1262void __exit cleanup_module(void)
1263{ 1263{
1264 unregister_netdev(dev_ni65); 1264 unregister_netdev(dev_ni65);
1265 cleanup_card(dev_ni65); 1265 cleanup_card(dev_ni65);
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index 312e0e331712..568daeb3e9d8 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -414,10 +414,10 @@ struct rx_info {
414 414
415 struct sk_buff *skbs[NR_RX_DESC]; 415 struct sk_buff *skbs[NR_RX_DESC];
416 416
417 u32 *next_rx_desc; 417 __le32 *next_rx_desc;
418 u16 next_rx, next_empty; 418 u16 next_rx, next_empty;
419 419
420 u32 *descs; 420 __le32 *descs;
421 dma_addr_t phy_descs; 421 dma_addr_t phy_descs;
422}; 422};
423 423
@@ -460,7 +460,7 @@ struct ns83820 {
460 struct sk_buff *tx_skbs[NR_TX_DESC]; 460 struct sk_buff *tx_skbs[NR_TX_DESC];
461 461
462 char pad[16] __attribute__((aligned(16))); 462 char pad[16] __attribute__((aligned(16)));
463 u32 *tx_descs; 463 __le32 *tx_descs;
464 dma_addr_t tx_phy_descs; 464 dma_addr_t tx_phy_descs;
465 465
466 struct timer_list tx_watchdog; 466 struct timer_list tx_watchdog;
@@ -534,7 +534,7 @@ static void ns83820_vlan_rx_kill_vid(struct net_device *ndev, unsigned short vid
534 * conditions, still route realtime traffic with as low jitter as 534 * conditions, still route realtime traffic with as low jitter as
535 * possible. 535 * possible.
536 */ 536 */
537static inline void build_rx_desc(struct ns83820 *dev, u32 *desc, dma_addr_t link, dma_addr_t buf, u32 cmdsts, u32 extsts) 537static inline void build_rx_desc(struct ns83820 *dev, __le32 *desc, dma_addr_t link, dma_addr_t buf, u32 cmdsts, u32 extsts)
538{ 538{
539 desc_addr_set(desc + DESC_LINK, link); 539 desc_addr_set(desc + DESC_LINK, link);
540 desc_addr_set(desc + DESC_BUFPTR, buf); 540 desc_addr_set(desc + DESC_BUFPTR, buf);
@@ -548,7 +548,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb)
548{ 548{
549 unsigned next_empty; 549 unsigned next_empty;
550 u32 cmdsts; 550 u32 cmdsts;
551 u32 *sg; 551 __le32 *sg;
552 dma_addr_t buf; 552 dma_addr_t buf;
553 553
554 next_empty = dev->rx_info.next_empty; 554 next_empty = dev->rx_info.next_empty;
@@ -875,7 +875,8 @@ static void fastcall rx_irq(struct net_device *ndev)
875 struct rx_info *info = &dev->rx_info; 875 struct rx_info *info = &dev->rx_info;
876 unsigned next_rx; 876 unsigned next_rx;
877 int rx_rc, len; 877 int rx_rc, len;
878 u32 cmdsts, *desc; 878 u32 cmdsts;
879 __le32 *desc;
879 unsigned long flags; 880 unsigned long flags;
880 int nr = 0; 881 int nr = 0;
881 882
@@ -1011,7 +1012,8 @@ static inline void kick_tx(struct ns83820 *dev)
1011static void do_tx_done(struct net_device *ndev) 1012static void do_tx_done(struct net_device *ndev)
1012{ 1013{
1013 struct ns83820 *dev = PRIV(ndev); 1014 struct ns83820 *dev = PRIV(ndev);
1014 u32 cmdsts, tx_done_idx, *desc; 1015 u32 cmdsts, tx_done_idx;
1016 __le32 *desc;
1015 1017
1016 dprintk("do_tx_done(%p)\n", ndev); 1018 dprintk("do_tx_done(%p)\n", ndev);
1017 tx_done_idx = dev->tx_done_idx; 1019 tx_done_idx = dev->tx_done_idx;
@@ -1078,7 +1080,7 @@ static void ns83820_cleanup_tx(struct ns83820 *dev)
1078 struct sk_buff *skb = dev->tx_skbs[i]; 1080 struct sk_buff *skb = dev->tx_skbs[i];
1079 dev->tx_skbs[i] = NULL; 1081 dev->tx_skbs[i] = NULL;
1080 if (skb) { 1082 if (skb) {
1081 u32 *desc = dev->tx_descs + (i * DESC_SIZE); 1083 __le32 *desc = dev->tx_descs + (i * DESC_SIZE);
1082 pci_unmap_single(dev->pci_dev, 1084 pci_unmap_single(dev->pci_dev,
1083 desc_addr_get(desc + DESC_BUFPTR), 1085 desc_addr_get(desc + DESC_BUFPTR),
1084 le32_to_cpu(desc[DESC_CMDSTS]) & CMDSTS_LEN_MASK, 1086 le32_to_cpu(desc[DESC_CMDSTS]) & CMDSTS_LEN_MASK,
@@ -1108,7 +1110,7 @@ static int ns83820_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1108 skb_frag_t *frag; 1110 skb_frag_t *frag;
1109 int stopped = 0; 1111 int stopped = 0;
1110 int do_intr = 0; 1112 int do_intr = 0;
1111 volatile u32 *first_desc; 1113 volatile __le32 *first_desc;
1112 1114
1113 dprintk("ns83820_hard_start_xmit\n"); 1115 dprintk("ns83820_hard_start_xmit\n");
1114 1116
@@ -1181,7 +1183,7 @@ again:
1181 first_desc = dev->tx_descs + (free_idx * DESC_SIZE); 1183 first_desc = dev->tx_descs + (free_idx * DESC_SIZE);
1182 1184
1183 for (;;) { 1185 for (;;) {
1184 volatile u32 *desc = dev->tx_descs + (free_idx * DESC_SIZE); 1186 volatile __le32 *desc = dev->tx_descs + (free_idx * DESC_SIZE);
1185 1187
1186 dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len, 1188 dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len,
1187 (unsigned long long)buf); 1189 (unsigned long long)buf);
@@ -1456,7 +1458,8 @@ static int ns83820_stop(struct net_device *ndev)
1456static void ns83820_tx_timeout(struct net_device *ndev) 1458static void ns83820_tx_timeout(struct net_device *ndev)
1457{ 1459{
1458 struct ns83820 *dev = PRIV(ndev); 1460 struct ns83820 *dev = PRIV(ndev);
1459 u32 tx_done_idx, *desc; 1461 u32 tx_done_idx;
1462 __le32 *desc;
1460 unsigned long flags; 1463 unsigned long flags;
1461 1464
1462 spin_lock_irqsave(&dev->tx_lock, flags); 1465 spin_lock_irqsave(&dev->tx_lock, flags);
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 4044bb1ada86..e175f3910b18 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -587,8 +587,7 @@ int phy_stop_interrupts(struct phy_device *phydev)
587 * Finish any pending work; we might have been scheduled 587 * Finish any pending work; we might have been scheduled
588 * to be called from keventd ourselves, though. 588 * to be called from keventd ourselves, though.
589 */ 589 */
590 if (!current_is_keventd()) 590 run_scheduled_work(&phydev->phy_queue);
591 flush_scheduled_work();
592 591
593 free_irq(phydev->irq, phydev); 592 free_irq(phydev->irq, phydev);
594 593
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 85a392fab5cc..f83b41d4cb0e 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -225,6 +225,7 @@ MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl);
225 225
226static int rx_copybreak = 200; 226static int rx_copybreak = 200;
227static int use_dac; 227static int use_dac;
228static int ignore_parity_err;
228static struct { 229static struct {
229 u32 msg_enable; 230 u32 msg_enable;
230} debug = { -1 }; 231} debug = { -1 };
@@ -470,6 +471,8 @@ module_param(use_dac, int, 0);
470MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); 471MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot.");
471module_param_named(debug, debug.msg_enable, int, 0); 472module_param_named(debug, debug.msg_enable, int, 0);
472MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); 473MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
474module_param_named(ignore_parity_err, ignore_parity_err, bool, 0);
475MODULE_PARM_DESC(ignore_parity_err, "Ignore PCI parity error as target. Default: false");
473MODULE_LICENSE("GPL"); 476MODULE_LICENSE("GPL");
474MODULE_VERSION(RTL8169_VERSION); 477MODULE_VERSION(RTL8169_VERSION);
475 478
@@ -1284,11 +1287,6 @@ static void rtl8169_hw_phy_config(struct net_device *dev)
1284 /* Shazam ! */ 1287 /* Shazam ! */
1285 1288
1286 if (tp->mac_version == RTL_GIGA_MAC_VER_04) { 1289 if (tp->mac_version == RTL_GIGA_MAC_VER_04) {
1287 mdio_write(ioaddr, 31, 0x0001);
1288 mdio_write(ioaddr, 9, 0x273a);
1289 mdio_write(ioaddr, 14, 0x7bfb);
1290 mdio_write(ioaddr, 27, 0x841e);
1291
1292 mdio_write(ioaddr, 31, 0x0002); 1290 mdio_write(ioaddr, 31, 0x0002);
1293 mdio_write(ioaddr, 1, 0x90d0); 1291 mdio_write(ioaddr, 1, 0x90d0);
1294 mdio_write(ioaddr, 31, 0x0000); 1292 mdio_write(ioaddr, 31, 0x0000);
@@ -1817,12 +1815,25 @@ static void rtl8169_hw_reset(void __iomem *ioaddr)
1817 RTL_R8(ChipCmd); 1815 RTL_R8(ChipCmd);
1818} 1816}
1819 1817
1820static void 1818static void rtl8169_set_rx_tx_config_registers(struct rtl8169_private *tp)
1821rtl8169_hw_start(struct net_device *dev) 1819{
1820 void __iomem *ioaddr = tp->mmio_addr;
1821 u32 cfg = rtl8169_rx_config;
1822
1823 cfg |= (RTL_R32(RxConfig) & rtl_chip_info[tp->chipset].RxConfigMask);
1824 RTL_W32(RxConfig, cfg);
1825
1826 /* Set DMA burst size and Interframe Gap Time */
1827 RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) |
1828 (InterFrameGap << TxInterFrameGapShift));
1829}
1830
1831static void rtl8169_hw_start(struct net_device *dev)
1822{ 1832{
1823 struct rtl8169_private *tp = netdev_priv(dev); 1833 struct rtl8169_private *tp = netdev_priv(dev);
1824 void __iomem *ioaddr = tp->mmio_addr; 1834 void __iomem *ioaddr = tp->mmio_addr;
1825 struct pci_dev *pdev = tp->pci_dev; 1835 struct pci_dev *pdev = tp->pci_dev;
1836 u16 cmd;
1826 u32 i; 1837 u32 i;
1827 1838
1828 /* Soft reset the chip. */ 1839 /* Soft reset the chip. */
@@ -1835,6 +1846,11 @@ rtl8169_hw_start(struct net_device *dev)
1835 msleep_interruptible(1); 1846 msleep_interruptible(1);
1836 } 1847 }
1837 1848
1849 if (tp->mac_version == RTL_GIGA_MAC_VER_05) {
1850 RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | PCIMulRW);
1851 pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x08);
1852 }
1853
1838 if (tp->mac_version == RTL_GIGA_MAC_VER_13) { 1854 if (tp->mac_version == RTL_GIGA_MAC_VER_13) {
1839 pci_write_config_word(pdev, 0x68, 0x00); 1855 pci_write_config_word(pdev, 0x68, 0x00);
1840 pci_write_config_word(pdev, 0x69, 0x08); 1856 pci_write_config_word(pdev, 0x69, 0x08);
@@ -1842,8 +1858,6 @@ rtl8169_hw_start(struct net_device *dev)
1842 1858
1843 /* Undocumented stuff. */ 1859 /* Undocumented stuff. */
1844 if (tp->mac_version == RTL_GIGA_MAC_VER_05) { 1860 if (tp->mac_version == RTL_GIGA_MAC_VER_05) {
1845 u16 cmd;
1846
1847 /* Realtek's r1000_n.c driver uses '&& 0x01' here. Well... */ 1861 /* Realtek's r1000_n.c driver uses '&& 0x01' here. Well... */
1848 if ((RTL_R8(Config2) & 0x07) & 0x01) 1862 if ((RTL_R8(Config2) & 0x07) & 0x01)
1849 RTL_W32(0x7c, 0x0007ffff); 1863 RTL_W32(0x7c, 0x0007ffff);
@@ -1855,23 +1869,29 @@ rtl8169_hw_start(struct net_device *dev)
1855 pci_write_config_word(pdev, PCI_COMMAND, cmd); 1869 pci_write_config_word(pdev, PCI_COMMAND, cmd);
1856 } 1870 }
1857 1871
1858
1859 RTL_W8(Cfg9346, Cfg9346_Unlock); 1872 RTL_W8(Cfg9346, Cfg9346_Unlock);
1873 if ((tp->mac_version == RTL_GIGA_MAC_VER_01) ||
1874 (tp->mac_version == RTL_GIGA_MAC_VER_02) ||
1875 (tp->mac_version == RTL_GIGA_MAC_VER_03) ||
1876 (tp->mac_version == RTL_GIGA_MAC_VER_04))
1877 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
1878
1860 RTL_W8(EarlyTxThres, EarlyTxThld); 1879 RTL_W8(EarlyTxThres, EarlyTxThld);
1861 1880
1862 /* Low hurts. Let's disable the filtering. */ 1881 /* Low hurts. Let's disable the filtering. */
1863 RTL_W16(RxMaxSize, 16383); 1882 RTL_W16(RxMaxSize, 16383);
1864 1883
1865 /* Set Rx Config register */ 1884 if ((tp->mac_version == RTL_GIGA_MAC_VER_01) ||
1866 i = rtl8169_rx_config | 1885 (tp->mac_version == RTL_GIGA_MAC_VER_02) ||
1867 (RTL_R32(RxConfig) & rtl_chip_info[tp->chipset].RxConfigMask); 1886 (tp->mac_version == RTL_GIGA_MAC_VER_03) ||
1868 RTL_W32(RxConfig, i); 1887 (tp->mac_version == RTL_GIGA_MAC_VER_04))
1888 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
1889 rtl8169_set_rx_tx_config_registers(tp);
1869 1890
1870 /* Set DMA burst size and Interframe Gap Time */ 1891 cmd = RTL_R16(CPlusCmd);
1871 RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) | 1892 RTL_W16(CPlusCmd, cmd);
1872 (InterFrameGap << TxInterFrameGapShift));
1873 1893
1874 tp->cp_cmd |= RTL_R16(CPlusCmd) | PCIMulRW; 1894 tp->cp_cmd |= cmd | PCIMulRW;
1875 1895
1876 if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || 1896 if ((tp->mac_version == RTL_GIGA_MAC_VER_02) ||
1877 (tp->mac_version == RTL_GIGA_MAC_VER_03)) { 1897 (tp->mac_version == RTL_GIGA_MAC_VER_03)) {
@@ -1897,7 +1917,15 @@ rtl8169_hw_start(struct net_device *dev)
1897 RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr & DMA_32BIT_MASK)); 1917 RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr & DMA_32BIT_MASK));
1898 RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr >> 32)); 1918 RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr >> 32));
1899 RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr & DMA_32BIT_MASK)); 1919 RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr & DMA_32BIT_MASK));
1900 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); 1920
1921 if ((tp->mac_version != RTL_GIGA_MAC_VER_01) &&
1922 (tp->mac_version != RTL_GIGA_MAC_VER_02) &&
1923 (tp->mac_version != RTL_GIGA_MAC_VER_03) &&
1924 (tp->mac_version != RTL_GIGA_MAC_VER_04)) {
1925 RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
1926 rtl8169_set_rx_tx_config_registers(tp);
1927 }
1928
1901 RTL_W8(Cfg9346, Cfg9346_Lock); 1929 RTL_W8(Cfg9346, Cfg9346_Lock);
1902 1930
1903 /* Initially a 10 us delay. Turned it into a PCI commit. - FR */ 1931 /* Initially a 10 us delay. Turned it into a PCI commit. - FR */
@@ -1992,7 +2020,7 @@ static int rtl8169_alloc_rx_skb(struct pci_dev *pdev, struct sk_buff **sk_buff,
1992 if (!skb) 2020 if (!skb)
1993 goto err_out; 2021 goto err_out;
1994 2022
1995 skb_reserve(skb, align); 2023 skb_reserve(skb, (align - 1) & (u32)skb->data);
1996 *sk_buff = skb; 2024 *sk_buff = skb;
1997 2025
1998 mapping = pci_map_single(pdev, skb->data, rx_buf_sz, 2026 mapping = pci_map_single(pdev, skb->data, rx_buf_sz,
@@ -2355,12 +2383,17 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
2355 /* 2383 /*
2356 * The recovery sequence below admits a very elaborated explanation: 2384 * The recovery sequence below admits a very elaborated explanation:
2357 * - it seems to work; 2385 * - it seems to work;
2358 * - I did not see what else could be done. 2386 * - I did not see what else could be done;
2387 * - it makes iop3xx happy.
2359 * 2388 *
2360 * Feel free to adjust to your needs. 2389 * Feel free to adjust to your needs.
2361 */ 2390 */
2362 pci_write_config_word(pdev, PCI_COMMAND, 2391 if (ignore_parity_err)
2363 pci_cmd | PCI_COMMAND_SERR | PCI_COMMAND_PARITY); 2392 pci_cmd &= ~PCI_COMMAND_PARITY;
2393 else
2394 pci_cmd |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY;
2395
2396 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
2364 2397
2365 pci_write_config_word(pdev, PCI_STATUS, 2398 pci_write_config_word(pdev, PCI_STATUS,
2366 pci_status & (PCI_STATUS_DETECTED_PARITY | 2399 pci_status & (PCI_STATUS_DETECTED_PARITY |
@@ -2374,10 +2407,11 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
2374 tp->cp_cmd &= ~PCIDAC; 2407 tp->cp_cmd &= ~PCIDAC;
2375 RTL_W16(CPlusCmd, tp->cp_cmd); 2408 RTL_W16(CPlusCmd, tp->cp_cmd);
2376 dev->features &= ~NETIF_F_HIGHDMA; 2409 dev->features &= ~NETIF_F_HIGHDMA;
2377 rtl8169_schedule_work(dev, rtl8169_reinit_task);
2378 } 2410 }
2379 2411
2380 rtl8169_hw_reset(ioaddr); 2412 rtl8169_hw_reset(ioaddr);
2413
2414 rtl8169_schedule_work(dev, rtl8169_reinit_task);
2381} 2415}
2382 2416
2383static void 2417static void
@@ -2457,7 +2491,7 @@ static inline int rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size,
2457 2491
2458 skb = dev_alloc_skb(pkt_size + align); 2492 skb = dev_alloc_skb(pkt_size + align);
2459 if (skb) { 2493 if (skb) {
2460 skb_reserve(skb, align); 2494 skb_reserve(skb, (align - 1) & (u32)skb->data);
2461 eth_copy_and_sum(skb, sk_buff[0]->data, pkt_size, 0); 2495 eth_copy_and_sum(skb, sk_buff[0]->data, pkt_size, 0);
2462 *sk_buff = skb; 2496 *sk_buff = skb;
2463 rtl8169_mark_to_asic(desc, rx_buf_sz); 2497 rtl8169_mark_to_asic(desc, rx_buf_sz);
diff --git a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c
index d9d0a3a3c558..0d6c95c7aedf 100644
--- a/drivers/net/seeq8005.c
+++ b/drivers/net/seeq8005.c
@@ -750,7 +750,7 @@ int __init init_module(void)
750 return 0; 750 return 0;
751} 751}
752 752
753void cleanup_module(void) 753void __exit cleanup_module(void)
754{ 754{
755 unregister_netdev(dev_seeq); 755 unregister_netdev(dev_seeq);
756 release_region(dev_seeq->base_addr, SEEQ8005_IO_EXTENT); 756 release_region(dev_seeq->base_addr, SEEQ8005_IO_EXTENT);
diff --git a/drivers/net/sk98lin/skgesirq.c b/drivers/net/sk98lin/skgesirq.c
index ab66d80a4455..3e7aa49afd00 100644
--- a/drivers/net/sk98lin/skgesirq.c
+++ b/drivers/net/sk98lin/skgesirq.c
@@ -1319,7 +1319,7 @@ SK_BOOL AutoNeg) /* Is Auto-negotiation used ? */
1319 SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &Isrc); 1319 SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &Isrc);
1320 1320
1321#ifdef xDEBUG 1321#ifdef xDEBUG
1322 if ((Isrc & ~(PHY_B_IS_HCT | PHY_B_IS_LCT) == 1322 if ((Isrc & ~(PHY_B_IS_HCT | PHY_B_IS_LCT)) ==
1323 (PHY_B_IS_SCR_S_ER | PHY_B_IS_RRS_CHANGE | PHY_B_IS_LRS_CHANGE)) { 1323 (PHY_B_IS_SCR_S_ER | PHY_B_IS_RRS_CHANGE | PHY_B_IS_LRS_CHANGE)) {
1324 1324
1325 SK_U32 Stat1, Stat2, Stat3; 1325 SK_U32 Stat1, Stat2, Stat3;
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 23e5275d920c..f6223c533c01 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -389,10 +389,10 @@ enum {
389/* Packet Arbiter Registers */ 389/* Packet Arbiter Registers */
390/* B3_PA_CTRL 16 bit Packet Arbiter Ctrl Register */ 390/* B3_PA_CTRL 16 bit Packet Arbiter Ctrl Register */
391enum { 391enum {
392 PA_CLR_TO_TX2 = 1<<13, /* Clear IRQ Packet Timeout TX2 */ 392 PA_CLR_TO_TX2 = 1<<13,/* Clear IRQ Packet Timeout TX2 */
393 PA_CLR_TO_TX1 = 1<<12, /* Clear IRQ Packet Timeout TX1 */ 393 PA_CLR_TO_TX1 = 1<<12,/* Clear IRQ Packet Timeout TX1 */
394 PA_CLR_TO_RX2 = 1<<11, /* Clear IRQ Packet Timeout RX2 */ 394 PA_CLR_TO_RX2 = 1<<11,/* Clear IRQ Packet Timeout RX2 */
395 PA_CLR_TO_RX1 = 1<<10, /* Clear IRQ Packet Timeout RX1 */ 395 PA_CLR_TO_RX1 = 1<<10,/* Clear IRQ Packet Timeout RX1 */
396 PA_ENA_TO_TX2 = 1<<9, /* Enable Timeout Timer TX2 */ 396 PA_ENA_TO_TX2 = 1<<9, /* Enable Timeout Timer TX2 */
397 PA_DIS_TO_TX2 = 1<<8, /* Disable Timeout Timer TX2 */ 397 PA_DIS_TO_TX2 = 1<<8, /* Disable Timeout Timer TX2 */
398 PA_ENA_TO_TX1 = 1<<7, /* Enable Timeout Timer TX1 */ 398 PA_ENA_TO_TX1 = 1<<7, /* Enable Timeout Timer TX1 */
@@ -481,14 +481,14 @@ enum {
481/* RAM Buffer Register Offsets */ 481/* RAM Buffer Register Offsets */
482enum { 482enum {
483 483
484 RB_START = 0x00,/* 32 bit RAM Buffer Start Address */ 484 RB_START= 0x00,/* 32 bit RAM Buffer Start Address */
485 RB_END = 0x04,/* 32 bit RAM Buffer End Address */ 485 RB_END = 0x04,/* 32 bit RAM Buffer End Address */
486 RB_WP = 0x08,/* 32 bit RAM Buffer Write Pointer */ 486 RB_WP = 0x08,/* 32 bit RAM Buffer Write Pointer */
487 RB_RP = 0x0c,/* 32 bit RAM Buffer Read Pointer */ 487 RB_RP = 0x0c,/* 32 bit RAM Buffer Read Pointer */
488 RB_RX_UTPP = 0x10,/* 32 bit Rx Upper Threshold, Pause Packet */ 488 RB_RX_UTPP= 0x10,/* 32 bit Rx Upper Threshold, Pause Packet */
489 RB_RX_LTPP = 0x14,/* 32 bit Rx Lower Threshold, Pause Packet */ 489 RB_RX_LTPP= 0x14,/* 32 bit Rx Lower Threshold, Pause Packet */
490 RB_RX_UTHP = 0x18,/* 32 bit Rx Upper Threshold, High Prio */ 490 RB_RX_UTHP= 0x18,/* 32 bit Rx Upper Threshold, High Prio */
491 RB_RX_LTHP = 0x1c,/* 32 bit Rx Lower Threshold, High Prio */ 491 RB_RX_LTHP= 0x1c,/* 32 bit Rx Lower Threshold, High Prio */
492 /* 0x10 - 0x1f: reserved at Tx RAM Buffer Registers */ 492 /* 0x10 - 0x1f: reserved at Tx RAM Buffer Registers */
493 RB_PC = 0x20,/* 32 bit RAM Buffer Packet Counter */ 493 RB_PC = 0x20,/* 32 bit RAM Buffer Packet Counter */
494 RB_LEV = 0x24,/* 32 bit RAM Buffer Level Register */ 494 RB_LEV = 0x24,/* 32 bit RAM Buffer Level Register */
@@ -532,7 +532,7 @@ enum {
532 PHY_ADDR_MARV = 0, 532 PHY_ADDR_MARV = 0,
533}; 533};
534 534
535#define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs)) 535#define RB_ADDR(offs, queue) ((u16)B16_RAM_REGS + (u16)(queue) + (offs))
536 536
537/* Receive MAC FIFO, Receive LED, and Link_Sync regs (GENESIS only) */ 537/* Receive MAC FIFO, Receive LED, and Link_Sync regs (GENESIS only) */
538enum { 538enum {
@@ -578,15 +578,15 @@ enum {
578 MFF_DIS_TIST = 1<<2, /* Disable Time Stamp Gener */ 578 MFF_DIS_TIST = 1<<2, /* Disable Time Stamp Gener */
579 MFF_CLR_INTIST = 1<<1, /* Clear IRQ No Time Stamp */ 579 MFF_CLR_INTIST = 1<<1, /* Clear IRQ No Time Stamp */
580 MFF_CLR_INSTAT = 1<<0, /* Clear IRQ No Status */ 580 MFF_CLR_INSTAT = 1<<0, /* Clear IRQ No Status */
581#define MFF_RX_CTRL_DEF MFF_ENA_TIM_PAT 581 MFF_RX_CTRL_DEF = MFF_ENA_TIM_PAT,
582}; 582};
583 583
584/* TX_MFF_CTRL1 16 bit Transmit MAC FIFO Control Reg 1 */ 584/* TX_MFF_CTRL1 16 bit Transmit MAC FIFO Control Reg 1 */
585enum { 585enum {
586 MFF_CLR_PERR = 1<<15, /* Clear Parity Error IRQ */ 586 MFF_CLR_PERR = 1<<15, /* Clear Parity Error IRQ */
587 /* Bit 14: reserved */ 587
588 MFF_ENA_PKT_REC = 1<<13, /* Enable Packet Recovery */ 588 MFF_ENA_PKT_REC = 1<<13, /* Enable Packet Recovery */
589 MFF_DIS_PKT_REC = 1<<12, /* Disable Packet Recovery */ 589 MFF_DIS_PKT_REC = 1<<12, /* Disable Packet Recovery */
590 590
591 MFF_ENA_W4E = 1<<7, /* Enable Wait for Empty */ 591 MFF_ENA_W4E = 1<<7, /* Enable Wait for Empty */
592 MFF_DIS_W4E = 1<<6, /* Disable Wait for Empty */ 592 MFF_DIS_W4E = 1<<6, /* Disable Wait for Empty */
@@ -595,9 +595,10 @@ enum {
595 MFF_DIS_LOOPB = 1<<2, /* Disable Loopback */ 595 MFF_DIS_LOOPB = 1<<2, /* Disable Loopback */
596 MFF_CLR_MAC_RST = 1<<1, /* Clear XMAC Reset */ 596 MFF_CLR_MAC_RST = 1<<1, /* Clear XMAC Reset */
597 MFF_SET_MAC_RST = 1<<0, /* Set XMAC Reset */ 597 MFF_SET_MAC_RST = 1<<0, /* Set XMAC Reset */
598
599 MFF_TX_CTRL_DEF = MFF_ENA_PKT_REC | (u16) MFF_ENA_TIM_PAT | MFF_ENA_FLUSH,
598}; 600};
599 601
600#define MFF_TX_CTRL_DEF (MFF_ENA_PKT_REC | MFF_ENA_TIM_PAT | MFF_ENA_FLUSH)
601 602
602/* RX_MFF_TST2 8 bit Receive MAC FIFO Test Register 2 */ 603/* RX_MFF_TST2 8 bit Receive MAC FIFO Test Register 2 */
603/* TX_MFF_TST2 8 bit Transmit MAC FIFO Test Register 2 */ 604/* TX_MFF_TST2 8 bit Transmit MAC FIFO Test Register 2 */
@@ -1304,8 +1305,8 @@ enum {
1304 1305
1305/* special defines for FIBER (88E1011S only) */ 1306/* special defines for FIBER (88E1011S only) */
1306enum { 1307enum {
1307 PHY_M_AN_ASP_X = 1<<8, /* Asymmetric Pause */ 1308 PHY_M_AN_ASP_X = 1<<8, /* Asymmetric Pause */
1308 PHY_M_AN_PC_X = 1<<7, /* MAC Pause implemented */ 1309 PHY_M_AN_PC_X = 1<<7, /* MAC Pause implemented */
1309 PHY_M_AN_1000X_AHD = 1<<6, /* Advertise 10000Base-X Half Duplex */ 1310 PHY_M_AN_1000X_AHD = 1<<6, /* Advertise 10000Base-X Half Duplex */
1310 PHY_M_AN_1000X_AFD = 1<<5, /* Advertise 10000Base-X Full Duplex */ 1311 PHY_M_AN_1000X_AFD = 1<<5, /* Advertise 10000Base-X Full Duplex */
1311}; 1312};
@@ -1320,7 +1321,7 @@ enum {
1320 1321
1321/***** PHY_MARV_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/ 1322/***** PHY_MARV_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/
1322enum { 1323enum {
1323 PHY_M_1000C_TEST = 7<<13,/* Bit 15..13: Test Modes */ 1324 PHY_M_1000C_TEST= 7<<13,/* Bit 15..13: Test Modes */
1324 PHY_M_1000C_MSE = 1<<12, /* Manual Master/Slave Enable */ 1325 PHY_M_1000C_MSE = 1<<12, /* Manual Master/Slave Enable */
1325 PHY_M_1000C_MSC = 1<<11, /* M/S Configuration (1=Master) */ 1326 PHY_M_1000C_MSC = 1<<11, /* M/S Configuration (1=Master) */
1326 PHY_M_1000C_MPD = 1<<10, /* Multi-Port Device */ 1327 PHY_M_1000C_MPD = 1<<10, /* Multi-Port Device */
@@ -1349,7 +1350,7 @@ enum {
1349 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ 1350 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */
1350}; 1351};
1351 1352
1352#define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK) 1353#define PHY_M_PC_MDI_XMODE(x) ((((u16)(x)<<5) & PHY_M_PC_MDIX_MSK)
1353 1354
1354enum { 1355enum {
1355 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ 1356 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */
@@ -1432,24 +1433,24 @@ enum {
1432 PHY_M_EC_DIS_LINK_P = 1<<12, /* Disable Link Pulses (88E1111 only) */ 1433 PHY_M_EC_DIS_LINK_P = 1<<12, /* Disable Link Pulses (88E1111 only) */
1433 PHY_M_EC_M_DSC_MSK = 3<<10, /* Bit 11..10: Master Downshift Counter */ 1434 PHY_M_EC_M_DSC_MSK = 3<<10, /* Bit 11..10: Master Downshift Counter */
1434 /* (88E1011 only) */ 1435 /* (88E1011 only) */
1435 PHY_M_EC_S_DSC_MSK = 3<<8,/* Bit 9.. 8: Slave Downshift Counter */ 1436 PHY_M_EC_S_DSC_MSK = 3<<8, /* Bit 9.. 8: Slave Downshift Counter */
1436 /* (88E1011 only) */ 1437 /* (88E1011 only) */
1437 PHY_M_EC_M_DSC_MSK2 = 7<<9,/* Bit 11.. 9: Master Downshift Counter */ 1438 PHY_M_EC_M_DSC_MSK2 = 7<<9, /* Bit 11.. 9: Master Downshift Counter */
1438 /* (88E1111 only) */ 1439 /* (88E1111 only) */
1439 PHY_M_EC_DOWN_S_ENA = 1<<8, /* Downshift Enable (88E1111 only) */ 1440 PHY_M_EC_DOWN_S_ENA = 1<<8, /* Downshift Enable (88E1111 only) */
1440 /* !!! Errata in spec. (1 = disable) */ 1441 /* !!! Errata in spec. (1 = disable) */
1441 PHY_M_EC_RX_TIM_CT = 1<<7, /* RGMII Rx Timing Control*/ 1442 PHY_M_EC_RX_TIM_CT = 1<<7, /* RGMII Rx Timing Control*/
1442 PHY_M_EC_MAC_S_MSK = 7<<4,/* Bit 6.. 4: Def. MAC interface speed */ 1443 PHY_M_EC_MAC_S_MSK = 7<<4, /* Bit 6.. 4: Def. MAC interface speed */
1443 PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */ 1444 PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */
1444 PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */ 1445 PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */
1445 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ 1446 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */
1446 PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; 1447 PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */};
1447 1448
1448#define PHY_M_EC_M_DSC(x) ((x)<<10) /* 00=1x; 01=2x; 10=3x; 11=4x */ 1449#define PHY_M_EC_M_DSC(x) ((u16)(x)<<10) /* 00=1x; 01=2x; 10=3x; 11=4x */
1449#define PHY_M_EC_S_DSC(x) ((x)<<8) /* 00=dis; 01=1x; 10=2x; 11=3x */ 1450#define PHY_M_EC_S_DSC(x) ((u16)(x)<<8) /* 00=dis; 01=1x; 10=2x; 11=3x */
1450#define PHY_M_EC_MAC_S(x) ((x)<<4) /* 01X=0; 110=2.5; 111=25 (MHz) */ 1451#define PHY_M_EC_MAC_S(x) ((u16)(x)<<4) /* 01X=0; 110=2.5; 111=25 (MHz) */
1451 1452
1452#define PHY_M_EC_M_DSC_2(x) ((x)<<9) /* 000=1x; 001=2x; 010=3x; 011=4x */ 1453#define PHY_M_EC_M_DSC_2(x) ((u16)(x)<<9) /* 000=1x; 001=2x; 010=3x; 011=4x */
1453 /* 100=5x; 101=6x; 110=7x; 111=8x */ 1454 /* 100=5x; 101=6x; 110=7x; 111=8x */
1454enum { 1455enum {
1455 MAC_TX_CLK_0_MHZ = 2, 1456 MAC_TX_CLK_0_MHZ = 2,
@@ -1468,10 +1469,12 @@ enum {
1468 PHY_M_LEDC_LK_C_MSK = 7<<3,/* Bit 5.. 3: Link Control Mask */ 1469 PHY_M_LEDC_LK_C_MSK = 7<<3,/* Bit 5.. 3: Link Control Mask */
1469 /* (88E1111 only) */ 1470 /* (88E1111 only) */
1470}; 1471};
1472#define PHY_M_LED_PULS_DUR(x) (((u16)(x)<<12) & PHY_M_LEDC_PULS_MSK)
1473#define PHY_M_LED_BLINK_RT(x) (((u16)(x)<<8) & PHY_M_LEDC_BL_R_MSK)
1471 1474
1472enum { 1475enum {
1473 PHY_M_LEDC_LINK_MSK = 3<<3,/* Bit 4.. 3: Link Control Mask */ 1476 PHY_M_LEDC_LINK_MSK = 3<<3, /* Bit 4.. 3: Link Control Mask */
1474 /* (88E1011 only) */ 1477 /* (88E1011 only) */
1475 PHY_M_LEDC_DP_CTRL = 1<<2, /* Duplex Control */ 1478 PHY_M_LEDC_DP_CTRL = 1<<2, /* Duplex Control */
1476 PHY_M_LEDC_DP_C_MSB = 1<<2, /* Duplex Control (MSB, 88E1111 only) */ 1479 PHY_M_LEDC_DP_C_MSB = 1<<2, /* Duplex Control (MSB, 88E1111 only) */
1477 PHY_M_LEDC_RX_CTRL = 1<<1, /* Rx Activity / Link */ 1480 PHY_M_LEDC_RX_CTRL = 1<<1, /* Rx Activity / Link */
@@ -1479,27 +1482,24 @@ enum {
1479 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ 1482 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */
1480}; 1483};
1481 1484
1482#define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK)
1483
1484enum { 1485enum {
1485 PULS_NO_STR = 0,/* no pulse stretching */ 1486 PULS_NO_STR = 0, /* no pulse stretching */
1486 PULS_21MS = 1,/* 21 ms to 42 ms */ 1487 PULS_21MS = 1, /* 21 ms to 42 ms */
1487 PULS_42MS = 2,/* 42 ms to 84 ms */ 1488 PULS_42MS = 2, /* 42 ms to 84 ms */
1488 PULS_84MS = 3,/* 84 ms to 170 ms */ 1489 PULS_84MS = 3, /* 84 ms to 170 ms */
1489 PULS_170MS = 4,/* 170 ms to 340 ms */ 1490 PULS_170MS = 4, /* 170 ms to 340 ms */
1490 PULS_340MS = 5,/* 340 ms to 670 ms */ 1491 PULS_340MS = 5, /* 340 ms to 670 ms */
1491 PULS_670MS = 6,/* 670 ms to 1.3 s */ 1492 PULS_670MS = 6, /* 670 ms to 1.3 s */
1492 PULS_1300MS = 7,/* 1.3 s to 2.7 s */ 1493 PULS_1300MS = 7, /* 1.3 s to 2.7 s */
1493}; 1494};
1494 1495
1495#define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK)
1496 1496
1497enum { 1497enum {
1498 BLINK_42MS = 0,/* 42 ms */ 1498 BLINK_42MS = 0, /* 42 ms */
1499 BLINK_84MS = 1,/* 84 ms */ 1499 BLINK_84MS = 1, /* 84 ms */
1500 BLINK_170MS = 2,/* 170 ms */ 1500 BLINK_170MS = 2, /* 170 ms */
1501 BLINK_340MS = 3,/* 340 ms */ 1501 BLINK_340MS = 3, /* 340 ms */
1502 BLINK_670MS = 4,/* 670 ms */ 1502 BLINK_670MS = 4, /* 670 ms */
1503}; 1503};
1504 1504
1505/***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/ 1505/***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/
@@ -1525,7 +1525,7 @@ enum {
1525 PHY_M_EC2_FO_IMPED = 1<<5, /* Fiber Output Impedance */ 1525 PHY_M_EC2_FO_IMPED = 1<<5, /* Fiber Output Impedance */
1526 PHY_M_EC2_FO_M_CLK = 1<<4, /* Fiber Mode Clock Enable */ 1526 PHY_M_EC2_FO_M_CLK = 1<<4, /* Fiber Mode Clock Enable */
1527 PHY_M_EC2_FO_BOOST = 1<<3, /* Fiber Output Boost */ 1527 PHY_M_EC2_FO_BOOST = 1<<3, /* Fiber Output Boost */
1528 PHY_M_EC2_FO_AM_MSK = 7,/* Bit 2.. 0: Fiber Output Amplitude */ 1528 PHY_M_EC2_FO_AM_MSK = 7, /* Bit 2.. 0: Fiber Output Amplitude */
1529}; 1529};
1530 1530
1531/***** PHY_MARV_EXT_P_STAT 16 bit r/w Ext. PHY Specific Status *****/ 1531/***** PHY_MARV_EXT_P_STAT 16 bit r/w Ext. PHY Specific Status *****/
@@ -1550,7 +1550,7 @@ enum {
1550 PHY_M_CABD_DIS_WAIT = 1<<15, /* Disable Waiting Period (Page 1) */ 1550 PHY_M_CABD_DIS_WAIT = 1<<15, /* Disable Waiting Period (Page 1) */
1551 /* (88E1111 only) */ 1551 /* (88E1111 only) */
1552 PHY_M_CABD_STAT_MSK = 3<<13, /* Bit 14..13: Status Mask */ 1552 PHY_M_CABD_STAT_MSK = 3<<13, /* Bit 14..13: Status Mask */
1553 PHY_M_CABD_AMPL_MSK = 0x1f<<8,/* Bit 12.. 8: Amplitude Mask */ 1553 PHY_M_CABD_AMPL_MSK = 0x1f<<8, /* Bit 12.. 8: Amplitude Mask */
1554 /* (88E1111 only) */ 1554 /* (88E1111 only) */
1555 PHY_M_CABD_DIST_MSK = 0xff, /* Bit 7.. 0: Distance Mask */ 1555 PHY_M_CABD_DIST_MSK = 0xff, /* Bit 7.. 0: Distance Mask */
1556}; 1556};
@@ -1605,9 +1605,9 @@ enum {
1605 1605
1606/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/ 1606/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/
1607enum { 1607enum {
1608 PHY_M_LEDC_LOS_MSK = 0xf<<12,/* Bit 15..12: LOS LED Ctrl. Mask */ 1608 PHY_M_LEDC_LOS_MSK = 0xf<<12, /* Bit 15..12: LOS LED Ctrl. Mask */
1609 PHY_M_LEDC_INIT_MSK = 0xf<<8, /* Bit 11.. 8: INIT LED Ctrl. Mask */ 1609 PHY_M_LEDC_INIT_MSK = 0xf<<8, /* Bit 11.. 8: INIT LED Ctrl. Mask */
1610 PHY_M_LEDC_STA1_MSK = 0xf<<4,/* Bit 7.. 4: STAT1 LED Ctrl. Mask */ 1610 PHY_M_LEDC_STA1_MSK = 0xf<<4, /* Bit 7.. 4: STAT1 LED Ctrl. Mask */
1611 PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */ 1611 PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */
1612}; 1612};
1613 1613
@@ -1804,8 +1804,8 @@ enum {
1804 1804
1805/* GM_SMI_CTRL 16 bit r/w SMI Control Register */ 1805/* GM_SMI_CTRL 16 bit r/w SMI Control Register */
1806enum { 1806enum {
1807 GM_SMI_CT_PHY_A_MSK = 0x1f<<11,/* Bit 15..11: PHY Device Address */ 1807 GM_SMI_CT_PHY_A_MSK = 0x1f<<11, /* Bit 15..11: PHY Device Address */
1808 GM_SMI_CT_REG_A_MSK = 0x1f<<6,/* Bit 10.. 6: PHY Register Address */ 1808 GM_SMI_CT_REG_A_MSK = 0x1f<<6, /* Bit 10.. 6: PHY Register Address */
1809 GM_SMI_CT_OP_RD = 1<<5, /* Bit 5: OpCode Read (0=Write)*/ 1809 GM_SMI_CT_OP_RD = 1<<5, /* Bit 5: OpCode Read (0=Write)*/
1810 GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */ 1810 GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */
1811 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ 1811 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */
@@ -1875,9 +1875,9 @@ enum {
1875 1875
1876/* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */ 1876/* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */
1877enum { 1877enum {
1878 GMF_WSP_TST_ON = 1<<18,/* Write Shadow Pointer Test On */ 1878 GMF_WSP_TST_ON = 1<<18, /* Write Shadow Pointer Test On */
1879 GMF_WSP_TST_OFF = 1<<17,/* Write Shadow Pointer Test Off */ 1879 GMF_WSP_TST_OFF = 1<<17, /* Write Shadow Pointer Test Off */
1880 GMF_WSP_STEP = 1<<16,/* Write Shadow Pointer Step/Increment */ 1880 GMF_WSP_STEP = 1<<16, /* Write Shadow Pointer Step/Increment */
1881 1881
1882 GMF_CLI_TX_FU = 1<<6, /* Clear IRQ Tx FIFO Underrun */ 1882 GMF_CLI_TX_FU = 1<<6, /* Clear IRQ Tx FIFO Underrun */
1883 GMF_CLI_TX_FC = 1<<5, /* Clear IRQ Tx Frame Complete */ 1883 GMF_CLI_TX_FC = 1<<5, /* Clear IRQ Tx Frame Complete */
@@ -2111,18 +2111,18 @@ enum {
2111 2111
2112/* XM_MMU_CMD 16 bit r/w MMU Command Register */ 2112/* XM_MMU_CMD 16 bit r/w MMU Command Register */
2113enum { 2113enum {
2114 XM_MMU_PHY_RDY = 1<<12,/* Bit 12: PHY Read Ready */ 2114 XM_MMU_PHY_RDY = 1<<12, /* Bit 12: PHY Read Ready */
2115 XM_MMU_PHY_BUSY = 1<<11,/* Bit 11: PHY Busy */ 2115 XM_MMU_PHY_BUSY = 1<<11, /* Bit 11: PHY Busy */
2116 XM_MMU_IGN_PF = 1<<10,/* Bit 10: Ignore Pause Frame */ 2116 XM_MMU_IGN_PF = 1<<10, /* Bit 10: Ignore Pause Frame */
2117 XM_MMU_MAC_LB = 1<<9, /* Bit 9: Enable MAC Loopback */ 2117 XM_MMU_MAC_LB = 1<<9, /* Bit 9: Enable MAC Loopback */
2118 XM_MMU_FRC_COL = 1<<7, /* Bit 7: Force Collision */ 2118 XM_MMU_FRC_COL = 1<<7, /* Bit 7: Force Collision */
2119 XM_MMU_SIM_COL = 1<<6, /* Bit 6: Simulate Collision */ 2119 XM_MMU_SIM_COL = 1<<6, /* Bit 6: Simulate Collision */
2120 XM_MMU_NO_PRE = 1<<5, /* Bit 5: No MDIO Preamble */ 2120 XM_MMU_NO_PRE = 1<<5, /* Bit 5: No MDIO Preamble */
2121 XM_MMU_GMII_FD = 1<<4, /* Bit 4: GMII uses Full Duplex */ 2121 XM_MMU_GMII_FD = 1<<4, /* Bit 4: GMII uses Full Duplex */
2122 XM_MMU_RAT_CTRL = 1<<3, /* Bit 3: Enable Rate Control */ 2122 XM_MMU_RAT_CTRL = 1<<3, /* Bit 3: Enable Rate Control */
2123 XM_MMU_GMII_LOOP= 1<<2, /* Bit 2: PHY is in Loopback Mode */ 2123 XM_MMU_GMII_LOOP= 1<<2, /* Bit 2: PHY is in Loopback Mode */
2124 XM_MMU_ENA_RX = 1<<1, /* Bit 1: Enable Receiver */ 2124 XM_MMU_ENA_RX = 1<<1, /* Bit 1: Enable Receiver */
2125 XM_MMU_ENA_TX = 1<<0, /* Bit 0: Enable Transmitter */ 2125 XM_MMU_ENA_TX = 1<<0, /* Bit 0: Enable Transmitter */
2126}; 2126};
2127 2127
2128 2128
@@ -2506,7 +2506,7 @@ static inline void skge_write8(const struct skge_hw *hw, int reg, u8 val)
2506} 2506}
2507 2507
2508/* MAC Related Registers inside the device. */ 2508/* MAC Related Registers inside the device. */
2509#define SK_REG(port,reg) (((port)<<7)+(reg)) 2509#define SK_REG(port,reg) (((port)<<7)+(u16)(reg))
2510#define SK_XMAC_REG(port, reg) \ 2510#define SK_XMAC_REG(port, reg) \
2511 ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1) 2511 ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1)
2512 2512
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 842abd9396c6..fb1d2c30c1bb 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -100,33 +100,32 @@ module_param(idle_timeout, int, 0);
100MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)"); 100MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)");
101 101
102static const struct pci_device_id sky2_id_table[] = { 102static const struct pci_device_id sky2_id_table[] = {
103 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, 103 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, 104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
105 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, /* DGE-560T */ 105 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, /* DGE-560T */
106 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) }, /* DGE-550SX */ 106 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) }, /* DGE-550SX */
107 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4B02) }, /* DGE-560SX */ 107 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4B02) }, /* DGE-560SX */
108 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, 108 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, /* 88E8021 */
109 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, 109 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, /* 88E8022 */
110 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, 110 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, /* 88E8061 */
111 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) }, 111 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) }, /* 88E8062 */
112 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) }, 112 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) }, /* 88E8021 */
113 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) }, 113 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) }, /* 88E8022 */
114 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) }, 114 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) }, /* 88E8061 */
115 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) }, 115 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) }, /* 88E8062 */
116 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) }, 116 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) }, /* 88E8035 */
117 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) }, 117 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) }, /* 88E8036 */
118 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) }, 118 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) }, /* 88E8038 */
119 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, 119 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, /* 88E8039 */
120 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, 120 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4356) }, /* 88EC033 */
121 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, 121 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, /* 88E8052 */
122 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, 122 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */
123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, 123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, /* 88E8053 */
124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, 124 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, /* 88E8055 */
125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4365) }, 125 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, /* 88E8056 */
126 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, 126 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, /* 88EC036 */
127 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, 127 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, /* 88EC032 */
128 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, 128 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */
129 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) },
130 { 0 } 129 { 0 }
131}; 130};
132 131
@@ -522,7 +521,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
522 /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ 521 /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
523 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL; 522 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL;
524 /* turn off the Rx LED (LED_RX) */ 523 /* turn off the Rx LED (LED_RX) */
525 ledover |= PHY_M_LED_MO_RX(MO_LED_OFF); 524 ledover &= ~PHY_M_LED_MO_RX;
526 } 525 }
527 526
528 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) { 527 if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) {
@@ -545,7 +544,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
545 544
546 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) { 545 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
547 /* turn on 100 Mbps LED (LED_LINK100) */ 546 /* turn on 100 Mbps LED (LED_LINK100) */
548 ledover |= PHY_M_LED_MO_100(MO_LED_ON); 547 ledover |= PHY_M_LED_MO_100;
549 } 548 }
550 549
551 if (ledover) 550 if (ledover)
@@ -697,10 +696,15 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
697 696
698} 697}
699 698
700/* Assign Ram Buffer allocation in units of 64bit (8 bytes) */ 699/* Assign Ram Buffer allocation to queue */
701static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end) 700static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space)
702{ 701{
703 pr_debug(PFX "q %d %#x %#x\n", q, start, end); 702 u32 end;
703
704 /* convert from K bytes to qwords used for hw register */
705 start *= 1024/8;
706 space *= 1024/8;
707 end = start + space - 1;
704 708
705 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); 709 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
706 sky2_write32(hw, RB_ADDR(q, RB_START), start); 710 sky2_write32(hw, RB_ADDR(q, RB_START), start);
@@ -709,7 +713,6 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
709 sky2_write32(hw, RB_ADDR(q, RB_RP), start); 713 sky2_write32(hw, RB_ADDR(q, RB_RP), start);
710 714
711 if (q == Q_R1 || q == Q_R2) { 715 if (q == Q_R1 || q == Q_R2) {
712 u32 space = end - start + 1;
713 u32 tp = space - space/4; 716 u32 tp = space - space/4;
714 717
715 /* On receive queue's set the thresholds 718 /* On receive queue's set the thresholds
@@ -1059,11 +1062,16 @@ static int sky2_rx_start(struct sky2_port *sky2)
1059 sky2->rx_put = sky2->rx_next = 0; 1062 sky2->rx_put = sky2->rx_next = 0;
1060 sky2_qset(hw, rxq); 1063 sky2_qset(hw, rxq);
1061 1064
1065 /* On PCI express lowering the watermark gives better performance */
1066 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP))
1067 sky2_write32(hw, Q_ADDR(rxq, Q_WM), BMU_WM_PEX);
1068
1069 /* These chips have no ram buffer?
1070 * MAC Rx RAM Read is controlled by hardware */
1062 if (hw->chip_id == CHIP_ID_YUKON_EC_U && 1071 if (hw->chip_id == CHIP_ID_YUKON_EC_U &&
1063 (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0)) { 1072 (hw->chip_rev == CHIP_REV_YU_EC_U_A1
1064 /* MAC Rx RAM Read is controlled by hardware */ 1073 || hw->chip_rev == CHIP_REV_YU_EC_U_B0))
1065 sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS); 1074 sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS);
1066 }
1067 1075
1068 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1); 1076 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
1069 1077
@@ -1139,7 +1147,7 @@ static int sky2_up(struct net_device *dev)
1139 struct sky2_port *sky2 = netdev_priv(dev); 1147 struct sky2_port *sky2 = netdev_priv(dev);
1140 struct sky2_hw *hw = sky2->hw; 1148 struct sky2_hw *hw = sky2->hw;
1141 unsigned port = sky2->port; 1149 unsigned port = sky2->port;
1142 u32 ramsize, rxspace, imask; 1150 u32 ramsize, imask;
1143 int cap, err = -ENOMEM; 1151 int cap, err = -ENOMEM;
1144 struct net_device *otherdev = hw->dev[sky2->port^1]; 1152 struct net_device *otherdev = hw->dev[sky2->port^1];
1145 1153
@@ -1192,20 +1200,25 @@ static int sky2_up(struct net_device *dev)
1192 1200
1193 sky2_mac_init(hw, port); 1201 sky2_mac_init(hw, port);
1194 1202
1195 /* Determine available ram buffer space in qwords. */ 1203 /* Register is number of 4K blocks on internal RAM buffer. */
1196 ramsize = sky2_read8(hw, B2_E_0) * 4096/8; 1204 ramsize = sky2_read8(hw, B2_E_0) * 4;
1205 printk(KERN_INFO PFX "%s: ram buffer %dK\n", dev->name, ramsize);
1197 1206
1198 if (ramsize > 6*1024/8) 1207 if (ramsize > 0) {
1199 rxspace = ramsize - (ramsize + 2) / 3; 1208 u32 rxspace;
1200 else
1201 rxspace = ramsize / 2;
1202 1209
1203 sky2_ramset(hw, rxqaddr[port], 0, rxspace-1); 1210 if (ramsize < 16)
1204 sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1); 1211 rxspace = ramsize / 2;
1212 else
1213 rxspace = 8 + (2*(ramsize - 16))/3;
1214
1215 sky2_ramset(hw, rxqaddr[port], 0, rxspace);
1216 sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace);
1205 1217
1206 /* Make sure SyncQ is disabled */ 1218 /* Make sure SyncQ is disabled */
1207 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), 1219 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
1208 RB_RST_SET); 1220 RB_RST_SET);
1221 }
1209 1222
1210 sky2_qset(hw, txqaddr[port]); 1223 sky2_qset(hw, txqaddr[port]);
1211 1224
@@ -2917,18 +2930,8 @@ static void sky2_led(struct sky2_hw *hw, unsigned port, int on)
2917 2930
2918 default: 2931 default:
2919 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); 2932 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
2920 gm_phy_write(hw, port, PHY_MARV_LED_OVER, 2933 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
2921 on ? PHY_M_LED_MO_DUP(MO_LED_ON) | 2934 on ? PHY_M_LED_ALL : 0);
2922 PHY_M_LED_MO_10(MO_LED_ON) |
2923 PHY_M_LED_MO_100(MO_LED_ON) |
2924 PHY_M_LED_MO_1000(MO_LED_ON) |
2925 PHY_M_LED_MO_RX(MO_LED_ON)
2926 : PHY_M_LED_MO_DUP(MO_LED_OFF) |
2927 PHY_M_LED_MO_10(MO_LED_OFF) |
2928 PHY_M_LED_MO_100(MO_LED_OFF) |
2929 PHY_M_LED_MO_1000(MO_LED_OFF) |
2930 PHY_M_LED_MO_RX(MO_LED_OFF));
2931
2932 } 2935 }
2933} 2936}
2934 2937
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 7760545edbf2..6ed1d47dbbd3 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -608,7 +608,7 @@ enum {
608 PHY_ADDR_MARV = 0, 608 PHY_ADDR_MARV = 0,
609}; 609};
610 610
611#define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs)) 611#define RB_ADDR(offs, queue) ((u16) B16_RAM_REGS + (queue) + (offs))
612 612
613 613
614enum { 614enum {
@@ -680,6 +680,7 @@ enum {
680 BMU_FIFO_ENA | BMU_OP_ON, 680 BMU_FIFO_ENA | BMU_OP_ON,
681 681
682 BMU_WM_DEFAULT = 0x600, 682 BMU_WM_DEFAULT = 0x600,
683 BMU_WM_PEX = 0x80,
683}; 684};
684 685
685/* Tx BMU Control / Status Registers (Yukon-2) */ 686/* Tx BMU Control / Status Registers (Yukon-2) */
@@ -1060,7 +1061,7 @@ enum {
1060 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ 1061 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */
1061}; 1062};
1062 1063
1063#define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK) 1064#define PHY_M_PC_MDI_XMODE(x) (((u16)(x)<<5) & PHY_M_PC_MDIX_MSK)
1064 1065
1065enum { 1066enum {
1066 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ 1067 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */
@@ -1156,13 +1157,13 @@ enum {
1156 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ 1157 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */
1157 PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; 1158 PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */};
1158 1159
1159#define PHY_M_EC_M_DSC(x) ((x)<<10 & PHY_M_EC_M_DSC_MSK) 1160#define PHY_M_EC_M_DSC(x) ((u16)(x)<<10 & PHY_M_EC_M_DSC_MSK)
1160 /* 00=1x; 01=2x; 10=3x; 11=4x */ 1161 /* 00=1x; 01=2x; 10=3x; 11=4x */
1161#define PHY_M_EC_S_DSC(x) ((x)<<8 & PHY_M_EC_S_DSC_MSK) 1162#define PHY_M_EC_S_DSC(x) ((u16)(x)<<8 & PHY_M_EC_S_DSC_MSK)
1162 /* 00=dis; 01=1x; 10=2x; 11=3x */ 1163 /* 00=dis; 01=1x; 10=2x; 11=3x */
1163#define PHY_M_EC_DSC_2(x) ((x)<<9 & PHY_M_EC_M_DSC_MSK2) 1164#define PHY_M_EC_DSC_2(x) ((u16)(x)<<9 & PHY_M_EC_M_DSC_MSK2)
1164 /* 000=1x; 001=2x; 010=3x; 011=4x */ 1165 /* 000=1x; 001=2x; 010=3x; 011=4x */
1165#define PHY_M_EC_MAC_S(x) ((x)<<4 & PHY_M_EC_MAC_S_MSK) 1166#define PHY_M_EC_MAC_S(x) ((u16)(x)<<4 & PHY_M_EC_MAC_S_MSK)
1166 /* 01X=0; 110=2.5; 111=25 (MHz) */ 1167 /* 01X=0; 110=2.5; 111=25 (MHz) */
1167 1168
1168/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */ 1169/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */
@@ -1173,7 +1174,7 @@ enum {
1173}; 1174};
1174/* !!! Errata in spec. (1 = disable) */ 1175/* !!! Errata in spec. (1 = disable) */
1175 1176
1176#define PHY_M_PC_DSC(x) (((x)<<12) & PHY_M_PC_DSC_MSK) 1177#define PHY_M_PC_DSC(x) (((u16)(x)<<12) & PHY_M_PC_DSC_MSK)
1177 /* 100=5x; 101=6x; 110=7x; 111=8x */ 1178 /* 100=5x; 101=6x; 110=7x; 111=8x */
1178enum { 1179enum {
1179 MAC_TX_CLK_0_MHZ = 2, 1180 MAC_TX_CLK_0_MHZ = 2,
@@ -1203,7 +1204,7 @@ enum {
1203 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ 1204 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */
1204}; 1205};
1205 1206
1206#define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK) 1207#define PHY_M_LED_PULS_DUR(x) (((u16)(x)<<12) & PHY_M_LEDC_PULS_MSK)
1207 1208
1208/***** PHY_MARV_PHY_STAT (page 3)16 bit r/w Polarity Control Reg. *****/ 1209/***** PHY_MARV_PHY_STAT (page 3)16 bit r/w Polarity Control Reg. *****/
1209enum { 1210enum {
@@ -1233,7 +1234,7 @@ enum {
1233 PULS_1300MS = 7,/* 1.3 s to 2.7 s */ 1234 PULS_1300MS = 7,/* 1.3 s to 2.7 s */
1234}; 1235};
1235 1236
1236#define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK) 1237#define PHY_M_LED_BLINK_RT(x) (((u16)(x)<<8) & PHY_M_LEDC_BL_R_MSK)
1237 1238
1238enum { 1239enum {
1239 BLINK_42MS = 0,/* 42 ms */ 1240 BLINK_42MS = 0,/* 42 ms */
@@ -1243,21 +1244,18 @@ enum {
1243 BLINK_670MS = 4,/* 670 ms */ 1244 BLINK_670MS = 4,/* 670 ms */
1244}; 1245};
1245 1246
1246/***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/ 1247/**** PHY_MARV_LED_OVER 16 bit r/w LED control */
1247#define PHY_M_LED_MO_SGMII(x) ((x)<<14) /* Bit 15..14: SGMII AN Timer */
1248 /* Bit 13..12: reserved */
1249#define PHY_M_LED_MO_DUP(x) ((x)<<10) /* Bit 11..10: Duplex */
1250#define PHY_M_LED_MO_10(x) ((x)<<8) /* Bit 9.. 8: Link 10 */
1251#define PHY_M_LED_MO_100(x) ((x)<<6) /* Bit 7.. 6: Link 100 */
1252#define PHY_M_LED_MO_1000(x) ((x)<<4) /* Bit 5.. 4: Link 1000 */
1253#define PHY_M_LED_MO_RX(x) ((x)<<2) /* Bit 3.. 2: Rx */
1254#define PHY_M_LED_MO_TX(x) ((x)<<0) /* Bit 1.. 0: Tx */
1255
1256enum { 1248enum {
1257 MO_LED_NORM = 0, 1249 PHY_M_LED_MO_DUP = 3<<10,/* Bit 11..10: Duplex */
1258 MO_LED_BLINK = 1, 1250 PHY_M_LED_MO_10 = 3<<8, /* Bit 9.. 8: Link 10 */
1259 MO_LED_OFF = 2, 1251 PHY_M_LED_MO_100 = 3<<6, /* Bit 7.. 6: Link 100 */
1260 MO_LED_ON = 3, 1252 PHY_M_LED_MO_1000 = 3<<4, /* Bit 5.. 4: Link 1000 */
1253 PHY_M_LED_MO_RX = 3<<2, /* Bit 3.. 2: Rx */
1254 PHY_M_LED_MO_TX = 3<<0, /* Bit 1.. 0: Tx */
1255
1256 PHY_M_LED_ALL = PHY_M_LED_MO_DUP | PHY_M_LED_MO_10
1257 | PHY_M_LED_MO_100 | PHY_M_LED_MO_1000
1258 | PHY_M_LED_MO_RX,
1261}; 1259};
1262 1260
1263/***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/ 1261/***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/
@@ -1294,9 +1292,9 @@ enum {
1294 PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */ 1292 PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */
1295}; 1293};
1296 1294
1297#define PHY_M_FELP_LED2_CTRL(x) (((x)<<8) & PHY_M_FELP_LED2_MSK) 1295#define PHY_M_FELP_LED2_CTRL(x) (((u16)(x)<<8) & PHY_M_FELP_LED2_MSK)
1298#define PHY_M_FELP_LED1_CTRL(x) (((x)<<4) & PHY_M_FELP_LED1_MSK) 1296#define PHY_M_FELP_LED1_CTRL(x) (((u16)(x)<<4) & PHY_M_FELP_LED1_MSK)
1299#define PHY_M_FELP_LED0_CTRL(x) (((x)<<0) & PHY_M_FELP_LED0_MSK) 1297#define PHY_M_FELP_LED0_CTRL(x) (((u16)(x)<<0) & PHY_M_FELP_LED0_MSK)
1300 1298
1301enum { 1299enum {
1302 LED_PAR_CTRL_COLX = 0x00, 1300 LED_PAR_CTRL_COLX = 0x00,
@@ -1552,8 +1550,8 @@ enum {
1552 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ 1550 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */
1553}; 1551};
1554 1552
1555#define GM_SMI_CT_PHY_AD(x) (((x)<<11) & GM_SMI_CT_PHY_A_MSK) 1553#define GM_SMI_CT_PHY_AD(x) (((u16)(x)<<11) & GM_SMI_CT_PHY_A_MSK)
1556#define GM_SMI_CT_REG_AD(x) (((x)<<6) & GM_SMI_CT_REG_A_MSK) 1554#define GM_SMI_CT_REG_AD(x) (((u16)(x)<<6) & GM_SMI_CT_REG_A_MSK)
1557 1555
1558/* GM_PHY_ADDR 16 bit r/w GPHY Address Register */ 1556/* GM_PHY_ADDR 16 bit r/w GPHY Address Register */
1559enum { 1557enum {
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c
index 889ef0d7c374..d70bc9795346 100644
--- a/drivers/net/smc-ultra.c
+++ b/drivers/net/smc-ultra.c
@@ -593,7 +593,7 @@ static void cleanup_card(struct net_device *dev)
593 iounmap(ei_status.mem); 593 iounmap(ei_status.mem);
594} 594}
595 595
596void 596void __exit
597cleanup_module(void) 597cleanup_module(void)
598{ 598{
599 int this_dev; 599 int this_dev;
diff --git a/drivers/net/smc-ultra32.c b/drivers/net/smc-ultra32.c
index e10755ec5def..2c5319c62fa5 100644
--- a/drivers/net/smc-ultra32.c
+++ b/drivers/net/smc-ultra32.c
@@ -437,7 +437,7 @@ int __init init_module(void)
437 return -ENXIO; 437 return -ENXIO;
438} 438}
439 439
440void cleanup_module(void) 440void __exit cleanup_module(void)
441{ 441{
442 int this_dev; 442 int this_dev;
443 443
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c
index c0d13d650913..bd6e84506c29 100644
--- a/drivers/net/smc9194.c
+++ b/drivers/net/smc9194.c
@@ -1616,7 +1616,7 @@ int __init init_module(void)
1616 return 0; 1616 return 0;
1617} 1617}
1618 1618
1619void cleanup_module(void) 1619void __exit cleanup_module(void)
1620{ 1620{
1621 unregister_netdev(devSMC9194); 1621 unregister_netdev(devSMC9194);
1622 free_irq(devSMC9194->irq, devSMC9194); 1622 free_irq(devSMC9194->irq, devSMC9194);
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index a8640169fc77..9367c574477a 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -238,7 +238,7 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg)
238#define SMC_CAN_USE_16BIT 1 238#define SMC_CAN_USE_16BIT 1
239#define SMC_CAN_USE_32BIT 0 239#define SMC_CAN_USE_32BIT 0
240 240
241#define SMC_inb(a, r) inb((u32)a) + (r)) 241#define SMC_inb(a, r) inb(((u32)a) + (r))
242#define SMC_inw(a, r) inw(((u32)a) + (r)) 242#define SMC_inw(a, r) inw(((u32)a) + (r))
243#define SMC_outb(v, a, r) outb(v, ((u32)a) + (r)) 243#define SMC_outb(v, a, r) outb(v, ((u32)a) + (r))
244#define SMC_outw(v, a, r) outw(v, ((u32)a) + (r)) 244#define SMC_outw(v, a, r) outw(v, ((u32)a) + (r))
@@ -434,6 +434,24 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
434 434
435#define SMC_IRQ_FLAGS (0) 435#define SMC_IRQ_FLAGS (0)
436 436
437#elif defined(CONFIG_ARCH_VERSATILE)
438
439#define SMC_CAN_USE_8BIT 1
440#define SMC_CAN_USE_16BIT 1
441#define SMC_CAN_USE_32BIT 1
442#define SMC_NOWAIT 1
443
444#define SMC_inb(a, r) readb((a) + (r))
445#define SMC_inw(a, r) readw((a) + (r))
446#define SMC_inl(a, r) readl((a) + (r))
447#define SMC_outb(v, a, r) writeb(v, (a) + (r))
448#define SMC_outw(v, a, r) writew(v, (a) + (r))
449#define SMC_outl(v, a, r) writel(v, (a) + (r))
450#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
451#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
452
453#define SMC_IRQ_FLAGS (0)
454
437#else 455#else
438 456
439#define SMC_CAN_USE_8BIT 1 457#define SMC_CAN_USE_8BIT 1
@@ -1216,7 +1234,7 @@ static const char * chip_ids[ 16 ] = {
1216 if (SMC_CAN_USE_32BIT) { \ 1234 if (SMC_CAN_USE_32BIT) { \
1217 void *__ptr = (p); \ 1235 void *__ptr = (p); \
1218 int __len = (l); \ 1236 int __len = (l); \
1219 void *__ioaddr = ioaddr; \ 1237 void __iomem *__ioaddr = ioaddr; \
1220 if (__len >= 2 && (unsigned long)__ptr & 2) { \ 1238 if (__len >= 2 && (unsigned long)__ptr & 2) { \
1221 __len -= 2; \ 1239 __len -= 2; \
1222 SMC_outw(*(u16 *)__ptr, ioaddr, DATA_REG); \ 1240 SMC_outw(*(u16 *)__ptr, ioaddr, DATA_REG); \
@@ -1240,7 +1258,7 @@ static const char * chip_ids[ 16 ] = {
1240 if (SMC_CAN_USE_32BIT) { \ 1258 if (SMC_CAN_USE_32BIT) { \
1241 void *__ptr = (p); \ 1259 void *__ptr = (p); \
1242 int __len = (l); \ 1260 int __len = (l); \
1243 void *__ioaddr = ioaddr; \ 1261 void __iomem *__ioaddr = ioaddr; \
1244 if ((unsigned long)__ptr & 2) { \ 1262 if ((unsigned long)__ptr & 2) { \
1245 /* \ 1263 /* \
1246 * We want 32bit alignment here. \ 1264 * We want 32bit alignment here. \
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index 47a1c09d19ac..c62e85d89f41 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -945,7 +945,7 @@ static void set_multicast_list( struct net_device *dev )
945 945
946static struct net_device *sun3lance_dev; 946static struct net_device *sun3lance_dev;
947 947
948int init_module(void) 948int __init init_module(void)
949{ 949{
950 sun3lance_dev = sun3lance_probe(-1); 950 sun3lance_dev = sun3lance_probe(-1);
951 if (IS_ERR(sun3lance_dev)) 951 if (IS_ERR(sun3lance_dev))
@@ -953,7 +953,7 @@ int init_module(void)
953 return 0; 953 return 0;
954} 954}
955 955
956void cleanup_module(void) 956void __exit cleanup_module(void)
957{ 957{
958 unregister_netdev(sun3lance_dev); 958 unregister_netdev(sun3lance_dev);
959#ifdef CONFIG_SUN3 959#ifdef CONFIG_SUN3
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index d9123c9adc1e..571320ae87ab 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -68,8 +68,8 @@
68 68
69#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
70#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
71#define DRV_MODULE_VERSION "3.69" 71#define DRV_MODULE_VERSION "3.70"
72#define DRV_MODULE_RELDATE "November 15, 2006" 72#define DRV_MODULE_RELDATE "December 1, 2006"
73 73
74#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
75#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -192,6 +192,7 @@ static struct pci_device_id tg3_pci_tbl[] = {
192 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5786)}, 192 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5786)},
193 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787)}, 193 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787)},
194 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M)}, 194 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M)},
195 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787F)},
195 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714)}, 196 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714)},
196 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714S)}, 197 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5714S)},
197 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715)}, 198 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5715)},
@@ -1061,7 +1062,7 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1061{ 1062{
1062 struct tg3 *tp_peer = tp; 1063 struct tg3 *tp_peer = tp;
1063 1064
1064 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0) 1065 if ((tp->tg3_flags2 & TG3_FLG2_IS_NIC) == 0)
1065 return; 1066 return;
1066 1067
1067 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) || 1068 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
@@ -1212,8 +1213,8 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
1212 power_control); 1213 power_control);
1213 udelay(100); /* Delay after power state change */ 1214 udelay(100); /* Delay after power state change */
1214 1215
1215 /* Switch out of Vaux if it is not a LOM */ 1216 /* Switch out of Vaux if it is a NIC */
1216 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) 1217 if (tp->tg3_flags2 & TG3_FLG2_IS_NIC)
1217 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100); 1218 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100);
1218 1219
1219 return 0; 1220 return 0;
@@ -1401,8 +1402,10 @@ static int tg3_set_power_state(struct tg3 *tp, pci_power_t state)
1401static void tg3_link_report(struct tg3 *tp) 1402static void tg3_link_report(struct tg3 *tp)
1402{ 1403{
1403 if (!netif_carrier_ok(tp->dev)) { 1404 if (!netif_carrier_ok(tp->dev)) {
1404 printk(KERN_INFO PFX "%s: Link is down.\n", tp->dev->name); 1405 if (netif_msg_link(tp))
1405 } else { 1406 printk(KERN_INFO PFX "%s: Link is down.\n",
1407 tp->dev->name);
1408 } else if (netif_msg_link(tp)) {
1406 printk(KERN_INFO PFX "%s: Link is up at %d Mbps, %s duplex.\n", 1409 printk(KERN_INFO PFX "%s: Link is up at %d Mbps, %s duplex.\n",
1407 tp->dev->name, 1410 tp->dev->name,
1408 (tp->link_config.active_speed == SPEED_1000 ? 1411 (tp->link_config.active_speed == SPEED_1000 ?
@@ -1557,12 +1560,6 @@ static void tg3_phy_copper_begin(struct tg3 *tp)
1557 1560
1558 tg3_writephy(tp, MII_ADVERTISE, new_adv); 1561 tg3_writephy(tp, MII_ADVERTISE, new_adv);
1559 } else if (tp->link_config.speed == SPEED_INVALID) { 1562 } else if (tp->link_config.speed == SPEED_INVALID) {
1560 tp->link_config.advertising =
1561 (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
1562 ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
1563 ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full |
1564 ADVERTISED_Autoneg | ADVERTISED_MII);
1565
1566 if (tp->tg3_flags & TG3_FLAG_10_100_ONLY) 1563 if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
1567 tp->link_config.advertising &= 1564 tp->link_config.advertising &=
1568 ~(ADVERTISED_1000baseT_Half | 1565 ~(ADVERTISED_1000baseT_Half |
@@ -1706,25 +1703,36 @@ static int tg3_init_5401phy_dsp(struct tg3 *tp)
1706 return err; 1703 return err;
1707} 1704}
1708 1705
1709static int tg3_copper_is_advertising_all(struct tg3 *tp) 1706static int tg3_copper_is_advertising_all(struct tg3 *tp, u32 mask)
1710{ 1707{
1711 u32 adv_reg, all_mask; 1708 u32 adv_reg, all_mask = 0;
1709
1710 if (mask & ADVERTISED_10baseT_Half)
1711 all_mask |= ADVERTISE_10HALF;
1712 if (mask & ADVERTISED_10baseT_Full)
1713 all_mask |= ADVERTISE_10FULL;
1714 if (mask & ADVERTISED_100baseT_Half)
1715 all_mask |= ADVERTISE_100HALF;
1716 if (mask & ADVERTISED_100baseT_Full)
1717 all_mask |= ADVERTISE_100FULL;
1712 1718
1713 if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg)) 1719 if (tg3_readphy(tp, MII_ADVERTISE, &adv_reg))
1714 return 0; 1720 return 0;
1715 1721
1716 all_mask = (ADVERTISE_10HALF | ADVERTISE_10FULL |
1717 ADVERTISE_100HALF | ADVERTISE_100FULL);
1718 if ((adv_reg & all_mask) != all_mask) 1722 if ((adv_reg & all_mask) != all_mask)
1719 return 0; 1723 return 0;
1720 if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY)) { 1724 if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY)) {
1721 u32 tg3_ctrl; 1725 u32 tg3_ctrl;
1722 1726
1727 all_mask = 0;
1728 if (mask & ADVERTISED_1000baseT_Half)
1729 all_mask |= ADVERTISE_1000HALF;
1730 if (mask & ADVERTISED_1000baseT_Full)
1731 all_mask |= ADVERTISE_1000FULL;
1732
1723 if (tg3_readphy(tp, MII_TG3_CTRL, &tg3_ctrl)) 1733 if (tg3_readphy(tp, MII_TG3_CTRL, &tg3_ctrl))
1724 return 0; 1734 return 0;
1725 1735
1726 all_mask = (MII_TG3_CTRL_ADV_1000_HALF |
1727 MII_TG3_CTRL_ADV_1000_FULL);
1728 if ((tg3_ctrl & all_mask) != all_mask) 1736 if ((tg3_ctrl & all_mask) != all_mask)
1729 return 0; 1737 return 0;
1730 } 1738 }
@@ -1884,7 +1892,8 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
1884 /* Force autoneg restart if we are exiting 1892 /* Force autoneg restart if we are exiting
1885 * low power mode. 1893 * low power mode.
1886 */ 1894 */
1887 if (!tg3_copper_is_advertising_all(tp)) 1895 if (!tg3_copper_is_advertising_all(tp,
1896 tp->link_config.advertising))
1888 current_link_up = 0; 1897 current_link_up = 0;
1889 } else { 1898 } else {
1890 current_link_up = 0; 1899 current_link_up = 0;
@@ -3703,8 +3712,9 @@ static void tg3_tx_timeout(struct net_device *dev)
3703{ 3712{
3704 struct tg3 *tp = netdev_priv(dev); 3713 struct tg3 *tp = netdev_priv(dev);
3705 3714
3706 printk(KERN_ERR PFX "%s: transmit timed out, resetting\n", 3715 if (netif_msg_tx_err(tp))
3707 dev->name); 3716 printk(KERN_ERR PFX "%s: transmit timed out, resetting\n",
3717 dev->name);
3708 3718
3709 schedule_work(&tp->reset_task); 3719 schedule_work(&tp->reset_task);
3710} 3720}
@@ -6396,16 +6406,17 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6396 udelay(40); 6406 udelay(40);
6397 6407
6398 /* tp->grc_local_ctrl is partially set up during tg3_get_invariants(). 6408 /* tp->grc_local_ctrl is partially set up during tg3_get_invariants().
6399 * If TG3_FLAG_EEPROM_WRITE_PROT is set, we should read the 6409 * If TG3_FLG2_IS_NIC is zero, we should read the
6400 * register to preserve the GPIO settings for LOMs. The GPIOs, 6410 * register to preserve the GPIO settings for LOMs. The GPIOs,
6401 * whether used as inputs or outputs, are set by boot code after 6411 * whether used as inputs or outputs, are set by boot code after
6402 * reset. 6412 * reset.
6403 */ 6413 */
6404 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) { 6414 if (!(tp->tg3_flags2 & TG3_FLG2_IS_NIC)) {
6405 u32 gpio_mask; 6415 u32 gpio_mask;
6406 6416
6407 gpio_mask = GRC_LCLCTRL_GPIO_OE0 | GRC_LCLCTRL_GPIO_OE2 | 6417 gpio_mask = GRC_LCLCTRL_GPIO_OE0 | GRC_LCLCTRL_GPIO_OE1 |
6408 GRC_LCLCTRL_GPIO_OUTPUT0 | GRC_LCLCTRL_GPIO_OUTPUT2; 6418 GRC_LCLCTRL_GPIO_OE2 | GRC_LCLCTRL_GPIO_OUTPUT0 |
6419 GRC_LCLCTRL_GPIO_OUTPUT1 | GRC_LCLCTRL_GPIO_OUTPUT2;
6409 6420
6410 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) 6421 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
6411 gpio_mask |= GRC_LCLCTRL_GPIO_OE3 | 6422 gpio_mask |= GRC_LCLCTRL_GPIO_OE3 |
@@ -6417,8 +6428,9 @@ static int tg3_reset_hw(struct tg3 *tp, int reset_phy)
6417 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask; 6428 tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
6418 6429
6419 /* GPIO1 must be driven high for eeprom write protect */ 6430 /* GPIO1 must be driven high for eeprom write protect */
6420 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 | 6431 if (tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)
6421 GRC_LCLCTRL_GPIO_OUTPUT1); 6432 tp->grc_local_ctrl |= (GRC_LCLCTRL_GPIO_OE1 |
6433 GRC_LCLCTRL_GPIO_OUTPUT1);
6422 } 6434 }
6423 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 6435 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl);
6424 udelay(100); 6436 udelay(100);
@@ -8656,7 +8668,9 @@ static int tg3_test_registers(struct tg3 *tp)
8656 return 0; 8668 return 0;
8657 8669
8658out: 8670out:
8659 printk(KERN_ERR PFX "Register test failed at offset %x\n", offset); 8671 if (netif_msg_hw(tp))
8672 printk(KERN_ERR PFX "Register test failed at offset %x\n",
8673 offset);
8660 tw32(offset, save_val); 8674 tw32(offset, save_val);
8661 return -EIO; 8675 return -EIO;
8662} 8676}
@@ -8781,17 +8795,20 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
8781 tg3_writephy(tp, 0x10, phy & ~0x4000); 8795 tg3_writephy(tp, 0x10, phy & ~0x4000);
8782 tg3_writephy(tp, MII_TG3_EPHY_TEST, phytest); 8796 tg3_writephy(tp, MII_TG3_EPHY_TEST, phytest);
8783 } 8797 }
8784 } 8798 val = BMCR_LOOPBACK | BMCR_FULLDPLX | BMCR_SPEED100;
8785 val = BMCR_LOOPBACK | BMCR_FULLDPLX; 8799 } else
8786 if (tp->tg3_flags & TG3_FLAG_10_100_ONLY) 8800 val = BMCR_LOOPBACK | BMCR_FULLDPLX | BMCR_SPEED1000;
8787 val |= BMCR_SPEED100;
8788 else
8789 val |= BMCR_SPEED1000;
8790 8801
8791 tg3_writephy(tp, MII_BMCR, val); 8802 tg3_writephy(tp, MII_BMCR, val);
8792 udelay(40); 8803 udelay(40);
8793 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) 8804
8805 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
8806 MAC_MODE_LINK_POLARITY;
8807 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
8794 tg3_writephy(tp, MII_TG3_EPHY_PTEST, 0x1800); 8808 tg3_writephy(tp, MII_TG3_EPHY_PTEST, 0x1800);
8809 mac_mode |= MAC_MODE_PORT_MODE_MII;
8810 } else
8811 mac_mode |= MAC_MODE_PORT_MODE_GMII;
8795 8812
8796 /* reset to prevent losing 1st rx packet intermittently */ 8813 /* reset to prevent losing 1st rx packet intermittently */
8797 if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) { 8814 if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) {
@@ -8799,12 +8816,6 @@ static int tg3_run_loopback(struct tg3 *tp, int loopback_mode)
8799 udelay(10); 8816 udelay(10);
8800 tw32_f(MAC_RX_MODE, tp->rx_mode); 8817 tw32_f(MAC_RX_MODE, tp->rx_mode);
8801 } 8818 }
8802 mac_mode = (tp->mac_mode & ~MAC_MODE_PORT_MODE_MASK) |
8803 MAC_MODE_LINK_POLARITY;
8804 if (tp->tg3_flags & TG3_FLAG_10_100_ONLY)
8805 mac_mode |= MAC_MODE_PORT_MODE_MII;
8806 else
8807 mac_mode |= MAC_MODE_PORT_MODE_GMII;
8808 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { 8819 if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) {
8809 mac_mode &= ~MAC_MODE_LINK_POLARITY; 8820 mac_mode &= ~MAC_MODE_LINK_POLARITY;
8810 tg3_writephy(tp, MII_TG3_EXT_CTRL, 8821 tg3_writephy(tp, MII_TG3_EXT_CTRL,
@@ -9456,16 +9467,12 @@ static void __devinit tg3_get_5906_nvram_info(struct tg3 *tp)
9456/* Chips other than 5700/5701 use the NVRAM for fetching info. */ 9467/* Chips other than 5700/5701 use the NVRAM for fetching info. */
9457static void __devinit tg3_nvram_init(struct tg3 *tp) 9468static void __devinit tg3_nvram_init(struct tg3 *tp)
9458{ 9469{
9459 int j;
9460
9461 tw32_f(GRC_EEPROM_ADDR, 9470 tw32_f(GRC_EEPROM_ADDR,
9462 (EEPROM_ADDR_FSM_RESET | 9471 (EEPROM_ADDR_FSM_RESET |
9463 (EEPROM_DEFAULT_CLOCK_PERIOD << 9472 (EEPROM_DEFAULT_CLOCK_PERIOD <<
9464 EEPROM_ADDR_CLKPERD_SHIFT))); 9473 EEPROM_ADDR_CLKPERD_SHIFT)));
9465 9474
9466 /* XXX schedule_timeout() ... */ 9475 msleep(1);
9467 for (j = 0; j < 100; j++)
9468 udelay(10);
9469 9476
9470 /* Enable seeprom accesses. */ 9477 /* Enable seeprom accesses. */
9471 tw32_f(GRC_LOCAL_CTRL, 9478 tw32_f(GRC_LOCAL_CTRL,
@@ -9526,12 +9533,12 @@ static int tg3_nvram_read_using_eeprom(struct tg3 *tp,
9526 EEPROM_ADDR_ADDR_MASK) | 9533 EEPROM_ADDR_ADDR_MASK) |
9527 EEPROM_ADDR_READ | EEPROM_ADDR_START); 9534 EEPROM_ADDR_READ | EEPROM_ADDR_START);
9528 9535
9529 for (i = 0; i < 10000; i++) { 9536 for (i = 0; i < 1000; i++) {
9530 tmp = tr32(GRC_EEPROM_ADDR); 9537 tmp = tr32(GRC_EEPROM_ADDR);
9531 9538
9532 if (tmp & EEPROM_ADDR_COMPLETE) 9539 if (tmp & EEPROM_ADDR_COMPLETE)
9533 break; 9540 break;
9534 udelay(100); 9541 msleep(1);
9535 } 9542 }
9536 if (!(tmp & EEPROM_ADDR_COMPLETE)) 9543 if (!(tmp & EEPROM_ADDR_COMPLETE))
9537 return -EBUSY; 9544 return -EBUSY;
@@ -9656,12 +9663,12 @@ static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp,
9656 EEPROM_ADDR_START | 9663 EEPROM_ADDR_START |
9657 EEPROM_ADDR_WRITE); 9664 EEPROM_ADDR_WRITE);
9658 9665
9659 for (j = 0; j < 10000; j++) { 9666 for (j = 0; j < 1000; j++) {
9660 val = tr32(GRC_EEPROM_ADDR); 9667 val = tr32(GRC_EEPROM_ADDR);
9661 9668
9662 if (val & EEPROM_ADDR_COMPLETE) 9669 if (val & EEPROM_ADDR_COMPLETE)
9663 break; 9670 break;
9664 udelay(100); 9671 msleep(1);
9665 } 9672 }
9666 if (!(val & EEPROM_ADDR_COMPLETE)) { 9673 if (!(val & EEPROM_ADDR_COMPLETE)) {
9667 rc = -EBUSY; 9674 rc = -EBUSY;
@@ -9965,8 +9972,10 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
9965 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 9972 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
9966 9973
9967 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) { 9974 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) {
9968 if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) 9975 if (!(tr32(PCIE_TRANSACTION_CFG) & PCIE_TRANS_CFG_LOM)) {
9969 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT; 9976 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
9977 tp->tg3_flags2 |= TG3_FLG2_IS_NIC;
9978 }
9970 return; 9979 return;
9971 } 9980 }
9972 9981
@@ -10066,10 +10075,17 @@ static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
10066 tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL) 10075 tp->pdev->subsystem_vendor == PCI_VENDOR_ID_DELL)
10067 tp->led_ctrl = LED_CTRL_MODE_PHY_2; 10076 tp->led_ctrl = LED_CTRL_MODE_PHY_2;
10068 10077
10069 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) 10078 if (nic_cfg & NIC_SRAM_DATA_CFG_EEPROM_WP) {
10070 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT; 10079 tp->tg3_flags |= TG3_FLAG_EEPROM_WRITE_PROT;
10071 else 10080 if ((tp->pdev->subsystem_vendor ==
10081 PCI_VENDOR_ID_ARIMA) &&
10082 (tp->pdev->subsystem_device == 0x205a ||
10083 tp->pdev->subsystem_device == 0x2063))
10084 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
10085 } else {
10072 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT; 10086 tp->tg3_flags &= ~TG3_FLAG_EEPROM_WRITE_PROT;
10087 tp->tg3_flags2 |= TG3_FLG2_IS_NIC;
10088 }
10073 10089
10074 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) { 10090 if (nic_cfg & NIC_SRAM_DATA_CFG_ASF_ENABLE) {
10075 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF; 10091 tp->tg3_flags |= TG3_FLAG_ENABLE_ASF;
@@ -10147,7 +10163,7 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
10147 10163
10148 if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) && 10164 if (!(tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) &&
10149 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) { 10165 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
10150 u32 bmsr, adv_reg, tg3_ctrl; 10166 u32 bmsr, adv_reg, tg3_ctrl, mask;
10151 10167
10152 tg3_readphy(tp, MII_BMSR, &bmsr); 10168 tg3_readphy(tp, MII_BMSR, &bmsr);
10153 if (!tg3_readphy(tp, MII_BMSR, &bmsr) && 10169 if (!tg3_readphy(tp, MII_BMSR, &bmsr) &&
@@ -10171,7 +10187,10 @@ static int __devinit tg3_phy_probe(struct tg3 *tp)
10171 MII_TG3_CTRL_ENABLE_AS_MASTER); 10187 MII_TG3_CTRL_ENABLE_AS_MASTER);
10172 } 10188 }
10173 10189
10174 if (!tg3_copper_is_advertising_all(tp)) { 10190 mask = (ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full |
10191 ADVERTISED_100baseT_Half | ADVERTISED_100baseT_Full |
10192 ADVERTISED_1000baseT_Half | ADVERTISED_1000baseT_Full);
10193 if (!tg3_copper_is_advertising_all(tp, mask)) {
10175 tg3_writephy(tp, MII_ADVERTISE, adv_reg); 10194 tg3_writephy(tp, MII_ADVERTISE, adv_reg);
10176 10195
10177 if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY)) 10196 if (!(tp->tg3_flags & TG3_FLAG_10_100_ONLY))
@@ -10695,7 +10714,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10695 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG; 10714 tp->tg3_flags |= TG3_FLAG_SRAM_USE_CONFIG;
10696 10715
10697 /* Get eeprom hw config before calling tg3_set_power_state(). 10716 /* Get eeprom hw config before calling tg3_set_power_state().
10698 * In particular, the TG3_FLAG_EEPROM_WRITE_PROT flag must be 10717 * In particular, the TG3_FLG2_IS_NIC flag must be
10699 * determined before calling tg3_set_power_state() so that 10718 * determined before calling tg3_set_power_state() so that
10700 * we know whether or not to switch out of Vaux power. 10719 * we know whether or not to switch out of Vaux power.
10701 * When the flag is set, it means that GPIO1 is used for eeprom 10720 * When the flag is set, it means that GPIO1 is used for eeprom
@@ -10862,7 +10881,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
10862 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5705F)) || 10881 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5705F)) ||
10863 (tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM && 10882 (tp->pdev->vendor == PCI_VENDOR_ID_BROADCOM &&
10864 (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5751F || 10883 (tp->pdev->device == PCI_DEVICE_ID_TIGON3_5751F ||
10865 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5753F)) || 10884 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5753F ||
10885 tp->pdev->device == PCI_DEVICE_ID_TIGON3_5787F)) ||
10866 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906) 10886 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5906)
10867 tp->tg3_flags |= TG3_FLAG_10_100_ONLY; 10887 tp->tg3_flags |= TG3_FLAG_10_100_ONLY;
10868 10888
@@ -11912,13 +11932,15 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
11912 11932
11913 pci_set_drvdata(pdev, dev); 11933 pci_set_drvdata(pdev, dev);
11914 11934
11915 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %sBaseT Ethernet ", 11935 printk(KERN_INFO "%s: Tigon3 [partno(%s) rev %04x PHY(%s)] (%s) %s Ethernet ",
11916 dev->name, 11936 dev->name,
11917 tp->board_part_number, 11937 tp->board_part_number,
11918 tp->pci_chip_rev_id, 11938 tp->pci_chip_rev_id,
11919 tg3_phy_string(tp), 11939 tg3_phy_string(tp),
11920 tg3_bus_string(tp, str), 11940 tg3_bus_string(tp, str),
11921 (tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100" : "10/100/1000"); 11941 ((tp->tg3_flags & TG3_FLAG_10_100_ONLY) ? "10/100Base-TX" :
11942 ((tp->tg3_flags2 & TG3_FLG2_ANY_SERDES) ? "1000Base-SX" :
11943 "10/100/1000Base-T")));
11922 11944
11923 for (i = 0; i < 6; i++) 11945 for (i = 0; i < 6; i++)
11924 printk("%2.2x%c", dev->dev_addr[i], 11946 printk("%2.2x%c", dev->dev_addr[i],
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index 92f53000bce6..dfaf4ed127bd 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -2233,6 +2233,7 @@ struct tg3 {
2233#define TG3_FLG2_PCI_EXPRESS 0x00000200 2233#define TG3_FLG2_PCI_EXPRESS 0x00000200
2234#define TG3_FLG2_ASF_NEW_HANDSHAKE 0x00000400 2234#define TG3_FLG2_ASF_NEW_HANDSHAKE 0x00000400
2235#define TG3_FLG2_HW_AUTONEG 0x00000800 2235#define TG3_FLG2_HW_AUTONEG 0x00000800
2236#define TG3_FLG2_IS_NIC 0x00001000
2236#define TG3_FLG2_PHY_SERDES 0x00002000 2237#define TG3_FLG2_PHY_SERDES 0x00002000
2237#define TG3_FLG2_CAPACITIVE_COUPLING 0x00004000 2238#define TG3_FLG2_CAPACITIVE_COUPLING 0x00004000
2238#define TG3_FLG2_FLASH 0x00008000 2239#define TG3_FLG2_FLASH 0x00008000
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c
index 46dabdb12071..cec282a6f62d 100644
--- a/drivers/net/tokenring/smctr.c
+++ b/drivers/net/tokenring/smctr.c
@@ -5706,7 +5706,7 @@ int __init init_module(void)
5706 return found ? 0 : -ENODEV; 5706 return found ? 0 : -ENODEV;
5707} 5707}
5708 5708
5709void cleanup_module(void) 5709void __exit cleanup_module(void)
5710{ 5710{
5711 int i; 5711 int i;
5712 5712
diff --git a/drivers/net/wd.c b/drivers/net/wd.c
index 41f1d6778849..7f38012b9c92 100644
--- a/drivers/net/wd.c
+++ b/drivers/net/wd.c
@@ -538,7 +538,7 @@ static void cleanup_card(struct net_device *dev)
538 iounmap(ei_status.mem); 538 iounmap(ei_status.mem);
539} 539}
540 540
541void 541void __exit
542cleanup_module(void) 542cleanup_module(void)
543{ 543{
544 int this_dev; 544 int this_dev;
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index efcdaf1c5f73..44a22701da97 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -49,6 +49,7 @@
49#include <asm/uaccess.h> 49#include <asm/uaccess.h>
50#include <net/ieee80211.h> 50#include <net/ieee80211.h>
51#include <linux/kthread.h> 51#include <linux/kthread.h>
52#include <linux/freezer.h>
52 53
53#include "airo.h" 54#include "airo.h"
54 55
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index 08bc57a4b895..974a8e5bec8b 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -1100,15 +1100,13 @@ static struct sta_info * ap_add_sta(struct ap_data *ap, u8 *addr)
1100{ 1100{
1101 struct sta_info *sta; 1101 struct sta_info *sta;
1102 1102
1103 sta = (struct sta_info *) 1103 sta = kzalloc(sizeof(struct sta_info), GFP_ATOMIC);
1104 kmalloc(sizeof(struct sta_info), GFP_ATOMIC);
1105 if (sta == NULL) { 1104 if (sta == NULL) {
1106 PDEBUG(DEBUG_AP, "AP: kmalloc failed\n"); 1105 PDEBUG(DEBUG_AP, "AP: kmalloc failed\n");
1107 return NULL; 1106 return NULL;
1108 } 1107 }
1109 1108
1110 /* initialize STA info data */ 1109 /* initialize STA info data */
1111 memset(sta, 0, sizeof(struct sta_info));
1112 sta->local = ap->local; 1110 sta->local = ap->local;
1113 skb_queue_head_init(&sta->tx_buf); 1111 skb_queue_head_init(&sta->tx_buf);
1114 memcpy(sta->addr, addr, ETH_ALEN); 1112 memcpy(sta->addr, addr, ETH_ALEN);
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index ee542ec6d6a8..8d8f4b9b8b07 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -563,12 +563,11 @@ static int prism2_config(struct pcmcia_device *link)
563 PDEBUG(DEBUG_FLOW, "prism2_config()\n"); 563 PDEBUG(DEBUG_FLOW, "prism2_config()\n");
564 564
565 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); 565 parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
566 hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); 566 hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
567 if (parse == NULL || hw_priv == NULL) { 567 if (parse == NULL || hw_priv == NULL) {
568 ret = -ENOMEM; 568 ret = -ENOMEM;
569 goto failed; 569 goto failed;
570 } 570 }
571 memset(hw_priv, 0, sizeof(*hw_priv));
572 571
573 tuple.Attributes = 0; 572 tuple.Attributes = 0;
574 tuple.TupleData = buf; 573 tuple.TupleData = buf;
diff --git a/drivers/net/wireless/hostap/hostap_download.c b/drivers/net/wireless/hostap/hostap_download.c
index ab26b52b3e76..24fc387bba67 100644
--- a/drivers/net/wireless/hostap/hostap_download.c
+++ b/drivers/net/wireless/hostap/hostap_download.c
@@ -685,14 +685,12 @@ static int prism2_download(local_info_t *local,
685 goto out; 685 goto out;
686 } 686 }
687 687
688 dl = kmalloc(sizeof(*dl) + param->num_areas * 688 dl = kzalloc(sizeof(*dl) + param->num_areas *
689 sizeof(struct prism2_download_data_area), GFP_KERNEL); 689 sizeof(struct prism2_download_data_area), GFP_KERNEL);
690 if (dl == NULL) { 690 if (dl == NULL) {
691 ret = -ENOMEM; 691 ret = -ENOMEM;
692 goto out; 692 goto out;
693 } 693 }
694 memset(dl, 0, sizeof(*dl) + param->num_areas *
695 sizeof(struct prism2_download_data_area));
696 dl->dl_cmd = param->dl_cmd; 694 dl->dl_cmd = param->dl_cmd;
697 dl->start_addr = param->start_addr; 695 dl->start_addr = param->start_addr;
698 dl->num_areas = param->num_areas; 696 dl->num_areas = param->num_areas;
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index c19e68636a1c..a394a23b9a20 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -347,14 +347,12 @@ static int hfa384x_cmd(struct net_device *dev, u16 cmd, u16 param0,
347 if (signal_pending(current)) 347 if (signal_pending(current))
348 return -EINTR; 348 return -EINTR;
349 349
350 entry = (struct hostap_cmd_queue *) 350 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
351 kmalloc(sizeof(*entry), GFP_ATOMIC);
352 if (entry == NULL) { 351 if (entry == NULL) {
353 printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n", 352 printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n",
354 dev->name); 353 dev->name);
355 return -ENOMEM; 354 return -ENOMEM;
356 } 355 }
357 memset(entry, 0, sizeof(*entry));
358 atomic_set(&entry->usecnt, 1); 356 atomic_set(&entry->usecnt, 1);
359 entry->type = CMD_SLEEP; 357 entry->type = CMD_SLEEP;
360 entry->cmd = cmd; 358 entry->cmd = cmd;
@@ -517,14 +515,12 @@ static int hfa384x_cmd_callback(struct net_device *dev, u16 cmd, u16 param0,
517 return -1; 515 return -1;
518 } 516 }
519 517
520 entry = (struct hostap_cmd_queue *) 518 entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
521 kmalloc(sizeof(*entry), GFP_ATOMIC);
522 if (entry == NULL) { 519 if (entry == NULL) {
523 printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc " 520 printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc "
524 "failed\n", dev->name); 521 "failed\n", dev->name);
525 return -ENOMEM; 522 return -ENOMEM;
526 } 523 }
527 memset(entry, 0, sizeof(*entry));
528 atomic_set(&entry->usecnt, 1); 524 atomic_set(&entry->usecnt, 1);
529 entry->type = CMD_CALLBACK; 525 entry->type = CMD_CALLBACK;
530 entry->cmd = cmd; 526 entry->cmd = cmd;
@@ -3016,14 +3012,12 @@ static int prism2_set_tim(struct net_device *dev, int aid, int set)
3016 iface = netdev_priv(dev); 3012 iface = netdev_priv(dev);
3017 local = iface->local; 3013 local = iface->local;
3018 3014
3019 new_entry = (struct set_tim_data *) 3015 new_entry = kzalloc(sizeof(*new_entry), GFP_ATOMIC);
3020 kmalloc(sizeof(*new_entry), GFP_ATOMIC);
3021 if (new_entry == NULL) { 3016 if (new_entry == NULL) {
3022 printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n", 3017 printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n",
3023 local->dev->name); 3018 local->dev->name);
3024 return -ENOMEM; 3019 return -ENOMEM;
3025 } 3020 }
3026 memset(new_entry, 0, sizeof(*new_entry));
3027 new_entry->aid = aid; 3021 new_entry->aid = aid;
3028 new_entry->set = set; 3022 new_entry->set = set;
3029 3023
diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c
index 5fd2b1ad7f5e..b6a02a02da74 100644
--- a/drivers/net/wireless/hostap/hostap_info.c
+++ b/drivers/net/wireless/hostap/hostap_info.c
@@ -327,11 +327,10 @@ static void prism2_info_hostscanresults(local_info_t *local,
327 ptr = (u8 *) pos; 327 ptr = (u8 *) pos;
328 328
329 new_count = left / result_size; 329 new_count = left / result_size;
330 results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result), 330 results = kcalloc(new_count, sizeof(struct hfa384x_hostscan_result),
331 GFP_ATOMIC); 331 GFP_ATOMIC);
332 if (results == NULL) 332 if (results == NULL)
333 return; 333 return;
334 memset(results, 0, new_count * sizeof(struct hfa384x_hostscan_result));
335 334
336 for (i = 0; i < new_count; i++) { 335 for (i = 0; i < new_count; i++) {
337 memcpy(&results[i], ptr, copy_len); 336 memcpy(&results[i], ptr, copy_len);
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index d061fb3443ff..3b7b8063ff1c 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -181,12 +181,10 @@ static int prism2_ioctl_siwencode(struct net_device *dev,
181 struct ieee80211_crypt_data *new_crypt; 181 struct ieee80211_crypt_data *new_crypt;
182 182
183 /* take WEP into use */ 183 /* take WEP into use */
184 new_crypt = (struct ieee80211_crypt_data *) 184 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
185 kmalloc(sizeof(struct ieee80211_crypt_data),
186 GFP_KERNEL); 185 GFP_KERNEL);
187 if (new_crypt == NULL) 186 if (new_crypt == NULL)
188 return -ENOMEM; 187 return -ENOMEM;
189 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
190 new_crypt->ops = ieee80211_get_crypto_ops("WEP"); 188 new_crypt->ops = ieee80211_get_crypto_ops("WEP");
191 if (!new_crypt->ops) { 189 if (!new_crypt->ops) {
192 request_module("ieee80211_crypt_wep"); 190 request_module("ieee80211_crypt_wep");
@@ -3320,14 +3318,12 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev,
3320 3318
3321 prism2_crypt_delayed_deinit(local, crypt); 3319 prism2_crypt_delayed_deinit(local, crypt);
3322 3320
3323 new_crypt = (struct ieee80211_crypt_data *) 3321 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
3324 kmalloc(sizeof(struct ieee80211_crypt_data),
3325 GFP_KERNEL); 3322 GFP_KERNEL);
3326 if (new_crypt == NULL) { 3323 if (new_crypt == NULL) {
3327 ret = -ENOMEM; 3324 ret = -ENOMEM;
3328 goto done; 3325 goto done;
3329 } 3326 }
3330 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
3331 new_crypt->ops = ops; 3327 new_crypt->ops = ops;
3332 new_crypt->priv = new_crypt->ops->init(i); 3328 new_crypt->priv = new_crypt->ops->init(i);
3333 if (new_crypt->priv == NULL) { 3329 if (new_crypt->priv == NULL) {
@@ -3538,14 +3534,12 @@ static int prism2_ioctl_set_encryption(local_info_t *local,
3538 3534
3539 prism2_crypt_delayed_deinit(local, crypt); 3535 prism2_crypt_delayed_deinit(local, crypt);
3540 3536
3541 new_crypt = (struct ieee80211_crypt_data *) 3537 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
3542 kmalloc(sizeof(struct ieee80211_crypt_data),
3543 GFP_KERNEL); 3538 GFP_KERNEL);
3544 if (new_crypt == NULL) { 3539 if (new_crypt == NULL) {
3545 ret = -ENOMEM; 3540 ret = -ENOMEM;
3546 goto done; 3541 goto done;
3547 } 3542 }
3548 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
3549 new_crypt->ops = ops; 3543 new_crypt->ops = ops;
3550 new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); 3544 new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
3551 if (new_crypt->priv == NULL) { 3545 if (new_crypt->priv == NULL) {
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index d1de9766c831..c4f6020baa9e 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -300,10 +300,9 @@ static int prism2_pci_probe(struct pci_dev *pdev,
300 struct hostap_interface *iface; 300 struct hostap_interface *iface;
301 struct hostap_pci_priv *hw_priv; 301 struct hostap_pci_priv *hw_priv;
302 302
303 hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); 303 hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
304 if (hw_priv == NULL) 304 if (hw_priv == NULL)
305 return -ENOMEM; 305 return -ENOMEM;
306 memset(hw_priv, 0, sizeof(*hw_priv));
307 306
308 if (pci_enable_device(pdev)) 307 if (pci_enable_device(pdev))
309 goto err_out_free; 308 goto err_out_free;
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index bc81b13a5a2a..e235e0647897 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -447,10 +447,9 @@ static int prism2_plx_probe(struct pci_dev *pdev,
447 int tmd7160; 447 int tmd7160;
448 struct hostap_plx_priv *hw_priv; 448 struct hostap_plx_priv *hw_priv;
449 449
450 hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); 450 hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
451 if (hw_priv == NULL) 451 if (hw_priv == NULL)
452 return -ENOMEM; 452 return -ENOMEM;
453 memset(hw_priv, 0, sizeof(*hw_priv));
454 453
455 if (pci_enable_device(pdev)) 454 if (pci_enable_device(pdev))
456 goto err_out_free; 455 goto err_out_free;
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 1bcd352a813b..dd9ba4aad7bb 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -6220,7 +6220,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev,
6220 /* Allocate and initialize the Tx/Rx queues and lists */ 6220 /* Allocate and initialize the Tx/Rx queues and lists */
6221 if (ipw2100_queues_allocate(priv)) { 6221 if (ipw2100_queues_allocate(priv)) {
6222 printk(KERN_WARNING DRV_NAME 6222 printk(KERN_WARNING DRV_NAME
6223 "Error calilng ipw2100_queues_allocate.\n"); 6223 "Error calling ipw2100_queues_allocate.\n");
6224 err = -ENOMEM; 6224 err = -ENOMEM;
6225 goto fail; 6225 goto fail;
6226 } 6226 }
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index e82e56bb85e1..22cb3fb7502e 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -70,7 +70,7 @@
70#define VQ 70#define VQ
71#endif 71#endif
72 72
73#define IPW2200_VERSION "1.1.4" VK VD VM VP VR VQ 73#define IPW2200_VERSION "1.2.0" VK VD VM VP VR VQ
74#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver" 74#define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver"
75#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" 75#define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation"
76#define DRV_VERSION IPW2200_VERSION 76#define DRV_VERSION IPW2200_VERSION
@@ -7677,7 +7677,8 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7677 7677
7678 /* Big bitfield of all the fields we provide in radiotap */ 7678 /* Big bitfield of all the fields we provide in radiotap */
7679 ipw_rt->rt_hdr.it_present = 7679 ipw_rt->rt_hdr.it_present =
7680 ((1 << IEEE80211_RADIOTAP_FLAGS) | 7680 ((1 << IEEE80211_RADIOTAP_TSFT) |
7681 (1 << IEEE80211_RADIOTAP_FLAGS) |
7681 (1 << IEEE80211_RADIOTAP_RATE) | 7682 (1 << IEEE80211_RADIOTAP_RATE) |
7682 (1 << IEEE80211_RADIOTAP_CHANNEL) | 7683 (1 << IEEE80211_RADIOTAP_CHANNEL) |
7683 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | 7684 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
@@ -7686,10 +7687,14 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv,
7686 7687
7687 /* Zero the flags, we'll add to them as we go */ 7688 /* Zero the flags, we'll add to them as we go */
7688 ipw_rt->rt_flags = 0; 7689 ipw_rt->rt_flags = 0;
7689 ipw_rt->rt_tsf = 0ULL; 7690 ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 |
7691 frame->parent_tsf[2] << 16 |
7692 frame->parent_tsf[1] << 8 |
7693 frame->parent_tsf[0]);
7690 7694
7691 /* Convert signal to DBM */ 7695 /* Convert signal to DBM */
7692 ipw_rt->rt_dbmsignal = antsignal; 7696 ipw_rt->rt_dbmsignal = antsignal;
7697 ipw_rt->rt_dbmnoise = frame->noise;
7693 7698
7694 /* Convert the channel data and set the flags */ 7699 /* Convert the channel data and set the flags */
7695 ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(received_channel)); 7700 ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(received_channel));
@@ -7889,7 +7894,8 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
7889 7894
7890 /* Big bitfield of all the fields we provide in radiotap */ 7895 /* Big bitfield of all the fields we provide in radiotap */
7891 ipw_rt->rt_hdr.it_present = 7896 ipw_rt->rt_hdr.it_present =
7892 ((1 << IEEE80211_RADIOTAP_FLAGS) | 7897 ((1 << IEEE80211_RADIOTAP_TSFT) |
7898 (1 << IEEE80211_RADIOTAP_FLAGS) |
7893 (1 << IEEE80211_RADIOTAP_RATE) | 7899 (1 << IEEE80211_RADIOTAP_RATE) |
7894 (1 << IEEE80211_RADIOTAP_CHANNEL) | 7900 (1 << IEEE80211_RADIOTAP_CHANNEL) |
7895 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | 7901 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) |
@@ -7898,7 +7904,10 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv,
7898 7904
7899 /* Zero the flags, we'll add to them as we go */ 7905 /* Zero the flags, we'll add to them as we go */
7900 ipw_rt->rt_flags = 0; 7906 ipw_rt->rt_flags = 0;
7901 ipw_rt->rt_tsf = 0ULL; 7907 ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 |
7908 frame->parent_tsf[2] << 16 |
7909 frame->parent_tsf[1] << 8 |
7910 frame->parent_tsf[0]);
7902 7911
7903 /* Convert to DBM */ 7912 /* Convert to DBM */
7904 ipw_rt->rt_dbmsignal = signal; 7913 ipw_rt->rt_dbmsignal = signal;
@@ -8297,7 +8306,7 @@ static void ipw_rx(struct ipw_priv *priv)
8297 ("Notification: subtype=%02X flags=%02X size=%d\n", 8306 ("Notification: subtype=%02X flags=%02X size=%d\n",
8298 pkt->u.notification.subtype, 8307 pkt->u.notification.subtype,
8299 pkt->u.notification.flags, 8308 pkt->u.notification.flags,
8300 pkt->u.notification.size); 8309 le16_to_cpu(pkt->u.notification.size));
8301 ipw_rx_notification(priv, &pkt->u.notification); 8310 ipw_rx_notification(priv, &pkt->u.notification);
8302 break; 8311 break;
8303 } 8312 }
@@ -11145,14 +11154,13 @@ static int ipw_up(struct ipw_priv *priv)
11145 return -EIO; 11154 return -EIO;
11146 11155
11147 if (cmdlog && !priv->cmdlog) { 11156 if (cmdlog && !priv->cmdlog) {
11148 priv->cmdlog = kmalloc(sizeof(*priv->cmdlog) * cmdlog, 11157 priv->cmdlog = kcalloc(cmdlog, sizeof(*priv->cmdlog),
11149 GFP_KERNEL); 11158 GFP_KERNEL);
11150 if (priv->cmdlog == NULL) { 11159 if (priv->cmdlog == NULL) {
11151 IPW_ERROR("Error allocating %d command log entries.\n", 11160 IPW_ERROR("Error allocating %d command log entries.\n",
11152 cmdlog); 11161 cmdlog);
11153 return -ENOMEM; 11162 return -ENOMEM;
11154 } else { 11163 } else {
11155 memset(priv->cmdlog, 0, sizeof(*priv->cmdlog) * cmdlog);
11156 priv->cmdlog_len = cmdlog; 11164 priv->cmdlog_len = cmdlog;
11157 } 11165 }
11158 } 11166 }
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index a87eb51886c8..96606ed10076 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -2141,11 +2141,9 @@ prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
2141 struct islpci_bss_wpa_ie, list); 2141 struct islpci_bss_wpa_ie, list);
2142 list_del(&bss->list); 2142 list_del(&bss->list);
2143 } else { 2143 } else {
2144 bss = kmalloc(sizeof (*bss), GFP_ATOMIC); 2144 bss = kzalloc(sizeof (*bss), GFP_ATOMIC);
2145 if (bss != NULL) { 2145 if (bss != NULL)
2146 priv->num_bss_wpa++; 2146 priv->num_bss_wpa++;
2147 memset(bss, 0, sizeof (*bss));
2148 }
2149 } 2147 }
2150 if (bss != NULL) { 2148 if (bss != NULL) {
2151 memcpy(bss->bssid, bssid, ETH_ALEN); 2149 memcpy(bss->bssid, bssid, ETH_ALEN);
@@ -2686,11 +2684,10 @@ prism2_ioctl_set_generic_element(struct net_device *ndev,
2686 return -EINVAL; 2684 return -EINVAL;
2687 2685
2688 alen = sizeof(*attach) + len; 2686 alen = sizeof(*attach) + len;
2689 attach = kmalloc(alen, GFP_KERNEL); 2687 attach = kzalloc(alen, GFP_KERNEL);
2690 if (attach == NULL) 2688 if (attach == NULL)
2691 return -ENOMEM; 2689 return -ENOMEM;
2692 2690
2693 memset(attach, 0, alen);
2694#define WLAN_FC_TYPE_MGMT 0 2691#define WLAN_FC_TYPE_MGMT 0
2695#define WLAN_FC_STYPE_ASSOC_REQ 0 2692#define WLAN_FC_STYPE_ASSOC_REQ 0
2696#define WLAN_FC_STYPE_REASSOC_REQ 2 2693#define WLAN_FC_STYPE_REASSOC_REQ 2
diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c
index fbc52b6a3024..e6cf9df2c206 100644
--- a/drivers/net/wireless/prism54/oid_mgt.c
+++ b/drivers/net/wireless/prism54/oid_mgt.c
@@ -235,12 +235,10 @@ mgt_init(islpci_private *priv)
235{ 235{
236 int i; 236 int i;
237 237
238 priv->mib = kmalloc(OID_NUM_LAST * sizeof (void *), GFP_KERNEL); 238 priv->mib = kcalloc(OID_NUM_LAST, sizeof (void *), GFP_KERNEL);
239 if (!priv->mib) 239 if (!priv->mib)
240 return -ENOMEM; 240 return -ENOMEM;
241 241
242 memset(priv->mib, 0, OID_NUM_LAST * sizeof (void *));
243
244 /* Alloc the cache */ 242 /* Alloc the cache */
245 for (i = 0; i < OID_NUM_LAST; i++) { 243 for (i = 0; i < OID_NUM_LAST; i++) {
246 if (isl_oid[i].flags & OID_FLAG_CACHED) { 244 if (isl_oid[i].flags & OID_FLAG_CACHED) {
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 8be99ebbe1cd..77e11ddad836 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -1673,3 +1673,16 @@ int zd_rfwritev_cr_locked(struct zd_chip *chip,
1673 1673
1674 return 0; 1674 return 0;
1675} 1675}
1676
1677int zd_chip_set_multicast_hash(struct zd_chip *chip,
1678 struct zd_mc_hash *hash)
1679{
1680 struct zd_ioreq32 ioreqs[] = {
1681 { CR_GROUP_HASH_P1, hash->low },
1682 { CR_GROUP_HASH_P2, hash->high },
1683 };
1684
1685 dev_dbg_f(zd_chip_dev(chip), "hash l 0x%08x h 0x%08x\n",
1686 ioreqs[0].value, ioreqs[1].value);
1687 return zd_iowrite32a(chip, ioreqs, ARRAY_SIZE(ioreqs));
1688}
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index ca892b9a6448..a4e3cee9b59d 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -390,10 +390,19 @@
390#define CR_BSSID_P1 CTL_REG(0x0618) 390#define CR_BSSID_P1 CTL_REG(0x0618)
391#define CR_BSSID_P2 CTL_REG(0x061C) 391#define CR_BSSID_P2 CTL_REG(0x061C)
392#define CR_BCN_PLCP_CFG CTL_REG(0x0620) 392#define CR_BCN_PLCP_CFG CTL_REG(0x0620)
393
394/* Group hash table for filtering incoming packets.
395 *
396 * The group hash table is 64 bit large and split over two parts. The first
397 * part is the lower part. The upper 6 bits of the last byte of the target
398 * address are used as index. Packets are received if the hash table bit is
399 * set. This is used for multicast handling, but for broadcasts (address
400 * ff:ff:ff:ff:ff:ff) the highest bit in the second table must also be set.
401 */
393#define CR_GROUP_HASH_P1 CTL_REG(0x0624) 402#define CR_GROUP_HASH_P1 CTL_REG(0x0624)
394#define CR_GROUP_HASH_P2 CTL_REG(0x0628) 403#define CR_GROUP_HASH_P2 CTL_REG(0x0628)
395#define CR_RX_TIMEOUT CTL_REG(0x062C)
396 404
405#define CR_RX_TIMEOUT CTL_REG(0x062C)
397/* Basic rates supported by the BSS. When producing ACK or CTS messages, the 406/* Basic rates supported by the BSS. When producing ACK or CTS messages, the
398 * device will use a rate in this table that is less than or equal to the rate 407 * device will use a rate in this table that is less than or equal to the rate
399 * of the incoming frame which prompted the response */ 408 * of the incoming frame which prompted the response */
@@ -864,4 +873,36 @@ u8 zd_rx_strength_percent(u8 rssi);
864 873
865u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status); 874u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status);
866 875
876struct zd_mc_hash {
877 u32 low;
878 u32 high;
879};
880
881static inline void zd_mc_clear(struct zd_mc_hash *hash)
882{
883 hash->low = 0;
884 /* The interfaces must always received broadcasts.
885 * The hash of the broadcast address ff:ff:ff:ff:ff:ff is 63.
886 */
887 hash->high = 0x80000000;
888}
889
890static inline void zd_mc_add_all(struct zd_mc_hash *hash)
891{
892 hash->low = hash->high = 0xffffffff;
893}
894
895static inline void zd_mc_add_addr(struct zd_mc_hash *hash, u8 *addr)
896{
897 unsigned int i = addr[5] >> 2;
898 if (i < 32) {
899 hash->low |= 1 << i;
900 } else {
901 hash->high |= 1 << (i-32);
902 }
903}
904
905int zd_chip_set_multicast_hash(struct zd_chip *chip,
906 struct zd_mc_hash *hash);
907
867#endif /* _ZD_CHIP_H */ 908#endif /* _ZD_CHIP_H */
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index f1573a9c2336..00ca704ece35 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -39,6 +39,8 @@ static void housekeeping_init(struct zd_mac *mac);
39static void housekeeping_enable(struct zd_mac *mac); 39static void housekeeping_enable(struct zd_mac *mac);
40static void housekeeping_disable(struct zd_mac *mac); 40static void housekeeping_disable(struct zd_mac *mac);
41 41
42static void set_multicast_hash_handler(struct work_struct *work);
43
42int zd_mac_init(struct zd_mac *mac, 44int zd_mac_init(struct zd_mac *mac,
43 struct net_device *netdev, 45 struct net_device *netdev,
44 struct usb_interface *intf) 46 struct usb_interface *intf)
@@ -55,6 +57,7 @@ int zd_mac_init(struct zd_mac *mac,
55 softmac_init(ieee80211_priv(netdev)); 57 softmac_init(ieee80211_priv(netdev));
56 zd_chip_init(&mac->chip, netdev, intf); 58 zd_chip_init(&mac->chip, netdev, intf);
57 housekeeping_init(mac); 59 housekeeping_init(mac);
60 INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler);
58 return 0; 61 return 0;
59} 62}
60 63
@@ -136,6 +139,7 @@ out:
136 139
137void zd_mac_clear(struct zd_mac *mac) 140void zd_mac_clear(struct zd_mac *mac)
138{ 141{
142 flush_workqueue(zd_workqueue);
139 zd_chip_clear(&mac->chip); 143 zd_chip_clear(&mac->chip);
140 ZD_ASSERT(!spin_is_locked(&mac->lock)); 144 ZD_ASSERT(!spin_is_locked(&mac->lock));
141 ZD_MEMCLEAR(mac, sizeof(struct zd_mac)); 145 ZD_MEMCLEAR(mac, sizeof(struct zd_mac));
@@ -256,6 +260,43 @@ int zd_mac_set_mac_address(struct net_device *netdev, void *p)
256 return 0; 260 return 0;
257} 261}
258 262
263static void set_multicast_hash_handler(struct work_struct *work)
264{
265 struct zd_mac *mac = container_of(work, struct zd_mac,
266 set_multicast_hash_work);
267 struct zd_mc_hash hash;
268
269 spin_lock_irq(&mac->lock);
270 hash = mac->multicast_hash;
271 spin_unlock_irq(&mac->lock);
272
273 zd_chip_set_multicast_hash(&mac->chip, &hash);
274}
275
276void zd_mac_set_multicast_list(struct net_device *dev)
277{
278 struct zd_mc_hash hash;
279 struct zd_mac *mac = zd_netdev_mac(dev);
280 struct dev_mc_list *mc;
281 unsigned long flags;
282
283 if (dev->flags & (IFF_PROMISC|IFF_ALLMULTI)) {
284 zd_mc_add_all(&hash);
285 } else {
286 zd_mc_clear(&hash);
287 for (mc = dev->mc_list; mc; mc = mc->next) {
288 dev_dbg_f(zd_mac_dev(mac), "mc addr " MAC_FMT "\n",
289 MAC_ARG(mc->dmi_addr));
290 zd_mc_add_addr(&hash, mc->dmi_addr);
291 }
292 }
293
294 spin_lock_irqsave(&mac->lock, flags);
295 mac->multicast_hash = hash;
296 spin_unlock_irqrestore(&mac->lock, flags);
297 queue_work(zd_workqueue, &mac->set_multicast_hash_work);
298}
299
259int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain) 300int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain)
260{ 301{
261 int r; 302 int r;
@@ -618,6 +659,9 @@ int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range)
618 range->we_version_compiled = WIRELESS_EXT; 659 range->we_version_compiled = WIRELESS_EXT;
619 range->we_version_source = 20; 660 range->we_version_source = 20;
620 661
662 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
663 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
664
621 ZD_ASSERT(!irqs_disabled()); 665 ZD_ASSERT(!irqs_disabled());
622 spin_lock_irq(&mac->lock); 666 spin_lock_irq(&mac->lock);
623 regdomain = mac->regdomain; 667 regdomain = mac->regdomain;
@@ -930,7 +974,8 @@ static int is_data_packet_for_us(struct ieee80211_device *ieee,
930 } 974 }
931 975
932 return memcmp(hdr->addr1, netdev->dev_addr, ETH_ALEN) == 0 || 976 return memcmp(hdr->addr1, netdev->dev_addr, ETH_ALEN) == 0 ||
933 is_multicast_ether_addr(hdr->addr1) || 977 (is_multicast_ether_addr(hdr->addr1) &&
978 memcmp(hdr->addr3, netdev->dev_addr, ETH_ALEN) != 0) ||
934 (netdev->flags & IFF_PROMISC); 979 (netdev->flags & IFF_PROMISC);
935} 980}
936 981
@@ -1062,10 +1107,8 @@ int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length)
1062 memcpy(skb_put(skb, length), buffer, length); 1107 memcpy(skb_put(skb, length), buffer, length);
1063 1108
1064 r = ieee80211_rx(ieee, skb, &stats); 1109 r = ieee80211_rx(ieee, skb, &stats);
1065 if (!r) { 1110 if (!r)
1066 ZD_ASSERT(in_irq()); 1111 dev_kfree_skb_any(skb);
1067 dev_kfree_skb_irq(skb);
1068 }
1069 return 0; 1112 return 0;
1070} 1113}
1071 1114
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index d4e8b870409d..f0cf05dc7d3e 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -133,6 +133,8 @@ struct zd_mac {
133 struct iw_statistics iw_stats; 133 struct iw_statistics iw_stats;
134 134
135 struct housekeeping housekeeping; 135 struct housekeeping housekeeping;
136 struct work_struct set_multicast_hash_work;
137 struct zd_mc_hash multicast_hash;
136 struct delayed_work set_rts_cts_work; 138 struct delayed_work set_rts_cts_work;
137 struct delayed_work set_basic_rates_work; 139 struct delayed_work set_basic_rates_work;
138 140
@@ -189,6 +191,7 @@ int zd_mac_init_hw(struct zd_mac *mac, u8 device_type);
189int zd_mac_open(struct net_device *netdev); 191int zd_mac_open(struct net_device *netdev);
190int zd_mac_stop(struct net_device *netdev); 192int zd_mac_stop(struct net_device *netdev);
191int zd_mac_set_mac_address(struct net_device *dev, void *p); 193int zd_mac_set_mac_address(struct net_device *dev, void *p);
194void zd_mac_set_multicast_list(struct net_device *netdev);
192 195
193int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length); 196int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length);
194 197
diff --git a/drivers/net/wireless/zd1211rw/zd_netdev.c b/drivers/net/wireless/zd1211rw/zd_netdev.c
index 60f1b0f6d45b..8bda48de31ef 100644
--- a/drivers/net/wireless/zd1211rw/zd_netdev.c
+++ b/drivers/net/wireless/zd1211rw/zd_netdev.c
@@ -242,7 +242,7 @@ struct net_device *zd_netdev_alloc(struct usb_interface *intf)
242 netdev->open = zd_mac_open; 242 netdev->open = zd_mac_open;
243 netdev->stop = zd_mac_stop; 243 netdev->stop = zd_mac_stop;
244 /* netdev->get_stats = */ 244 /* netdev->get_stats = */
245 /* netdev->set_multicast_list = */ 245 netdev->set_multicast_list = zd_mac_set_multicast_list;
246 netdev->set_mac_address = zd_mac_set_mac_address; 246 netdev->set_mac_address = zd_mac_set_mac_address;
247 netdev->wireless_handlers = &iw_handler_def; 247 netdev->wireless_handlers = &iw_handler_def;
248 /* netdev->ethtool_ops = */ 248 /* netdev->ethtool_ops = */
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index 39c96641bc72..b61c17b3e298 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -1975,7 +1975,7 @@ static int __devinit parport_ECPPS2_supported(struct parport *pb){return 0;}
1975/* --- IRQ detection -------------------------------------- */ 1975/* --- IRQ detection -------------------------------------- */
1976 1976
1977/* Only if supports ECP mode */ 1977/* Only if supports ECP mode */
1978static int __devinit programmable_irq_support(struct parport *pb) 1978static int programmable_irq_support(struct parport *pb)
1979{ 1979{
1980 int irq, intrLine; 1980 int irq, intrLine;
1981 unsigned char oecr = inb (ECONTROL (pb)); 1981 unsigned char oecr = inb (ECONTROL (pb));
@@ -1992,7 +1992,7 @@ static int __devinit programmable_irq_support(struct parport *pb)
1992 return irq; 1992 return irq;
1993} 1993}
1994 1994
1995static int __devinit irq_probe_ECP(struct parport *pb) 1995static int irq_probe_ECP(struct parport *pb)
1996{ 1996{
1997 int i; 1997 int i;
1998 unsigned long irqs; 1998 unsigned long irqs;
@@ -2020,7 +2020,7 @@ static int __devinit irq_probe_ECP(struct parport *pb)
2020 * This detection seems that only works in National Semiconductors 2020 * This detection seems that only works in National Semiconductors
2021 * This doesn't work in SMC, LGS, and Winbond 2021 * This doesn't work in SMC, LGS, and Winbond
2022 */ 2022 */
2023static int __devinit irq_probe_EPP(struct parport *pb) 2023static int irq_probe_EPP(struct parport *pb)
2024{ 2024{
2025#ifndef ADVANCED_DETECT 2025#ifndef ADVANCED_DETECT
2026 return PARPORT_IRQ_NONE; 2026 return PARPORT_IRQ_NONE;
@@ -2059,7 +2059,7 @@ static int __devinit irq_probe_EPP(struct parport *pb)
2059#endif /* Advanced detection */ 2059#endif /* Advanced detection */
2060} 2060}
2061 2061
2062static int __devinit irq_probe_SPP(struct parport *pb) 2062static int irq_probe_SPP(struct parport *pb)
2063{ 2063{
2064 /* Don't even try to do this. */ 2064 /* Don't even try to do this. */
2065 return PARPORT_IRQ_NONE; 2065 return PARPORT_IRQ_NONE;
@@ -2747,6 +2747,7 @@ enum parport_pc_pci_cards {
2747 titan_1284p2, 2747 titan_1284p2,
2748 avlab_1p, 2748 avlab_1p,
2749 avlab_2p, 2749 avlab_2p,
2750 oxsemi_952,
2750 oxsemi_954, 2751 oxsemi_954,
2751 oxsemi_840, 2752 oxsemi_840,
2752 aks_0100, 2753 aks_0100,
@@ -2822,6 +2823,7 @@ static struct parport_pc_pci {
2822 /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} }, 2823 /* avlab_2p */ { 2, { { 0, 1}, { 2, 3 },} },
2823 /* The Oxford Semi cards are unusual: 954 doesn't support ECP, 2824 /* The Oxford Semi cards are unusual: 954 doesn't support ECP,
2824 * and 840 locks up if you write 1 to bit 2! */ 2825 * and 840 locks up if you write 1 to bit 2! */
2826 /* oxsemi_952 */ { 1, { { 0, 1 }, } },
2825 /* oxsemi_954 */ { 1, { { 0, -1 }, } }, 2827 /* oxsemi_954 */ { 1, { { 0, -1 }, } },
2826 /* oxsemi_840 */ { 1, { { 0, -1 }, } }, 2828 /* oxsemi_840 */ { 1, { { 0, -1 }, } },
2827 /* aks_0100 */ { 1, { { 0, -1 }, } }, 2829 /* aks_0100 */ { 1, { { 0, -1 }, } },
@@ -2895,6 +2897,8 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
2895 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/ 2897 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
2896 { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p}, /* AFAVLAB_TK9902 */ 2898 { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p}, /* AFAVLAB_TK9902 */
2897 { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p}, 2899 { 0x14db, 0x2121, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2p},
2900 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI952PP,
2901 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_952 },
2898 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954PP, 2902 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_16PCI954PP,
2899 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_954 }, 2903 PCI_ANY_ID, PCI_ANY_ID, 0, 0, oxsemi_954 },
2900 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_12PCI840, 2904 { PCI_VENDOR_ID_OXSEMI, PCI_DEVICE_ID_OXSEMI_12PCI840,
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 9fc9a34ef24a..9168401401bc 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -26,7 +26,7 @@
26 26
27static DEFINE_SPINLOCK(msi_lock); 27static DEFINE_SPINLOCK(msi_lock);
28static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL }; 28static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL };
29static kmem_cache_t* msi_cachep; 29static struct kmem_cache* msi_cachep;
30 30
31static int pci_msi_enable = 1; 31static int pci_msi_enable = 1;
32 32
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0eeac60042b3..6a3c1e728900 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -873,6 +873,7 @@ void __devinit pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
873 dev->dev.release = pci_release_dev; 873 dev->dev.release = pci_release_dev;
874 pci_dev_get(dev); 874 pci_dev_get(dev);
875 875
876 set_dev_node(&dev->dev, pcibus_to_node(bus));
876 dev->dev.dma_mask = &dev->dma_mask; 877 dev->dev.dma_mask = &dev->dma_mask;
877 dev->dev.coherent_dma_mask = 0xffffffffull; 878 dev->dev.coherent_dma_mask = 0xffffffffull;
878 879
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index f9cd831a3f31..606a46740338 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -29,6 +29,7 @@
29#include <linux/pci.h> 29#include <linux/pci.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/kthread.h> 31#include <linux/kthread.h>
32#include <linux/freezer.h>
32#include <asm/system.h> 33#include <asm/system.h>
33#include <asm/irq.h> 34#include <asm/irq.h>
34 35
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index 227600cd6360..91c047a7e635 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -164,9 +164,17 @@ static DEVICE_ATTR(card_id,S_IRUGO,pnp_show_card_ids,NULL);
164 164
165static int pnp_interface_attach_card(struct pnp_card *card) 165static int pnp_interface_attach_card(struct pnp_card *card)
166{ 166{
167 device_create_file(&card->dev,&dev_attr_name); 167 int rc = device_create_file(&card->dev,&dev_attr_name);
168 device_create_file(&card->dev,&dev_attr_card_id); 168 if (rc) return rc;
169
170 rc = device_create_file(&card->dev,&dev_attr_card_id);
171 if (rc) goto err_name;
172
169 return 0; 173 return 0;
174
175err_name:
176 device_remove_file(&card->dev,&dev_attr_name);
177 return rc;
170} 178}
171 179
172/** 180/**
@@ -306,16 +314,20 @@ found:
306 down_write(&dev->dev.bus->subsys.rwsem); 314 down_write(&dev->dev.bus->subsys.rwsem);
307 dev->card_link = clink; 315 dev->card_link = clink;
308 dev->dev.driver = &drv->link.driver; 316 dev->dev.driver = &drv->link.driver;
309 if (pnp_bus_type.probe(&dev->dev)) { 317 if (pnp_bus_type.probe(&dev->dev))
310 dev->dev.driver = NULL; 318 goto err_out;
311 dev->card_link = NULL; 319 if (device_bind_driver(&dev->dev))
312 up_write(&dev->dev.bus->subsys.rwsem); 320 goto err_out;
313 return NULL; 321
314 }
315 device_bind_driver(&dev->dev);
316 up_write(&dev->dev.bus->subsys.rwsem); 322 up_write(&dev->dev.bus->subsys.rwsem);
317 323
318 return dev; 324 return dev;
325
326err_out:
327 dev->dev.driver = NULL;
328 dev->card_link = NULL;
329 up_write(&dev->dev.bus->subsys.rwsem);
330 return NULL;
319} 331}
320 332
321/** 333/**
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 9d8b415eca79..ac9fcd499f3f 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -461,8 +461,19 @@ static DEVICE_ATTR(id,S_IRUGO,pnp_show_current_ids,NULL);
461 461
462int pnp_interface_attach_device(struct pnp_dev *dev) 462int pnp_interface_attach_device(struct pnp_dev *dev)
463{ 463{
464 device_create_file(&dev->dev,&dev_attr_options); 464 int rc = device_create_file(&dev->dev,&dev_attr_options);
465 device_create_file(&dev->dev,&dev_attr_resources); 465 if (rc) goto err;
466 device_create_file(&dev->dev,&dev_attr_id); 466 rc = device_create_file(&dev->dev,&dev_attr_resources);
467 if (rc) goto err_opt;
468 rc = device_create_file(&dev->dev,&dev_attr_id);
469 if (rc) goto err_res;
470
467 return 0; 471 return 0;
472
473err_res:
474 device_remove_file(&dev->dev,&dev_attr_resources);
475err_opt:
476 device_remove_file(&dev->dev,&dev_attr_options);
477err:
478 return rc;
468} 479}
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index 81a6c83d89a6..33adeba1a31f 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -61,6 +61,7 @@
61#include <linux/dmi.h> 61#include <linux/dmi.h>
62#include <linux/delay.h> 62#include <linux/delay.h>
63#include <linux/acpi.h> 63#include <linux/acpi.h>
64#include <linux/freezer.h>
64 65
65#include <asm/page.h> 66#include <asm/page.h>
66#include <asm/desc.h> 67#include <asm/desc.h>
@@ -530,7 +531,8 @@ static int __init pnpbios_init(void)
530 if (check_legacy_ioport(PNPBIOS_BASE)) 531 if (check_legacy_ioport(PNPBIOS_BASE))
531 return -ENODEV; 532 return -ENODEV;
532#endif 533#endif
533 if (pnpbios_disabled || dmi_check_system(pnpbios_dmi_table)) { 534 if (pnpbios_disabled || dmi_check_system(pnpbios_dmi_table) ||
535 paravirt_enabled()) {
534 printk(KERN_INFO "PnPBIOS: Disabled\n"); 536 printk(KERN_INFO "PnPBIOS: Disabled\n");
535 return -ENODEV; 537 return -ENODEV;
536 } 538 }
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index fc766a7a611e..2a63ab2b47f4 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -154,15 +154,23 @@ config RTC_DRV_DS1672
154 will be called rtc-ds1672. 154 will be called rtc-ds1672.
155 155
156config RTC_DRV_DS1742 156config RTC_DRV_DS1742
157 tristate "Dallas DS1742" 157 tristate "Dallas DS1742/1743"
158 depends on RTC_CLASS 158 depends on RTC_CLASS
159 help 159 help
160 If you say yes here you get support for the 160 If you say yes here you get support for the
161 Dallas DS1742 timekeeping chip. 161 Dallas DS1742/1743 timekeeping chip.
162 162
163 This driver can also be built as a module. If so, the module 163 This driver can also be built as a module. If so, the module
164 will be called rtc-ds1742. 164 will be called rtc-ds1742.
165 165
166config RTC_DRV_OMAP
167 tristate "TI OMAP1"
168 depends on RTC_CLASS && ( \
169 ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 )
170 help
171 Say "yes" here to support the real time clock on TI OMAP1 chips.
172 This driver can also be built as a module called rtc-omap.
173
166config RTC_DRV_PCF8563 174config RTC_DRV_PCF8563
167 tristate "Philips PCF8563/Epson RTC8564" 175 tristate "Philips PCF8563/Epson RTC8564"
168 depends on RTC_CLASS && I2C 176 depends on RTC_CLASS && I2C
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 3ba5ff6e6800..bd4c45d333f0 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o
21obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o 21obj-$(CONFIG_RTC_DRV_DS1307) += rtc-ds1307.o
22obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o 22obj-$(CONFIG_RTC_DRV_DS1672) += rtc-ds1672.o
23obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o 23obj-$(CONFIG_RTC_DRV_DS1742) += rtc-ds1742.o
24obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o
24obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o 25obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
25obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o 26obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
26obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o 27obj-$(CONFIG_RTC_DRV_RS5C372) += rtc-rs5c372.o
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c
index 67e816a9a39f..dfef1637bfb8 100644
--- a/drivers/rtc/rtc-ds1672.c
+++ b/drivers/rtc/rtc-ds1672.c
@@ -237,17 +237,22 @@ static int ds1672_probe(struct i2c_adapter *adapter, int address, int kind)
237 /* read control register */ 237 /* read control register */
238 err = ds1672_get_control(client, &control); 238 err = ds1672_get_control(client, &control);
239 if (err) 239 if (err)
240 goto exit_detach; 240 goto exit_devreg;
241 241
242 if (control & DS1672_REG_CONTROL_EOSC) 242 if (control & DS1672_REG_CONTROL_EOSC)
243 dev_warn(&client->dev, "Oscillator not enabled. " 243 dev_warn(&client->dev, "Oscillator not enabled. "
244 "Set time to enable.\n"); 244 "Set time to enable.\n");
245 245
246 /* Register sysfs hooks */ 246 /* Register sysfs hooks */
247 device_create_file(&client->dev, &dev_attr_control); 247 err = device_create_file(&client->dev, &dev_attr_control);
248 if (err)
249 goto exit_devreg;
248 250
249 return 0; 251 return 0;
250 252
253exit_devreg:
254 rtc_device_unregister(rtc);
255
251exit_detach: 256exit_detach:
252 i2c_detach_client(client); 257 i2c_detach_client(client);
253 258
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index 6273a3d240a2..17633bfa8480 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -6,6 +6,10 @@
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 *
10 * Copyright (C) 2006 Torsten Ertbjerg Rasmussen <tr@newtec.dk>
11 * - nvram size determined from resource
12 * - this ds1742 driver now supports ds1743.
9 */ 13 */
10 14
11#include <linux/bcd.h> 15#include <linux/bcd.h>
@@ -17,20 +21,19 @@
17#include <linux/platform_device.h> 21#include <linux/platform_device.h>
18#include <linux/io.h> 22#include <linux/io.h>
19 23
20#define DRV_VERSION "0.2" 24#define DRV_VERSION "0.3"
21 25
22#define RTC_REG_SIZE 0x800 26#define RTC_SIZE 8
23#define RTC_OFFSET 0x7f8
24 27
25#define RTC_CONTROL (RTC_OFFSET + 0) 28#define RTC_CONTROL 0
26#define RTC_CENTURY (RTC_OFFSET + 0) 29#define RTC_CENTURY 0
27#define RTC_SECONDS (RTC_OFFSET + 1) 30#define RTC_SECONDS 1
28#define RTC_MINUTES (RTC_OFFSET + 2) 31#define RTC_MINUTES 2
29#define RTC_HOURS (RTC_OFFSET + 3) 32#define RTC_HOURS 3
30#define RTC_DAY (RTC_OFFSET + 4) 33#define RTC_DAY 4
31#define RTC_DATE (RTC_OFFSET + 5) 34#define RTC_DATE 5
32#define RTC_MONTH (RTC_OFFSET + 6) 35#define RTC_MONTH 6
33#define RTC_YEAR (RTC_OFFSET + 7) 36#define RTC_YEAR 7
34 37
35#define RTC_CENTURY_MASK 0x3f 38#define RTC_CENTURY_MASK 0x3f
36#define RTC_SECONDS_MASK 0x7f 39#define RTC_SECONDS_MASK 0x7f
@@ -48,7 +51,10 @@
48 51
49struct rtc_plat_data { 52struct rtc_plat_data {
50 struct rtc_device *rtc; 53 struct rtc_device *rtc;
51 void __iomem *ioaddr; 54 void __iomem *ioaddr_nvram;
55 void __iomem *ioaddr_rtc;
56 size_t size_nvram;
57 size_t size;
52 unsigned long baseaddr; 58 unsigned long baseaddr;
53 unsigned long last_jiffies; 59 unsigned long last_jiffies;
54}; 60};
@@ -57,7 +63,7 @@ static int ds1742_rtc_set_time(struct device *dev, struct rtc_time *tm)
57{ 63{
58 struct platform_device *pdev = to_platform_device(dev); 64 struct platform_device *pdev = to_platform_device(dev);
59 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 65 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
60 void __iomem *ioaddr = pdata->ioaddr; 66 void __iomem *ioaddr = pdata->ioaddr_rtc;
61 u8 century; 67 u8 century;
62 68
63 century = BIN2BCD((tm->tm_year + 1900) / 100); 69 century = BIN2BCD((tm->tm_year + 1900) / 100);
@@ -82,7 +88,7 @@ static int ds1742_rtc_read_time(struct device *dev, struct rtc_time *tm)
82{ 88{
83 struct platform_device *pdev = to_platform_device(dev); 89 struct platform_device *pdev = to_platform_device(dev);
84 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 90 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
85 void __iomem *ioaddr = pdata->ioaddr; 91 void __iomem *ioaddr = pdata->ioaddr_rtc;
86 unsigned int year, month, day, hour, minute, second, week; 92 unsigned int year, month, day, hour, minute, second, week;
87 unsigned int century; 93 unsigned int century;
88 94
@@ -127,10 +133,10 @@ static ssize_t ds1742_nvram_read(struct kobject *kobj, char *buf,
127 struct platform_device *pdev = 133 struct platform_device *pdev =
128 to_platform_device(container_of(kobj, struct device, kobj)); 134 to_platform_device(container_of(kobj, struct device, kobj));
129 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 135 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
130 void __iomem *ioaddr = pdata->ioaddr; 136 void __iomem *ioaddr = pdata->ioaddr_nvram;
131 ssize_t count; 137 ssize_t count;
132 138
133 for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--) 139 for (count = 0; size > 0 && pos < pdata->size_nvram; count++, size--)
134 *buf++ = readb(ioaddr + pos++); 140 *buf++ = readb(ioaddr + pos++);
135 return count; 141 return count;
136} 142}
@@ -141,10 +147,10 @@ static ssize_t ds1742_nvram_write(struct kobject *kobj, char *buf,
141 struct platform_device *pdev = 147 struct platform_device *pdev =
142 to_platform_device(container_of(kobj, struct device, kobj)); 148 to_platform_device(container_of(kobj, struct device, kobj));
143 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 149 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
144 void __iomem *ioaddr = pdata->ioaddr; 150 void __iomem *ioaddr = pdata->ioaddr_nvram;
145 ssize_t count; 151 ssize_t count;
146 152
147 for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--) 153 for (count = 0; size > 0 && pos < pdata->size_nvram; count++, size--)
148 writeb(*buf++, ioaddr + pos++); 154 writeb(*buf++, ioaddr + pos++);
149 return count; 155 return count;
150} 156}
@@ -155,7 +161,6 @@ static struct bin_attribute ds1742_nvram_attr = {
155 .mode = S_IRUGO | S_IWUGO, 161 .mode = S_IRUGO | S_IWUGO,
156 .owner = THIS_MODULE, 162 .owner = THIS_MODULE,
157 }, 163 },
158 .size = RTC_OFFSET,
159 .read = ds1742_nvram_read, 164 .read = ds1742_nvram_read,
160 .write = ds1742_nvram_write, 165 .write = ds1742_nvram_write,
161}; 166};
@@ -175,19 +180,23 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
175 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 180 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
176 if (!pdata) 181 if (!pdata)
177 return -ENOMEM; 182 return -ENOMEM;
178 if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) { 183 pdata->size = res->end - res->start + 1;
184 if (!request_mem_region(res->start, pdata->size, pdev->name)) {
179 ret = -EBUSY; 185 ret = -EBUSY;
180 goto out; 186 goto out;
181 } 187 }
182 pdata->baseaddr = res->start; 188 pdata->baseaddr = res->start;
183 ioaddr = ioremap(pdata->baseaddr, RTC_REG_SIZE); 189 ioaddr = ioremap(pdata->baseaddr, pdata->size);
184 if (!ioaddr) { 190 if (!ioaddr) {
185 ret = -ENOMEM; 191 ret = -ENOMEM;
186 goto out; 192 goto out;
187 } 193 }
188 pdata->ioaddr = ioaddr; 194 pdata->ioaddr_nvram = ioaddr;
195 pdata->size_nvram = pdata->size - RTC_SIZE;
196 pdata->ioaddr_rtc = ioaddr + pdata->size_nvram;
189 197
190 /* turn RTC on if it was not on */ 198 /* turn RTC on if it was not on */
199 ioaddr = pdata->ioaddr_rtc;
191 sec = readb(ioaddr + RTC_SECONDS); 200 sec = readb(ioaddr + RTC_SECONDS);
192 if (sec & RTC_STOP) { 201 if (sec & RTC_STOP) {
193 sec &= RTC_SECONDS_MASK; 202 sec &= RTC_SECONDS_MASK;
@@ -208,6 +217,8 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
208 pdata->rtc = rtc; 217 pdata->rtc = rtc;
209 pdata->last_jiffies = jiffies; 218 pdata->last_jiffies = jiffies;
210 platform_set_drvdata(pdev, pdata); 219 platform_set_drvdata(pdev, pdata);
220 ds1742_nvram_attr.size = max(ds1742_nvram_attr.size,
221 pdata->size_nvram);
211 ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr); 222 ret = sysfs_create_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr);
212 if (ret) 223 if (ret)
213 goto out; 224 goto out;
@@ -215,10 +226,10 @@ static int __init ds1742_rtc_probe(struct platform_device *pdev)
215 out: 226 out:
216 if (pdata->rtc) 227 if (pdata->rtc)
217 rtc_device_unregister(pdata->rtc); 228 rtc_device_unregister(pdata->rtc);
218 if (ioaddr) 229 if (pdata->ioaddr_nvram)
219 iounmap(ioaddr); 230 iounmap(pdata->ioaddr_nvram);
220 if (pdata->baseaddr) 231 if (pdata->baseaddr)
221 release_mem_region(pdata->baseaddr, RTC_REG_SIZE); 232 release_mem_region(pdata->baseaddr, pdata->size);
222 kfree(pdata); 233 kfree(pdata);
223 return ret; 234 return ret;
224} 235}
@@ -229,8 +240,8 @@ static int __devexit ds1742_rtc_remove(struct platform_device *pdev)
229 240
230 sysfs_remove_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr); 241 sysfs_remove_bin_file(&pdev->dev.kobj, &ds1742_nvram_attr);
231 rtc_device_unregister(pdata->rtc); 242 rtc_device_unregister(pdata->rtc);
232 iounmap(pdata->ioaddr); 243 iounmap(pdata->ioaddr_nvram);
233 release_mem_region(pdata->baseaddr, RTC_REG_SIZE); 244 release_mem_region(pdata->baseaddr, pdata->size);
234 kfree(pdata); 245 kfree(pdata);
235 return 0; 246 return 0;
236} 247}
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
new file mode 100644
index 000000000000..eac5fb1fc02f
--- /dev/null
+++ b/drivers/rtc/rtc-omap.c
@@ -0,0 +1,572 @@
1/*
2 * TI OMAP1 Real Time Clock interface for Linux
3 *
4 * Copyright (C) 2003 MontaVista Software, Inc.
5 * Author: George G. Davis <gdavis@mvista.com> or <source@mvista.com>
6 *
7 * Copyright (C) 2006 David Brownell (new RTC framework)
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/ioport.h>
19#include <linux/delay.h>
20#include <linux/rtc.h>
21#include <linux/bcd.h>
22#include <linux/platform_device.h>
23
24#include <asm/io.h>
25#include <asm/mach/time.h>
26
27
28/* The OMAP1 RTC is a year/month/day/hours/minutes/seconds BCD clock
29 * with century-range alarm matching, driven by the 32kHz clock.
30 *
31 * The main user-visible ways it differs from PC RTCs are by omitting
32 * "don't care" alarm fields and sub-second periodic IRQs, and having
33 * an autoadjust mechanism to calibrate to the true oscillator rate.
34 *
35 * Board-specific wiring options include using split power mode with
36 * RTC_OFF_NOFF used as the reset signal (so the RTC won't be reset),
37 * and wiring RTC_WAKE_INT (so the RTC alarm can wake the system from
38 * low power modes). See the BOARD-SPECIFIC CUSTOMIZATION comment.
39 */
40
41#define OMAP_RTC_BASE 0xfffb4800
42
43/* RTC registers */
44#define OMAP_RTC_SECONDS_REG 0x00
45#define OMAP_RTC_MINUTES_REG 0x04
46#define OMAP_RTC_HOURS_REG 0x08
47#define OMAP_RTC_DAYS_REG 0x0C
48#define OMAP_RTC_MONTHS_REG 0x10
49#define OMAP_RTC_YEARS_REG 0x14
50#define OMAP_RTC_WEEKS_REG 0x18
51
52#define OMAP_RTC_ALARM_SECONDS_REG 0x20
53#define OMAP_RTC_ALARM_MINUTES_REG 0x24
54#define OMAP_RTC_ALARM_HOURS_REG 0x28
55#define OMAP_RTC_ALARM_DAYS_REG 0x2c
56#define OMAP_RTC_ALARM_MONTHS_REG 0x30
57#define OMAP_RTC_ALARM_YEARS_REG 0x34
58
59#define OMAP_RTC_CTRL_REG 0x40
60#define OMAP_RTC_STATUS_REG 0x44
61#define OMAP_RTC_INTERRUPTS_REG 0x48
62
63#define OMAP_RTC_COMP_LSB_REG 0x4c
64#define OMAP_RTC_COMP_MSB_REG 0x50
65#define OMAP_RTC_OSC_REG 0x54
66
67/* OMAP_RTC_CTRL_REG bit fields: */
68#define OMAP_RTC_CTRL_SPLIT (1<<7)
69#define OMAP_RTC_CTRL_DISABLE (1<<6)
70#define OMAP_RTC_CTRL_SET_32_COUNTER (1<<5)
71#define OMAP_RTC_CTRL_TEST (1<<4)
72#define OMAP_RTC_CTRL_MODE_12_24 (1<<3)
73#define OMAP_RTC_CTRL_AUTO_COMP (1<<2)
74#define OMAP_RTC_CTRL_ROUND_30S (1<<1)
75#define OMAP_RTC_CTRL_STOP (1<<0)
76
77/* OMAP_RTC_STATUS_REG bit fields: */
78#define OMAP_RTC_STATUS_POWER_UP (1<<7)
79#define OMAP_RTC_STATUS_ALARM (1<<6)
80#define OMAP_RTC_STATUS_1D_EVENT (1<<5)
81#define OMAP_RTC_STATUS_1H_EVENT (1<<4)
82#define OMAP_RTC_STATUS_1M_EVENT (1<<3)
83#define OMAP_RTC_STATUS_1S_EVENT (1<<2)
84#define OMAP_RTC_STATUS_RUN (1<<1)
85#define OMAP_RTC_STATUS_BUSY (1<<0)
86
87/* OMAP_RTC_INTERRUPTS_REG bit fields: */
88#define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3)
89#define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2)
90
91
92#define rtc_read(addr) omap_readb(OMAP_RTC_BASE + (addr))
93#define rtc_write(val, addr) omap_writeb(val, OMAP_RTC_BASE + (addr))
94
95
96/* platform_bus isn't hotpluggable, so for static linkage it'd be safe
97 * to get rid of probe() and remove() code ... too bad the driver struct
98 * remembers probe(), that's about 25% of the runtime footprint!!
99 */
100#ifndef MODULE
101#undef __devexit
102#undef __devexit_p
103#define __devexit __exit
104#define __devexit_p __exit_p
105#endif
106
107
108/* we rely on the rtc framework to handle locking (rtc->ops_lock),
109 * so the only other requirement is that register accesses which
110 * require BUSY to be clear are made with IRQs locally disabled
111 */
112static void rtc_wait_not_busy(void)
113{
114 int count = 0;
115 u8 status;
116
117 /* BUSY may stay active for 1/32768 second (~30 usec) */
118 for (count = 0; count < 50; count++) {
119 status = rtc_read(OMAP_RTC_STATUS_REG);
120 if ((status & (u8)OMAP_RTC_STATUS_BUSY) == 0)
121 break;
122 udelay(1);
123 }
124 /* now we have ~15 usec to read/write various registers */
125}
126
127static irqreturn_t rtc_irq(int irq, void *class_dev)
128{
129 unsigned long events = 0;
130 u8 irq_data;
131
132 irq_data = rtc_read(OMAP_RTC_STATUS_REG);
133
134 /* alarm irq? */
135 if (irq_data & OMAP_RTC_STATUS_ALARM) {
136 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
137 events |= RTC_IRQF | RTC_AF;
138 }
139
140 /* 1/sec periodic/update irq? */
141 if (irq_data & OMAP_RTC_STATUS_1S_EVENT)
142 events |= RTC_IRQF | RTC_UF;
143
144 rtc_update_irq(class_dev, 1, events);
145
146 return IRQ_HANDLED;
147}
148
149#ifdef CONFIG_RTC_INTF_DEV
150
151static int
152omap_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
153{
154 u8 reg;
155
156 switch (cmd) {
157 case RTC_AIE_OFF:
158 case RTC_AIE_ON:
159 case RTC_UIE_OFF:
160 case RTC_UIE_ON:
161 break;
162 default:
163 return -ENOIOCTLCMD;
164 }
165
166 local_irq_disable();
167 rtc_wait_not_busy();
168 reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
169 switch (cmd) {
170 /* AIE = Alarm Interrupt Enable */
171 case RTC_AIE_OFF:
172 reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
173 break;
174 case RTC_AIE_ON:
175 reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
176 break;
177 /* UIE = Update Interrupt Enable (1/second) */
178 case RTC_UIE_OFF:
179 reg &= ~OMAP_RTC_INTERRUPTS_IT_TIMER;
180 break;
181 case RTC_UIE_ON:
182 reg |= OMAP_RTC_INTERRUPTS_IT_TIMER;
183 break;
184 }
185 rtc_wait_not_busy();
186 rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
187 local_irq_enable();
188
189 return 0;
190}
191
192#else
193#define omap_rtc_ioctl NULL
194#endif
195
196/* this hardware doesn't support "don't care" alarm fields */
197static int tm2bcd(struct rtc_time *tm)
198{
199 if (rtc_valid_tm(tm) != 0)
200 return -EINVAL;
201
202 tm->tm_sec = BIN2BCD(tm->tm_sec);
203 tm->tm_min = BIN2BCD(tm->tm_min);
204 tm->tm_hour = BIN2BCD(tm->tm_hour);
205 tm->tm_mday = BIN2BCD(tm->tm_mday);
206
207 tm->tm_mon = BIN2BCD(tm->tm_mon + 1);
208
209 /* epoch == 1900 */
210 if (tm->tm_year < 100 || tm->tm_year > 199)
211 return -EINVAL;
212 tm->tm_year = BIN2BCD(tm->tm_year - 100);
213
214 return 0;
215}
216
217static void bcd2tm(struct rtc_time *tm)
218{
219 tm->tm_sec = BCD2BIN(tm->tm_sec);
220 tm->tm_min = BCD2BIN(tm->tm_min);
221 tm->tm_hour = BCD2BIN(tm->tm_hour);
222 tm->tm_mday = BCD2BIN(tm->tm_mday);
223 tm->tm_mon = BCD2BIN(tm->tm_mon) - 1;
224 /* epoch == 1900 */
225 tm->tm_year = BCD2BIN(tm->tm_year) + 100;
226}
227
228
229static int omap_rtc_read_time(struct device *dev, struct rtc_time *tm)
230{
231 /* we don't report wday/yday/isdst ... */
232 local_irq_disable();
233 rtc_wait_not_busy();
234
235 tm->tm_sec = rtc_read(OMAP_RTC_SECONDS_REG);
236 tm->tm_min = rtc_read(OMAP_RTC_MINUTES_REG);
237 tm->tm_hour = rtc_read(OMAP_RTC_HOURS_REG);
238 tm->tm_mday = rtc_read(OMAP_RTC_DAYS_REG);
239 tm->tm_mon = rtc_read(OMAP_RTC_MONTHS_REG);
240 tm->tm_year = rtc_read(OMAP_RTC_YEARS_REG);
241
242 local_irq_enable();
243
244 bcd2tm(tm);
245 return 0;
246}
247
248static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm)
249{
250 if (tm2bcd(tm) < 0)
251 return -EINVAL;
252 local_irq_disable();
253 rtc_wait_not_busy();
254
255 rtc_write(tm->tm_year, OMAP_RTC_YEARS_REG);
256 rtc_write(tm->tm_mon, OMAP_RTC_MONTHS_REG);
257 rtc_write(tm->tm_mday, OMAP_RTC_DAYS_REG);
258 rtc_write(tm->tm_hour, OMAP_RTC_HOURS_REG);
259 rtc_write(tm->tm_min, OMAP_RTC_MINUTES_REG);
260 rtc_write(tm->tm_sec, OMAP_RTC_SECONDS_REG);
261
262 local_irq_enable();
263
264 return 0;
265}
266
267static int omap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
268{
269 local_irq_disable();
270 rtc_wait_not_busy();
271
272 alm->time.tm_sec = rtc_read(OMAP_RTC_ALARM_SECONDS_REG);
273 alm->time.tm_min = rtc_read(OMAP_RTC_ALARM_MINUTES_REG);
274 alm->time.tm_hour = rtc_read(OMAP_RTC_ALARM_HOURS_REG);
275 alm->time.tm_mday = rtc_read(OMAP_RTC_ALARM_DAYS_REG);
276 alm->time.tm_mon = rtc_read(OMAP_RTC_ALARM_MONTHS_REG);
277 alm->time.tm_year = rtc_read(OMAP_RTC_ALARM_YEARS_REG);
278
279 local_irq_enable();
280
281 bcd2tm(&alm->time);
282 alm->pending = !!(rtc_read(OMAP_RTC_INTERRUPTS_REG)
283 & OMAP_RTC_INTERRUPTS_IT_ALARM);
284 alm->enabled = alm->pending && device_may_wakeup(dev);
285
286 return 0;
287}
288
289static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
290{
291 u8 reg;
292
293 /* Much userspace code uses RTC_ALM_SET, thus "don't care" for
294 * day/month/year specifies alarms up to 24 hours in the future.
295 * So we need to handle that ... but let's ignore the "don't care"
296 * values for hours/minutes/seconds.
297 */
298 if (alm->time.tm_mday <= 0
299 && alm->time.tm_mon < 0
300 && alm->time.tm_year < 0) {
301 struct rtc_time tm;
302 unsigned long now, then;
303
304 omap_rtc_read_time(dev, &tm);
305 rtc_tm_to_time(&tm, &now);
306
307 alm->time.tm_mday = tm.tm_mday;
308 alm->time.tm_mon = tm.tm_mon;
309 alm->time.tm_year = tm.tm_year;
310 rtc_tm_to_time(&alm->time, &then);
311
312 /* sometimes the alarm wraps into tomorrow */
313 if (then < now) {
314 rtc_time_to_tm(now + 24 * 60 * 60, &tm);
315 alm->time.tm_mday = tm.tm_mday;
316 alm->time.tm_mon = tm.tm_mon;
317 alm->time.tm_year = tm.tm_year;
318 }
319 }
320
321 if (tm2bcd(&alm->time) < 0)
322 return -EINVAL;
323
324 local_irq_disable();
325 rtc_wait_not_busy();
326
327 rtc_write(alm->time.tm_year, OMAP_RTC_ALARM_YEARS_REG);
328 rtc_write(alm->time.tm_mon, OMAP_RTC_ALARM_MONTHS_REG);
329 rtc_write(alm->time.tm_mday, OMAP_RTC_ALARM_DAYS_REG);
330 rtc_write(alm->time.tm_hour, OMAP_RTC_ALARM_HOURS_REG);
331 rtc_write(alm->time.tm_min, OMAP_RTC_ALARM_MINUTES_REG);
332 rtc_write(alm->time.tm_sec, OMAP_RTC_ALARM_SECONDS_REG);
333
334 reg = rtc_read(OMAP_RTC_INTERRUPTS_REG);
335 if (alm->enabled)
336 reg |= OMAP_RTC_INTERRUPTS_IT_ALARM;
337 else
338 reg &= ~OMAP_RTC_INTERRUPTS_IT_ALARM;
339 rtc_write(reg, OMAP_RTC_INTERRUPTS_REG);
340
341 local_irq_enable();
342
343 return 0;
344}
345
346static struct rtc_class_ops omap_rtc_ops = {
347 .ioctl = omap_rtc_ioctl,
348 .read_time = omap_rtc_read_time,
349 .set_time = omap_rtc_set_time,
350 .read_alarm = omap_rtc_read_alarm,
351 .set_alarm = omap_rtc_set_alarm,
352};
353
354static int omap_rtc_alarm;
355static int omap_rtc_timer;
356
357static int __devinit omap_rtc_probe(struct platform_device *pdev)
358{
359 struct resource *res, *mem;
360 struct rtc_device *rtc;
361 u8 reg, new_ctrl;
362
363 omap_rtc_timer = platform_get_irq(pdev, 0);
364 if (omap_rtc_timer <= 0) {
365 pr_debug("%s: no update irq?\n", pdev->name);
366 return -ENOENT;
367 }
368
369 omap_rtc_alarm = platform_get_irq(pdev, 1);
370 if (omap_rtc_alarm <= 0) {
371 pr_debug("%s: no alarm irq?\n", pdev->name);
372 return -ENOENT;
373 }
374
375 /* NOTE: using static mapping for RTC registers */
376 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
377 if (res && res->start != OMAP_RTC_BASE) {
378 pr_debug("%s: RTC registers at %08x, expected %08x\n",
379 pdev->name, (unsigned) res->start, OMAP_RTC_BASE);
380 return -ENOENT;
381 }
382
383 if (res)
384 mem = request_mem_region(res->start,
385 res->end - res->start + 1,
386 pdev->name);
387 else
388 mem = NULL;
389 if (!mem) {
390 pr_debug("%s: RTC registers at %08x are not free\n",
391 pdev->name, OMAP_RTC_BASE);
392 return -EBUSY;
393 }
394
395 rtc = rtc_device_register(pdev->name, &pdev->dev,
396 &omap_rtc_ops, THIS_MODULE);
397 if (IS_ERR(rtc)) {
398 pr_debug("%s: can't register RTC device, err %ld\n",
399 pdev->name, PTR_ERR(rtc));
400 goto fail;
401 }
402 platform_set_drvdata(pdev, rtc);
403 class_set_devdata(&rtc->class_dev, mem);
404
405 /* clear pending irqs, and set 1/second periodic,
406 * which we'll use instead of update irqs
407 */
408 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
409
410 /* clear old status */
411 reg = rtc_read(OMAP_RTC_STATUS_REG);
412 if (reg & (u8) OMAP_RTC_STATUS_POWER_UP) {
413 pr_info("%s: RTC power up reset detected\n",
414 pdev->name);
415 rtc_write(OMAP_RTC_STATUS_POWER_UP, OMAP_RTC_STATUS_REG);
416 }
417 if (reg & (u8) OMAP_RTC_STATUS_ALARM)
418 rtc_write(OMAP_RTC_STATUS_ALARM, OMAP_RTC_STATUS_REG);
419
420 /* handle periodic and alarm irqs */
421 if (request_irq(omap_rtc_timer, rtc_irq, SA_INTERRUPT,
422 rtc->class_dev.class_id, &rtc->class_dev)) {
423 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
424 pdev->name, omap_rtc_timer);
425 goto fail0;
426 }
427 if (request_irq(omap_rtc_alarm, rtc_irq, SA_INTERRUPT,
428 rtc->class_dev.class_id, &rtc->class_dev)) {
429 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
430 pdev->name, omap_rtc_alarm);
431 goto fail1;
432 }
433
434 /* On boards with split power, RTC_ON_NOFF won't reset the RTC */
435 reg = rtc_read(OMAP_RTC_CTRL_REG);
436 if (reg & (u8) OMAP_RTC_CTRL_STOP)
437 pr_info("%s: already running\n", pdev->name);
438
439 /* force to 24 hour mode */
440 new_ctrl = reg & ~(OMAP_RTC_CTRL_SPLIT|OMAP_RTC_CTRL_AUTO_COMP);
441 new_ctrl |= OMAP_RTC_CTRL_STOP;
442
443 /* BOARD-SPECIFIC CUSTOMIZATION CAN GO HERE:
444 *
445 * - Boards wired so that RTC_WAKE_INT does something, and muxed
446 * right (W13_1610_RTC_WAKE_INT is the default after chip reset),
447 * should initialize the device wakeup flag appropriately.
448 *
449 * - Boards wired so RTC_ON_nOFF is used as the reset signal,
450 * rather than nPWRON_RESET, should forcibly enable split
451 * power mode. (Some chip errata report that RTC_CTRL_SPLIT
452 * is write-only, and always reads as zero...)
453 */
454 device_init_wakeup(&pdev->dev, 0);
455
456 if (new_ctrl & (u8) OMAP_RTC_CTRL_SPLIT)
457 pr_info("%s: split power mode\n", pdev->name);
458
459 if (reg != new_ctrl)
460 rtc_write(new_ctrl, OMAP_RTC_CTRL_REG);
461
462 return 0;
463
464fail1:
465 free_irq(omap_rtc_timer, NULL);
466fail0:
467 rtc_device_unregister(rtc);
468fail:
469 release_resource(mem);
470 return -EIO;
471}
472
473static int __devexit omap_rtc_remove(struct platform_device *pdev)
474{
475 struct rtc_device *rtc = platform_get_drvdata(pdev);;
476
477 device_init_wakeup(&pdev->dev, 0);
478
479 /* leave rtc running, but disable irqs */
480 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
481
482 free_irq(omap_rtc_timer, rtc);
483 free_irq(omap_rtc_alarm, rtc);
484
485 release_resource(class_get_devdata(&rtc->class_dev));
486 rtc_device_unregister(rtc);
487 return 0;
488}
489
490#ifdef CONFIG_PM
491
492static struct timespec rtc_delta;
493static u8 irqstat;
494
495static int omap_rtc_suspend(struct platform_device *pdev, pm_message_t state)
496{
497 struct rtc_time rtc_tm;
498 struct timespec time;
499
500 time.tv_nsec = 0;
501 omap_rtc_read_time(NULL, &rtc_tm);
502 rtc_tm_to_time(&rtc_tm, &time.tv_sec);
503
504 save_time_delta(&rtc_delta, &time);
505 irqstat = rtc_read(OMAP_RTC_INTERRUPTS_REG);
506
507 /* FIXME the RTC alarm is not currently acting as a wakeup event
508 * source, and in fact this enable() call is just saving a flag
509 * that's never used...
510 */
511 if (device_may_wakeup(&pdev->dev))
512 enable_irq_wake(omap_rtc_alarm);
513 else
514 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
515
516 return 0;
517}
518
519static int omap_rtc_resume(struct platform_device *pdev)
520{
521 struct rtc_time rtc_tm;
522 struct timespec time;
523
524 time.tv_nsec = 0;
525 omap_rtc_read_time(NULL, &rtc_tm);
526 rtc_tm_to_time(&rtc_tm, &time.tv_sec);
527
528 restore_time_delta(&rtc_delta, &time);
529 if (device_may_wakeup(&pdev->dev))
530 disable_irq_wake(omap_rtc_alarm);
531 else
532 rtc_write(irqstat, OMAP_RTC_INTERRUPTS_REG);
533 return 0;
534}
535
536#else
537#define omap_rtc_suspend NULL
538#define omap_rtc_resume NULL
539#endif
540
541static void omap_rtc_shutdown(struct platform_device *pdev)
542{
543 rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
544}
545
546MODULE_ALIAS("omap_rtc");
547static struct platform_driver omap_rtc_driver = {
548 .probe = omap_rtc_probe,
549 .remove = __devexit_p(omap_rtc_remove),
550 .suspend = omap_rtc_suspend,
551 .resume = omap_rtc_resume,
552 .shutdown = omap_rtc_shutdown,
553 .driver = {
554 .name = "omap_rtc",
555 .owner = THIS_MODULE,
556 },
557};
558
559static int __init rtc_init(void)
560{
561 return platform_driver_register(&omap_rtc_driver);
562}
563module_init(rtc_init);
564
565static void __exit rtc_exit(void)
566{
567 platform_driver_unregister(&omap_rtc_driver);
568}
569module_exit(rtc_exit);
570
571MODULE_AUTHOR("George G. Davis (and others)");
572MODULE_LICENSE("GPL");
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index a44fe4efa216..e2c7698fdba3 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -13,7 +13,7 @@
13#include <linux/rtc.h> 13#include <linux/rtc.h>
14#include <linux/bcd.h> 14#include <linux/bcd.h>
15 15
16#define DRV_VERSION "0.2" 16#define DRV_VERSION "0.3"
17 17
18/* Addresses to scan */ 18/* Addresses to scan */
19static unsigned short normal_i2c[] = { /* 0x32,*/ I2C_CLIENT_END }; 19static unsigned short normal_i2c[] = { /* 0x32,*/ I2C_CLIENT_END };
@@ -39,6 +39,14 @@ static int rs5c372_attach(struct i2c_adapter *adapter);
39static int rs5c372_detach(struct i2c_client *client); 39static int rs5c372_detach(struct i2c_client *client);
40static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind); 40static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind);
41 41
42struct rs5c372 {
43 u8 reg_addr;
44 u8 regs[17];
45 struct i2c_msg msg[1];
46 struct i2c_client client;
47 struct rtc_device *rtc;
48};
49
42static struct i2c_driver rs5c372_driver = { 50static struct i2c_driver rs5c372_driver = {
43 .driver = { 51 .driver = {
44 .name = "rs5c372", 52 .name = "rs5c372",
@@ -49,18 +57,16 @@ static struct i2c_driver rs5c372_driver = {
49 57
50static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm) 58static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm)
51{ 59{
52 unsigned char buf[7] = { RS5C372_REG_BASE };
53 60
54 /* this implements the 1st reading method, according 61 struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
55 * to the datasheet. buf[0] is initialized with 62 u8 *buf = &(rs5c372->regs[1]);
56 * address ptr and transmission format register. 63
64 /* this implements the 3rd reading method, according
65 * to the datasheet. rs5c372 defaults to internal
66 * address 0xF, so 0x0 is in regs[1]
57 */ 67 */
58 struct i2c_msg msgs[] = {
59 { client->addr, 0, 1, buf },
60 { client->addr, I2C_M_RD, 7, buf },
61 };
62 68
63 if ((i2c_transfer(client->adapter, msgs, 2)) != 2) { 69 if ((i2c_transfer(client->adapter, rs5c372->msg, 1)) != 1) {
64 dev_err(&client->dev, "%s: read error\n", __FUNCTION__); 70 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
65 return -EIO; 71 return -EIO;
66 } 72 }
@@ -114,23 +120,14 @@ static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
114 120
115static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim) 121static int rs5c372_get_trim(struct i2c_client *client, int *osc, int *trim)
116{ 122{
117 unsigned char buf = RS5C372_REG_TRIM; 123 struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
118 124 u8 tmp = rs5c372->regs[RS5C372_REG_TRIM + 1];
119 struct i2c_msg msgs[] = {
120 { client->addr, 0, 1, &buf },
121 { client->addr, I2C_M_RD, 1, &buf },
122 };
123
124 if ((i2c_transfer(client->adapter, msgs, 2)) != 2) {
125 dev_err(&client->dev, "%s: read error\n", __FUNCTION__);
126 return -EIO;
127 }
128 125
129 if (osc) 126 if (osc)
130 *osc = (buf & RS5C372_TRIM_XSL) ? 32000 : 32768; 127 *osc = (tmp & RS5C372_TRIM_XSL) ? 32000 : 32768;
131 128
132 if (trim) { 129 if (trim) {
133 *trim = buf & RS5C372_TRIM_MASK; 130 *trim = tmp & RS5C372_TRIM_MASK;
134 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim); 131 dev_dbg(&client->dev, "%s: raw trim=%x\n", __FUNCTION__, *trim);
135 } 132 }
136 133
@@ -201,7 +198,7 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
201{ 198{
202 int err = 0; 199 int err = 0;
203 struct i2c_client *client; 200 struct i2c_client *client;
204 struct rtc_device *rtc; 201 struct rs5c372 *rs5c372;
205 202
206 dev_dbg(&adapter->dev, "%s\n", __FUNCTION__); 203 dev_dbg(&adapter->dev, "%s\n", __FUNCTION__);
207 204
@@ -210,10 +207,11 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
210 goto exit; 207 goto exit;
211 } 208 }
212 209
213 if (!(client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL))) { 210 if (!(rs5c372 = kzalloc(sizeof(struct rs5c372), GFP_KERNEL))) {
214 err = -ENOMEM; 211 err = -ENOMEM;
215 goto exit; 212 goto exit;
216 } 213 }
214 client = &rs5c372->client;
217 215
218 /* I2C client */ 216 /* I2C client */
219 client->addr = address; 217 client->addr = address;
@@ -222,32 +220,47 @@ static int rs5c372_probe(struct i2c_adapter *adapter, int address, int kind)
222 220
223 strlcpy(client->name, rs5c372_driver.driver.name, I2C_NAME_SIZE); 221 strlcpy(client->name, rs5c372_driver.driver.name, I2C_NAME_SIZE);
224 222
223 i2c_set_clientdata(client, rs5c372);
224
225 rs5c372->msg[0].addr = address;
226 rs5c372->msg[0].flags = I2C_M_RD;
227 rs5c372->msg[0].len = sizeof(rs5c372->regs);
228 rs5c372->msg[0].buf = rs5c372->regs;
229
225 /* Inform the i2c layer */ 230 /* Inform the i2c layer */
226 if ((err = i2c_attach_client(client))) 231 if ((err = i2c_attach_client(client)))
227 goto exit_kfree; 232 goto exit_kfree;
228 233
229 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n"); 234 dev_info(&client->dev, "chip found, driver version " DRV_VERSION "\n");
230 235
231 rtc = rtc_device_register(rs5c372_driver.driver.name, &client->dev, 236 rs5c372->rtc = rtc_device_register(rs5c372_driver.driver.name,
232 &rs5c372_rtc_ops, THIS_MODULE); 237 &client->dev, &rs5c372_rtc_ops, THIS_MODULE);
233 238
234 if (IS_ERR(rtc)) { 239 if (IS_ERR(rs5c372->rtc)) {
235 err = PTR_ERR(rtc); 240 err = PTR_ERR(rs5c372->rtc);
236 goto exit_detach; 241 goto exit_detach;
237 } 242 }
238 243
239 i2c_set_clientdata(client, rtc); 244 err = device_create_file(&client->dev, &dev_attr_trim);
240 245 if (err)
241 device_create_file(&client->dev, &dev_attr_trim); 246 goto exit_devreg;
242 device_create_file(&client->dev, &dev_attr_osc); 247 err = device_create_file(&client->dev, &dev_attr_osc);
248 if (err)
249 goto exit_trim;
243 250
244 return 0; 251 return 0;
245 252
253exit_trim:
254 device_remove_file(&client->dev, &dev_attr_trim);
255
256exit_devreg:
257 rtc_device_unregister(rs5c372->rtc);
258
246exit_detach: 259exit_detach:
247 i2c_detach_client(client); 260 i2c_detach_client(client);
248 261
249exit_kfree: 262exit_kfree:
250 kfree(client); 263 kfree(rs5c372);
251 264
252exit: 265exit:
253 return err; 266 return err;
@@ -256,16 +269,15 @@ exit:
256static int rs5c372_detach(struct i2c_client *client) 269static int rs5c372_detach(struct i2c_client *client)
257{ 270{
258 int err; 271 int err;
259 struct rtc_device *rtc = i2c_get_clientdata(client); 272 struct rs5c372 *rs5c372 = i2c_get_clientdata(client);
260 273
261 if (rtc) 274 if (rs5c372->rtc)
262 rtc_device_unregister(rtc); 275 rtc_device_unregister(rs5c372->rtc);
263 276
264 if ((err = i2c_detach_client(client))) 277 if ((err = i2c_detach_client(client)))
265 return err; 278 return err;
266 279
267 kfree(client); 280 kfree(rs5c372);
268
269 return 0; 281 return 0;
270} 282}
271 283
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c
index 6ef9c62d5032..f50a1b8e1607 100644
--- a/drivers/rtc/rtc-test.c
+++ b/drivers/rtc/rtc-test.c
@@ -123,11 +123,18 @@ static int test_probe(struct platform_device *plat_dev)
123 err = PTR_ERR(rtc); 123 err = PTR_ERR(rtc);
124 return err; 124 return err;
125 } 125 }
126 device_create_file(&plat_dev->dev, &dev_attr_irq); 126
127 err = device_create_file(&plat_dev->dev, &dev_attr_irq);
128 if (err)
129 goto err;
127 130
128 platform_set_drvdata(plat_dev, rtc); 131 platform_set_drvdata(plat_dev, rtc);
129 132
130 return 0; 133 return 0;
134
135err:
136 rtc_device_unregister(rtc);
137 return err;
131} 138}
132 139
133static int __devexit test_remove(struct platform_device *plat_dev) 140static int __devexit test_remove(struct platform_device *plat_dev)
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c
index 522c69753bbf..9a67487d086b 100644
--- a/drivers/rtc/rtc-x1205.c
+++ b/drivers/rtc/rtc-x1205.c
@@ -562,11 +562,19 @@ static int x1205_probe(struct i2c_adapter *adapter, int address, int kind)
562 else 562 else
563 dev_err(&client->dev, "couldn't read status\n"); 563 dev_err(&client->dev, "couldn't read status\n");
564 564
565 device_create_file(&client->dev, &dev_attr_atrim); 565 err = device_create_file(&client->dev, &dev_attr_atrim);
566 device_create_file(&client->dev, &dev_attr_dtrim); 566 if (err) goto exit_devreg;
567 err = device_create_file(&client->dev, &dev_attr_dtrim);
568 if (err) goto exit_atrim;
567 569
568 return 0; 570 return 0;
569 571
572exit_atrim:
573 device_remove_file(&client->dev, &dev_attr_atrim);
574
575exit_devreg:
576 rtc_device_unregister(rtc);
577
570exit_detach: 578exit_detach:
571 i2c_detach_client(client); 579 i2c_detach_client(client);
572 580
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 17fdd8c9f740..cf28ccc57948 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -25,7 +25,7 @@
25 25
26#include "dasd_int.h" 26#include "dasd_int.h"
27 27
28kmem_cache_t *dasd_page_cache; 28struct kmem_cache *dasd_page_cache;
29EXPORT_SYMBOL_GPL(dasd_page_cache); 29EXPORT_SYMBOL_GPL(dasd_page_cache);
30 30
31/* 31/*
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 5ecea3e4fdef..fdaa471e845f 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1215,7 +1215,7 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1215 dst = page_address(bv->bv_page) + bv->bv_offset; 1215 dst = page_address(bv->bv_page) + bv->bv_offset;
1216 if (dasd_page_cache) { 1216 if (dasd_page_cache) {
1217 char *copy = kmem_cache_alloc(dasd_page_cache, 1217 char *copy = kmem_cache_alloc(dasd_page_cache,
1218 SLAB_DMA | __GFP_NOWARN); 1218 GFP_DMA | __GFP_NOWARN);
1219 if (copy && rq_data_dir(req) == WRITE) 1219 if (copy && rq_data_dir(req) == WRITE)
1220 memcpy(copy + bv->bv_offset, dst, bv->bv_len); 1220 memcpy(copy + bv->bv_offset, dst, bv->bv_len);
1221 if (copy) 1221 if (copy)
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index 80926c548228..b857fd5893fd 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -308,7 +308,7 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
308 dst = page_address(bv->bv_page) + bv->bv_offset; 308 dst = page_address(bv->bv_page) + bv->bv_offset;
309 if (dasd_page_cache) { 309 if (dasd_page_cache) {
310 char *copy = kmem_cache_alloc(dasd_page_cache, 310 char *copy = kmem_cache_alloc(dasd_page_cache,
311 SLAB_DMA | __GFP_NOWARN); 311 GFP_DMA | __GFP_NOWARN);
312 if (copy && rq_data_dir(req) == WRITE) 312 if (copy && rq_data_dir(req) == WRITE)
313 memcpy(copy + bv->bv_offset, dst, bv->bv_len); 313 memcpy(copy + bv->bv_offset, dst, bv->bv_len);
314 if (copy) 314 if (copy)
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 9f52004f6fc2..dc5dd509434d 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -474,7 +474,7 @@ extern struct dasd_profile_info_t dasd_global_profile;
474extern unsigned int dasd_profile_level; 474extern unsigned int dasd_profile_level;
475extern struct block_device_operations dasd_device_operations; 475extern struct block_device_operations dasd_device_operations;
476 476
477extern kmem_cache_t *dasd_page_cache; 477extern struct kmem_cache *dasd_page_cache;
478 478
479struct dasd_ccw_req * 479struct dasd_ccw_req *
480dasd_kmalloc_request(char *, int, int, struct dasd_device *); 480dasd_kmalloc_request(char *, int, int, struct dasd_device *);
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 74c0eac083e4..32933ed54b8a 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -1032,9 +1032,9 @@ struct zfcp_data {
1032 wwn_t init_wwpn; 1032 wwn_t init_wwpn;
1033 fcp_lun_t init_fcp_lun; 1033 fcp_lun_t init_fcp_lun;
1034 char *driver_version; 1034 char *driver_version;
1035 kmem_cache_t *fsf_req_qtcb_cache; 1035 struct kmem_cache *fsf_req_qtcb_cache;
1036 kmem_cache_t *sr_buffer_cache; 1036 struct kmem_cache *sr_buffer_cache;
1037 kmem_cache_t *gid_pn_cache; 1037 struct kmem_cache *gid_pn_cache;
1038}; 1038};
1039 1039
1040/** 1040/**
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 277826cdd0c8..067f1519eb04 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -109,7 +109,7 @@ zfcp_fsf_req_alloc(mempool_t *pool, int req_flags)
109 ptr = kmalloc(size, GFP_ATOMIC); 109 ptr = kmalloc(size, GFP_ATOMIC);
110 else 110 else
111 ptr = kmem_cache_alloc(zfcp_data.fsf_req_qtcb_cache, 111 ptr = kmem_cache_alloc(zfcp_data.fsf_req_qtcb_cache,
112 SLAB_ATOMIC); 112 GFP_ATOMIC);
113 } 113 }
114 114
115 if (unlikely(!ptr)) 115 if (unlikely(!ptr))
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index 335a25540c08..68103e508db7 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -313,7 +313,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
313 hostdata->status = memory + STATUS_OFFSET; 313 hostdata->status = memory + STATUS_OFFSET;
314 /* all of these offsets are L1_CACHE_BYTES separated. It is fatal 314 /* all of these offsets are L1_CACHE_BYTES separated. It is fatal
315 * if this isn't sufficient separation to avoid dma flushing issues */ 315 * if this isn't sufficient separation to avoid dma flushing issues */
316 BUG_ON(!dma_is_consistent(pScript) && L1_CACHE_BYTES < dma_get_cache_alignment()); 316 BUG_ON(!dma_is_consistent(hostdata->dev, pScript) && L1_CACHE_BYTES < dma_get_cache_alignment());
317 hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET); 317 hostdata->slots = (struct NCR_700_command_slot *)(memory + SLOTS_OFFSET);
318 hostdata->dev = dev; 318 hostdata->dev = dev;
319 319
@@ -362,11 +362,11 @@ NCR_700_detect(struct scsi_host_template *tpnt,
362 for (j = 0; j < PATCHES; j++) 362 for (j = 0; j < PATCHES; j++)
363 script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]); 363 script[LABELPATCHES[j]] = bS_to_host(pScript + SCRIPT[LABELPATCHES[j]]);
364 /* now patch up fixed addresses. */ 364 /* now patch up fixed addresses. */
365 script_patch_32(script, MessageLocation, 365 script_patch_32(hostdata->dev, script, MessageLocation,
366 pScript + MSGOUT_OFFSET); 366 pScript + MSGOUT_OFFSET);
367 script_patch_32(script, StatusAddress, 367 script_patch_32(hostdata->dev, script, StatusAddress,
368 pScript + STATUS_OFFSET); 368 pScript + STATUS_OFFSET);
369 script_patch_32(script, ReceiveMsgAddress, 369 script_patch_32(hostdata->dev, script, ReceiveMsgAddress,
370 pScript + MSGIN_OFFSET); 370 pScript + MSGIN_OFFSET);
371 371
372 hostdata->script = script; 372 hostdata->script = script;
@@ -821,8 +821,9 @@ process_extended_message(struct Scsi_Host *host,
821 shost_printk(KERN_WARNING, host, 821 shost_printk(KERN_WARNING, host,
822 "Unexpected SDTR msg\n"); 822 "Unexpected SDTR msg\n");
823 hostdata->msgout[0] = A_REJECT_MSG; 823 hostdata->msgout[0] = A_REJECT_MSG;
824 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 824 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
825 script_patch_16(hostdata->script, MessageCount, 1); 825 script_patch_16(hostdata->dev, hostdata->script,
826 MessageCount, 1);
826 /* SendMsgOut returns, so set up the return 827 /* SendMsgOut returns, so set up the return
827 * address */ 828 * address */
828 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 829 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -833,8 +834,9 @@ process_extended_message(struct Scsi_Host *host,
833 printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n", 834 printk(KERN_INFO "scsi%d: (%d:%d), Unsolicited WDTR after CMD, Rejecting\n",
834 host->host_no, pun, lun); 835 host->host_no, pun, lun);
835 hostdata->msgout[0] = A_REJECT_MSG; 836 hostdata->msgout[0] = A_REJECT_MSG;
836 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 837 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
837 script_patch_16(hostdata->script, MessageCount, 1); 838 script_patch_16(hostdata->dev, hostdata->script, MessageCount,
839 1);
838 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 840 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
839 841
840 break; 842 break;
@@ -847,8 +849,9 @@ process_extended_message(struct Scsi_Host *host,
847 printk("\n"); 849 printk("\n");
848 /* just reject it */ 850 /* just reject it */
849 hostdata->msgout[0] = A_REJECT_MSG; 851 hostdata->msgout[0] = A_REJECT_MSG;
850 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 852 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
851 script_patch_16(hostdata->script, MessageCount, 1); 853 script_patch_16(hostdata->dev, hostdata->script, MessageCount,
854 1);
852 /* SendMsgOut returns, so set up the return 855 /* SendMsgOut returns, so set up the return
853 * address */ 856 * address */
854 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 857 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -929,8 +932,9 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata
929 printk("\n"); 932 printk("\n");
930 /* just reject it */ 933 /* just reject it */
931 hostdata->msgout[0] = A_REJECT_MSG; 934 hostdata->msgout[0] = A_REJECT_MSG;
932 dma_cache_sync(hostdata->msgout, 1, DMA_TO_DEVICE); 935 dma_cache_sync(hostdata->dev, hostdata->msgout, 1, DMA_TO_DEVICE);
933 script_patch_16(hostdata->script, MessageCount, 1); 936 script_patch_16(hostdata->dev, hostdata->script, MessageCount,
937 1);
934 /* SendMsgOut returns, so set up the return 938 /* SendMsgOut returns, so set up the return
935 * address */ 939 * address */
936 resume_offset = hostdata->pScript + Ent_SendMessageWithATN; 940 resume_offset = hostdata->pScript + Ent_SendMessageWithATN;
@@ -939,7 +943,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata
939 } 943 }
940 NCR_700_writel(temp, host, TEMP_REG); 944 NCR_700_writel(temp, host, TEMP_REG);
941 /* set us up to receive another message */ 945 /* set us up to receive another message */
942 dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE); 946 dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE, DMA_FROM_DEVICE);
943 return resume_offset; 947 return resume_offset;
944} 948}
945 949
@@ -1019,9 +1023,9 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1019 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN); 1023 slot->SG[1].ins = bS_to_host(SCRIPT_RETURN);
1020 slot->SG[1].pAddr = 0; 1024 slot->SG[1].pAddr = 0;
1021 slot->resume_offset = hostdata->pScript; 1025 slot->resume_offset = hostdata->pScript;
1022 dma_cache_sync(slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE); 1026 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG[0])*2, DMA_TO_DEVICE);
1023 dma_cache_sync(SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE); 1027 dma_cache_sync(hostdata->dev, SCp->sense_buffer, sizeof(SCp->sense_buffer), DMA_FROM_DEVICE);
1024 1028
1025 /* queue the command for reissue */ 1029 /* queue the command for reissue */
1026 slot->state = NCR_700_SLOT_QUEUED; 1030 slot->state = NCR_700_SLOT_QUEUED;
1027 slot->flags = NCR_700_FLAG_AUTOSENSE; 1031 slot->flags = NCR_700_FLAG_AUTOSENSE;
@@ -1136,11 +1140,12 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1136 hostdata->cmd = slot->cmnd; 1140 hostdata->cmd = slot->cmnd;
1137 1141
1138 /* re-patch for this command */ 1142 /* re-patch for this command */
1139 script_patch_32_abs(hostdata->script, CommandAddress, 1143 script_patch_32_abs(hostdata->dev, hostdata->script,
1140 slot->pCmd); 1144 CommandAddress, slot->pCmd);
1141 script_patch_16(hostdata->script, 1145 script_patch_16(hostdata->dev, hostdata->script,
1142 CommandCount, slot->cmnd->cmd_len); 1146 CommandCount, slot->cmnd->cmd_len);
1143 script_patch_32_abs(hostdata->script, SGScriptStartAddress, 1147 script_patch_32_abs(hostdata->dev, hostdata->script,
1148 SGScriptStartAddress,
1144 to32bit(&slot->pSG[0].ins)); 1149 to32bit(&slot->pSG[0].ins));
1145 1150
1146 /* Note: setting SXFER only works if we're 1151 /* Note: setting SXFER only works if we're
@@ -1150,13 +1155,13 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1150 * should therefore always clear ACK */ 1155 * should therefore always clear ACK */
1151 NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device), 1156 NCR_700_writeb(NCR_700_get_SXFER(hostdata->cmd->device),
1152 host, SXFER_REG); 1157 host, SXFER_REG);
1153 dma_cache_sync(hostdata->msgin, 1158 dma_cache_sync(hostdata->dev, hostdata->msgin,
1154 MSG_ARRAY_SIZE, DMA_FROM_DEVICE); 1159 MSG_ARRAY_SIZE, DMA_FROM_DEVICE);
1155 dma_cache_sync(hostdata->msgout, 1160 dma_cache_sync(hostdata->dev, hostdata->msgout,
1156 MSG_ARRAY_SIZE, DMA_TO_DEVICE); 1161 MSG_ARRAY_SIZE, DMA_TO_DEVICE);
1157 /* I'm just being paranoid here, the command should 1162 /* I'm just being paranoid here, the command should
1158 * already have been flushed from the cache */ 1163 * already have been flushed from the cache */
1159 dma_cache_sync(slot->cmnd->cmnd, 1164 dma_cache_sync(hostdata->dev, slot->cmnd->cmnd,
1160 slot->cmnd->cmd_len, DMA_TO_DEVICE); 1165 slot->cmnd->cmd_len, DMA_TO_DEVICE);
1161 1166
1162 1167
@@ -1220,7 +1225,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,
1220 hostdata->reselection_id = reselection_id; 1225 hostdata->reselection_id = reselection_id;
1221 /* just in case we have a stale simple tag message, clear it */ 1226 /* just in case we have a stale simple tag message, clear it */
1222 hostdata->msgin[1] = 0; 1227 hostdata->msgin[1] = 0;
1223 dma_cache_sync(hostdata->msgin, 1228 dma_cache_sync(hostdata->dev, hostdata->msgin,
1224 MSG_ARRAY_SIZE, DMA_BIDIRECTIONAL); 1229 MSG_ARRAY_SIZE, DMA_BIDIRECTIONAL);
1225 if(hostdata->tag_negotiated & (1<<reselection_id)) { 1230 if(hostdata->tag_negotiated & (1<<reselection_id)) {
1226 resume_offset = hostdata->pScript + Ent_GetReselectionWithTag; 1231 resume_offset = hostdata->pScript + Ent_GetReselectionWithTag;
@@ -1336,7 +1341,7 @@ process_selection(struct Scsi_Host *host, __u32 dsp)
1336 hostdata->cmd = NULL; 1341 hostdata->cmd = NULL;
1337 /* clear any stale simple tag message */ 1342 /* clear any stale simple tag message */
1338 hostdata->msgin[1] = 0; 1343 hostdata->msgin[1] = 0;
1339 dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, 1344 dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE,
1340 DMA_BIDIRECTIONAL); 1345 DMA_BIDIRECTIONAL);
1341 1346
1342 if(id == 0xff) { 1347 if(id == 0xff) {
@@ -1433,29 +1438,30 @@ NCR_700_start_command(struct scsi_cmnd *SCp)
1433 NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION); 1438 NCR_700_set_flag(SCp->device, NCR_700_DEV_BEGIN_SYNC_NEGOTIATION);
1434 } 1439 }
1435 1440
1436 script_patch_16(hostdata->script, MessageCount, count); 1441 script_patch_16(hostdata->dev, hostdata->script, MessageCount, count);
1437 1442
1438 1443
1439 script_patch_ID(hostdata->script, 1444 script_patch_ID(hostdata->dev, hostdata->script,
1440 Device_ID, 1<<scmd_id(SCp)); 1445 Device_ID, 1<<scmd_id(SCp));
1441 1446
1442 script_patch_32_abs(hostdata->script, CommandAddress, 1447 script_patch_32_abs(hostdata->dev, hostdata->script, CommandAddress,
1443 slot->pCmd); 1448 slot->pCmd);
1444 script_patch_16(hostdata->script, CommandCount, SCp->cmd_len); 1449 script_patch_16(hostdata->dev, hostdata->script, CommandCount,
1450 SCp->cmd_len);
1445 /* finally plumb the beginning of the SG list into the script 1451 /* finally plumb the beginning of the SG list into the script
1446 * */ 1452 * */
1447 script_patch_32_abs(hostdata->script, SGScriptStartAddress, 1453 script_patch_32_abs(hostdata->dev, hostdata->script,
1448 to32bit(&slot->pSG[0].ins)); 1454 SGScriptStartAddress, to32bit(&slot->pSG[0].ins));
1449 NCR_700_clear_fifo(SCp->device->host); 1455 NCR_700_clear_fifo(SCp->device->host);
1450 1456
1451 if(slot->resume_offset == 0) 1457 if(slot->resume_offset == 0)
1452 slot->resume_offset = hostdata->pScript; 1458 slot->resume_offset = hostdata->pScript;
1453 /* now perform all the writebacks and invalidates */ 1459 /* now perform all the writebacks and invalidates */
1454 dma_cache_sync(hostdata->msgout, count, DMA_TO_DEVICE); 1460 dma_cache_sync(hostdata->dev, hostdata->msgout, count, DMA_TO_DEVICE);
1455 dma_cache_sync(hostdata->msgin, MSG_ARRAY_SIZE, 1461 dma_cache_sync(hostdata->dev, hostdata->msgin, MSG_ARRAY_SIZE,
1456 DMA_FROM_DEVICE); 1462 DMA_FROM_DEVICE);
1457 dma_cache_sync(SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE); 1463 dma_cache_sync(hostdata->dev, SCp->cmnd, SCp->cmd_len, DMA_TO_DEVICE);
1458 dma_cache_sync(hostdata->status, 1, DMA_FROM_DEVICE); 1464 dma_cache_sync(hostdata->dev, hostdata->status, 1, DMA_FROM_DEVICE);
1459 1465
1460 /* set the synchronous period/offset */ 1466 /* set the synchronous period/offset */
1461 NCR_700_writeb(NCR_700_get_SXFER(SCp->device), 1467 NCR_700_writeb(NCR_700_get_SXFER(SCp->device),
@@ -1631,7 +1637,7 @@ NCR_700_intr(int irq, void *dev_id)
1631 slot->SG[i].ins = bS_to_host(SCRIPT_NOP); 1637 slot->SG[i].ins = bS_to_host(SCRIPT_NOP);
1632 slot->SG[i].pAddr = 0; 1638 slot->SG[i].pAddr = 0;
1633 } 1639 }
1634 dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); 1640 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
1635 /* and pretend we disconnected after 1641 /* and pretend we disconnected after
1636 * the command phase */ 1642 * the command phase */
1637 resume_offset = hostdata->pScript + Ent_MsgInDuringData; 1643 resume_offset = hostdata->pScript + Ent_MsgInDuringData;
@@ -1897,9 +1903,9 @@ NCR_700_queuecommand(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *))
1897 } 1903 }
1898 slot->SG[i].ins = bS_to_host(SCRIPT_RETURN); 1904 slot->SG[i].ins = bS_to_host(SCRIPT_RETURN);
1899 slot->SG[i].pAddr = 0; 1905 slot->SG[i].pAddr = 0;
1900 dma_cache_sync(slot->SG, sizeof(slot->SG), DMA_TO_DEVICE); 1906 dma_cache_sync(hostdata->dev, slot->SG, sizeof(slot->SG), DMA_TO_DEVICE);
1901 DEBUG((" SETTING %08lx to %x\n", 1907 DEBUG((" SETTING %08lx to %x\n",
1902 (&slot->pSG[i].ins), 1908 (&slot->pSG[i].ins),
1903 slot->SG[i].ins)); 1909 slot->SG[i].ins));
1904 } 1910 }
1905 slot->resume_offset = 0; 1911 slot->resume_offset = 0;
diff --git a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h
index f5c3caf344a7..f38822db4210 100644
--- a/drivers/scsi/53c700.h
+++ b/drivers/scsi/53c700.h
@@ -415,31 +415,31 @@ struct NCR_700_Host_Parameters {
415#define NCR_710_MIN_XFERP 0 415#define NCR_710_MIN_XFERP 0
416#define NCR_700_MIN_PERIOD 25 /* for SDTR message, 100ns */ 416#define NCR_700_MIN_PERIOD 25 /* for SDTR message, 100ns */
417 417
418#define script_patch_32(script, symbol, value) \ 418#define script_patch_32(dev, script, symbol, value) \
419{ \ 419{ \
420 int i; \ 420 int i; \
421 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 421 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
422 __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]) + value; \ 422 __u32 val = bS_to_cpu((script)[A_##symbol##_used[i]]) + value; \
423 (script)[A_##symbol##_used[i]] = bS_to_host(val); \ 423 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
424 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 424 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
425 DEBUG((" script, patching %s at %d to 0x%lx\n", \ 425 DEBUG((" script, patching %s at %d to 0x%lx\n", \
426 #symbol, A_##symbol##_used[i], (value))); \ 426 #symbol, A_##symbol##_used[i], (value))); \
427 } \ 427 } \
428} 428}
429 429
430#define script_patch_32_abs(script, symbol, value) \ 430#define script_patch_32_abs(dev, script, symbol, value) \
431{ \ 431{ \
432 int i; \ 432 int i; \
433 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 433 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
434 (script)[A_##symbol##_used[i]] = bS_to_host(value); \ 434 (script)[A_##symbol##_used[i]] = bS_to_host(value); \
435 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 435 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
436 DEBUG((" script, patching %s at %d to 0x%lx\n", \ 436 DEBUG((" script, patching %s at %d to 0x%lx\n", \
437 #symbol, A_##symbol##_used[i], (value))); \ 437 #symbol, A_##symbol##_used[i], (value))); \
438 } \ 438 } \
439} 439}
440 440
441/* Used for patching the SCSI ID in the SELECT instruction */ 441/* Used for patching the SCSI ID in the SELECT instruction */
442#define script_patch_ID(script, symbol, value) \ 442#define script_patch_ID(dev, script, symbol, value) \
443{ \ 443{ \
444 int i; \ 444 int i; \
445 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 445 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
@@ -447,13 +447,13 @@ struct NCR_700_Host_Parameters {
447 val &= 0xff00ffff; \ 447 val &= 0xff00ffff; \
448 val |= ((value) & 0xff) << 16; \ 448 val |= ((value) & 0xff) << 16; \
449 (script)[A_##symbol##_used[i]] = bS_to_host(val); \ 449 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
450 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 450 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
451 DEBUG((" script, patching ID field %s at %d to 0x%x\n", \ 451 DEBUG((" script, patching ID field %s at %d to 0x%x\n", \
452 #symbol, A_##symbol##_used[i], val)); \ 452 #symbol, A_##symbol##_used[i], val)); \
453 } \ 453 } \
454} 454}
455 455
456#define script_patch_16(script, symbol, value) \ 456#define script_patch_16(dev, script, symbol, value) \
457{ \ 457{ \
458 int i; \ 458 int i; \
459 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \ 459 for(i=0; i< (sizeof(A_##symbol##_used) / sizeof(__u32)); i++) { \
@@ -461,7 +461,7 @@ struct NCR_700_Host_Parameters {
461 val &= 0xffff0000; \ 461 val &= 0xffff0000; \
462 val |= ((value) & 0xffff); \ 462 val |= ((value) & 0xffff); \
463 (script)[A_##symbol##_used[i]] = bS_to_host(val); \ 463 (script)[A_##symbol##_used[i]] = bS_to_host(val); \
464 dma_cache_sync(&(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \ 464 dma_cache_sync((dev), &(script)[A_##symbol##_used[i]], 4, DMA_TO_DEVICE); \
465 DEBUG((" script, patching short field %s at %d to 0x%x\n", \ 465 DEBUG((" script, patching short field %s at %d to 0x%x\n", \
466 #symbol, A_##symbol##_used[i], val)); \ 466 #symbol, A_##symbol##_used[i], val)); \
467 } \ 467 } \
diff --git a/drivers/scsi/aic94xx/aic94xx.h b/drivers/scsi/aic94xx/aic94xx.h
index 71a031df7a34..32f513b1b78a 100644
--- a/drivers/scsi/aic94xx/aic94xx.h
+++ b/drivers/scsi/aic94xx/aic94xx.h
@@ -56,8 +56,8 @@
56/* 2*ITNL timeout + 1 second */ 56/* 2*ITNL timeout + 1 second */
57#define AIC94XX_SCB_TIMEOUT (5*HZ) 57#define AIC94XX_SCB_TIMEOUT (5*HZ)
58 58
59extern kmem_cache_t *asd_dma_token_cache; 59extern struct kmem_cache *asd_dma_token_cache;
60extern kmem_cache_t *asd_ascb_cache; 60extern struct kmem_cache *asd_ascb_cache;
61extern char sas_addr_str[2*SAS_ADDR_SIZE + 1]; 61extern char sas_addr_str[2*SAS_ADDR_SIZE + 1];
62 62
63static inline void asd_stringify_sas_addr(char *p, const u8 *sas_addr) 63static inline void asd_stringify_sas_addr(char *p, const u8 *sas_addr)
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c
index af7e01134364..da94e126ca83 100644
--- a/drivers/scsi/aic94xx/aic94xx_hwi.c
+++ b/drivers/scsi/aic94xx/aic94xx_hwi.c
@@ -1047,7 +1047,7 @@ irqreturn_t asd_hw_isr(int irq, void *dev_id)
1047static inline struct asd_ascb *asd_ascb_alloc(struct asd_ha_struct *asd_ha, 1047static inline struct asd_ascb *asd_ascb_alloc(struct asd_ha_struct *asd_ha,
1048 gfp_t gfp_flags) 1048 gfp_t gfp_flags)
1049{ 1049{
1050 extern kmem_cache_t *asd_ascb_cache; 1050 extern struct kmem_cache *asd_ascb_cache;
1051 struct asd_seq_data *seq = &asd_ha->seq; 1051 struct asd_seq_data *seq = &asd_ha->seq;
1052 struct asd_ascb *ascb; 1052 struct asd_ascb *ascb;
1053 unsigned long flags; 1053 unsigned long flags;
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index 42302ef05ee5..fbc82b00a418 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -450,8 +450,8 @@ static inline void asd_destroy_ha_caches(struct asd_ha_struct *asd_ha)
450 asd_ha->scb_pool = NULL; 450 asd_ha->scb_pool = NULL;
451} 451}
452 452
453kmem_cache_t *asd_dma_token_cache; 453struct kmem_cache *asd_dma_token_cache;
454kmem_cache_t *asd_ascb_cache; 454struct kmem_cache *asd_ascb_cache;
455 455
456static int asd_create_global_caches(void) 456static int asd_create_global_caches(void)
457{ 457{
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 1427a41e8441..8f6b5bf580f6 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -110,6 +110,7 @@ typedef struct ide_scsi_obj {
110} idescsi_scsi_t; 110} idescsi_scsi_t;
111 111
112static DEFINE_MUTEX(idescsi_ref_mutex); 112static DEFINE_MUTEX(idescsi_ref_mutex);
113static int idescsi_nocd; /* Set by module param to skip cd */
113 114
114#define ide_scsi_g(disk) \ 115#define ide_scsi_g(disk) \
115 container_of((disk)->private_data, struct ide_scsi_obj, driver) 116 container_of((disk)->private_data, struct ide_scsi_obj, driver)
@@ -1127,6 +1128,9 @@ static int ide_scsi_probe(ide_drive_t *drive)
1127 warned = 1; 1128 warned = 1;
1128 } 1129 }
1129 1130
1131 if (idescsi_nocd && drive->media == ide_cdrom)
1132 return -ENODEV;
1133
1130 if (!strstr("ide-scsi", drive->driver_req) || 1134 if (!strstr("ide-scsi", drive->driver_req) ||
1131 !drive->present || 1135 !drive->present ||
1132 drive->media == ide_disk || 1136 drive->media == ide_disk ||
@@ -1187,6 +1191,8 @@ static void __exit exit_idescsi_module(void)
1187 driver_unregister(&idescsi_driver.gen_driver); 1191 driver_unregister(&idescsi_driver.gen_driver);
1188} 1192}
1189 1193
1194module_param(idescsi_nocd, int, 0600);
1195MODULE_PARM_DESC(idescsi_nocd, "Disable handling of CD-ROMs so they may be driven by ide-cd");
1190module_init(init_idescsi_module); 1196module_init(init_idescsi_module);
1191module_exit(exit_idescsi_module); 1197module_exit(exit_idescsi_module);
1192MODULE_LICENSE("GPL"); 1198MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index ccd4dafce8e2..b318500785e5 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -6940,7 +6940,7 @@ static int __devinit ipr_alloc_cmd_blks(struct ipr_ioa_cfg *ioa_cfg)
6940 return -ENOMEM; 6940 return -ENOMEM;
6941 6941
6942 for (i = 0; i < IPR_NUM_CMD_BLKS; i++) { 6942 for (i = 0; i < IPR_NUM_CMD_BLKS; i++) {
6943 ipr_cmd = pci_pool_alloc (ioa_cfg->ipr_cmd_pool, SLAB_KERNEL, &dma_addr); 6943 ipr_cmd = pci_pool_alloc (ioa_cfg->ipr_cmd_pool, GFP_KERNEL, &dma_addr);
6944 6944
6945 if (!ipr_cmd) { 6945 if (!ipr_cmd) {
6946 ipr_free_cmd_blks(ioa_cfg); 6946 ipr_free_cmd_blks(ioa_cfg);
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index d65bc4e0f214..2f0c07fc3f48 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -36,7 +36,7 @@
36 36
37#include "../scsi_sas_internal.h" 37#include "../scsi_sas_internal.h"
38 38
39kmem_cache_t *sas_task_cache; 39struct kmem_cache *sas_task_cache;
40 40
41/*------------ SAS addr hash -----------*/ 41/*------------ SAS addr hash -----------*/
42void sas_hash_addr(u8 *hashed, const u8 *sas_addr) 42void sas_hash_addr(u8 *hashed, const u8 *sas_addr)
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index cbe0cad83b68..d03523d3bf38 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -24,7 +24,7 @@ char qla2x00_version_str[40];
24/* 24/*
25 * SRB allocation cache 25 * SRB allocation cache
26 */ 26 */
27static kmem_cache_t *srb_cachep; 27static struct kmem_cache *srb_cachep;
28 28
29/* 29/*
30 * Ioctl related information. 30 * Ioctl related information.
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 969c9e431028..9ef693c8809a 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -19,7 +19,7 @@ char qla4xxx_version_str[40];
19/* 19/*
20 * SRB allocation cache 20 * SRB allocation cache
21 */ 21 */
22static kmem_cache_t *srb_cachep; 22static struct kmem_cache *srb_cachep;
23 23
24/* 24/*
25 * Module parameter information and variables 25 * Module parameter information and variables
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index fafc00deaade..24cffd98ee63 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -136,7 +136,7 @@ const char * scsi_device_type(unsigned type)
136EXPORT_SYMBOL(scsi_device_type); 136EXPORT_SYMBOL(scsi_device_type);
137 137
138struct scsi_host_cmd_pool { 138struct scsi_host_cmd_pool {
139 kmem_cache_t *slab; 139 struct kmem_cache *slab;
140 unsigned int users; 140 unsigned int users;
141 char *name; 141 char *name;
142 unsigned int slab_flags; 142 unsigned int slab_flags;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index fb616c69151f..1748e27501cd 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -36,7 +36,7 @@
36struct scsi_host_sg_pool { 36struct scsi_host_sg_pool {
37 size_t size; 37 size_t size;
38 char *name; 38 char *name;
39 kmem_cache_t *slab; 39 struct kmem_cache *slab;
40 mempool_t *pool; 40 mempool_t *pool;
41}; 41};
42 42
@@ -241,7 +241,7 @@ struct scsi_io_context {
241 char sense[SCSI_SENSE_BUFFERSIZE]; 241 char sense[SCSI_SENSE_BUFFERSIZE];
242}; 242};
243 243
244static kmem_cache_t *scsi_io_context_cache; 244static struct kmem_cache *scsi_io_context_cache;
245 245
246static void scsi_end_async(struct request *req, int uptodate) 246static void scsi_end_async(struct request *req, int uptodate)
247{ 247{
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
index 386dbae17b44..d402aff5f314 100644
--- a/drivers/scsi/scsi_tgt_lib.c
+++ b/drivers/scsi/scsi_tgt_lib.c
@@ -33,7 +33,7 @@
33#include "scsi_tgt_priv.h" 33#include "scsi_tgt_priv.h"
34 34
35static struct workqueue_struct *scsi_tgtd; 35static struct workqueue_struct *scsi_tgtd;
36static kmem_cache_t *scsi_tgt_cmd_cache; 36static struct kmem_cache *scsi_tgt_cmd_cache;
37 37
38/* 38/*
39 * TODO: this struct will be killed when the block layer supports large bios 39 * TODO: this struct will be killed when the block layer supports large bios
diff --git a/drivers/serial/8250_exar_st16c554.c b/drivers/serial/8250_exar_st16c554.c
new file mode 100644
index 000000000000..567143ace159
--- /dev/null
+++ b/drivers/serial/8250_exar_st16c554.c
@@ -0,0 +1,52 @@
1/*
2 * linux/drivers/serial/8250_exar.c
3 *
4 * Written by Paul B Schroeder < pschroeder "at" uplogix "dot" com >
5 * Based on 8250_boca.
6 *
7 * Copyright (C) 2005 Russell King.
8 * Data taken from include/asm-i386/serial.h
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/serial_8250.h>
17
18#define PORT(_base,_irq) \
19 { \
20 .iobase = _base, \
21 .irq = _irq, \
22 .uartclk = 1843200, \
23 .iotype = UPIO_PORT, \
24 .flags = UPF_BOOT_AUTOCONF, \
25 }
26
27static struct plat_serial8250_port exar_data[] = {
28 PORT(0x100, 5),
29 PORT(0x108, 5),
30 PORT(0x110, 5),
31 PORT(0x118, 5),
32 { },
33};
34
35static struct platform_device exar_device = {
36 .name = "serial8250",
37 .id = PLAT8250_DEV_EXAR_ST16C554,
38 .dev = {
39 .platform_data = exar_data,
40 },
41};
42
43static int __init exar_init(void)
44{
45 return platform_device_register(&exar_device);
46}
47
48module_init(exar_init);
49
50MODULE_AUTHOR("Paul B Schroeder");
51MODULE_DESCRIPTION("8250 serial probe module for Exar cards");
52MODULE_LICENSE("GPL");
diff --git a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
index 71d907c8288b..d3d6b82706b5 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -464,11 +464,38 @@ static void __devexit serial_pnp_remove(struct pnp_dev *dev)
464 serial8250_unregister_port(line - 1); 464 serial8250_unregister_port(line - 1);
465} 465}
466 466
467#ifdef CONFIG_PM
468static int serial_pnp_suspend(struct pnp_dev *dev, pm_message_t state)
469{
470 long line = (long)pnp_get_drvdata(dev);
471
472 if (!line)
473 return -ENODEV;
474 serial8250_suspend_port(line - 1);
475 return 0;
476}
477
478static int serial_pnp_resume(struct pnp_dev *dev)
479{
480 long line = (long)pnp_get_drvdata(dev);
481
482 if (!line)
483 return -ENODEV;
484 serial8250_resume_port(line - 1);
485 return 0;
486}
487#else
488#define serial_pnp_suspend NULL
489#define serial_pnp_resume NULL
490#endif /* CONFIG_PM */
491
467static struct pnp_driver serial_pnp_driver = { 492static struct pnp_driver serial_pnp_driver = {
468 .name = "serial", 493 .name = "serial",
469 .id_table = pnp_dev_table,
470 .probe = serial_pnp_probe, 494 .probe = serial_pnp_probe,
471 .remove = __devexit_p(serial_pnp_remove), 495 .remove = __devexit_p(serial_pnp_remove),
496 .suspend = serial_pnp_suspend,
497 .resume = serial_pnp_resume,
498 .id_table = pnp_dev_table,
472}; 499};
473 500
474static int __init serial8250_pnp_init(void) 501static int __init serial8250_pnp_init(void)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 0b71e7d18903..fc12d5df10e2 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -210,6 +210,17 @@ config SERIAL_8250_BOCA
210 To compile this driver as a module, choose M here: the module 210 To compile this driver as a module, choose M here: the module
211 will be called 8250_boca. 211 will be called 8250_boca.
212 212
213config SERIAL_8250_EXAR_ST16C554
214 tristate "Support Exar ST16C554/554D Quad UART"
215 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
216 help
217 The Uplogix Envoy TU301 uses this Exar Quad UART. If you are
218 tinkering with your Envoy TU301, or have a machine with this UART,
219 say Y here.
220
221 To compile this driver as a module, choose M here: the module
222 will be called 8250_exar_st16c554.
223
213config SERIAL_8250_HUB6 224config SERIAL_8250_HUB6
214 tristate "Support Hub6 cards" 225 tristate "Support Hub6 cards"
215 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS 226 depends on SERIAL_8250 != n && ISA && SERIAL_8250_MANY_PORTS
@@ -511,6 +522,25 @@ config SERIAL_IMX_CONSOLE
511 your boot loader (lilo or loadlin) about how to pass options to the 522 your boot loader (lilo or loadlin) about how to pass options to the
512 kernel at boot time.) 523 kernel at boot time.)
513 524
525config SERIAL_UARTLITE
526 tristate "Xilinx uartlite serial port support"
527 depends on PPC32
528 select SERIAL_CORE
529 help
530 Say Y here if you want to use the Xilinx uartlite serial controller.
531
532 To compile this driver as a module, choose M here: the
533 module will be called uartlite.ko.
534
535config SERIAL_UARTLITE_CONSOLE
536 bool "Support for console on Xilinx uartlite serial port"
537 depends on SERIAL_UARTLITE=y
538 select SERIAL_CORE_CONSOLE
539 help
540 Say Y here if you wish to use a Xilinx uartlite as the system
541 console (the system console is the device which receives all kernel
542 messages and warnings and which allows logins in single user mode).
543
514config SERIAL_SUNCORE 544config SERIAL_SUNCORE
515 bool 545 bool
516 depends on SPARC 546 depends on SPARC
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index b4d8a7c182e3..df3632cd7df9 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_SERIAL_8250_CONSOLE) += 8250_early.o
17obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o 17obj-$(CONFIG_SERIAL_8250_FOURPORT) += 8250_fourport.o
18obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o 18obj-$(CONFIG_SERIAL_8250_ACCENT) += 8250_accent.o
19obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o 19obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o
20obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o
20obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o 21obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o
21obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o 22obj-$(CONFIG_SERIAL_8250_MCA) += 8250_mca.o
22obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o 23obj-$(CONFIG_SERIAL_8250_AU1X00) += 8250_au1x00.o
@@ -55,4 +56,5 @@ obj-$(CONFIG_SERIAL_VR41XX) += vr41xx_siu.o
55obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o 56obj-$(CONFIG_SERIAL_SGI_IOC4) += ioc4_serial.o
56obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o 57obj-$(CONFIG_SERIAL_SGI_IOC3) += ioc3_serial.o
57obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o 58obj-$(CONFIG_SERIAL_ATMEL) += atmel_serial.o
59obj-$(CONFIG_SERIAL_UARTLITE) += uartlite.o
58obj-$(CONFIG_SERIAL_NETX) += netx-serial.o 60obj-$(CONFIG_SERIAL_NETX) += netx-serial.o
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 4213fabc62bf..4d3626ef4643 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -129,6 +129,8 @@ static void pl010_rx_chars(struct uart_port *port)
129 */ 129 */
130 rsr = readb(port->membase + UART01x_RSR) | UART_DUMMY_RSR_RX; 130 rsr = readb(port->membase + UART01x_RSR) | UART_DUMMY_RSR_RX;
131 if (unlikely(rsr & UART01x_RSR_ANY)) { 131 if (unlikely(rsr & UART01x_RSR_ANY)) {
132 writel(0, port->membase + UART01x_ECR);
133
132 if (rsr & UART01x_RSR_BE) { 134 if (rsr & UART01x_RSR_BE) {
133 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE); 135 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
134 port->icount.brk++; 136 port->icount.brk++;
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index 53662b33b841..af1544f3356f 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -1,11 +1,13 @@
1/* 1/*
2 * dz.c: Serial port driver for DECStations equiped 2 * dz.c: Serial port driver for DECstations equipped
3 * with the DZ chipset. 3 * with the DZ chipset.
4 * 4 *
5 * Copyright (C) 1998 Olivier A. D. Lebaillif 5 * Copyright (C) 1998 Olivier A. D. Lebaillif
6 * 6 *
7 * Email: olivier.lebaillif@ifrsys.com 7 * Email: olivier.lebaillif@ifrsys.com
8 * 8 *
9 * Copyright (C) 2004, 2006 Maciej W. Rozycki
10 *
9 * [31-AUG-98] triemer 11 * [31-AUG-98] triemer
10 * Changed IRQ to use Harald's dec internals interrupts.h 12 * Changed IRQ to use Harald's dec internals interrupts.h
11 * removed base_addr code - moving address assignment to setup.c 13 * removed base_addr code - moving address assignment to setup.c
@@ -26,10 +28,16 @@
26 28
27#undef DEBUG_DZ 29#undef DEBUG_DZ
28 30
31#if defined(CONFIG_SERIAL_DZ_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
32#define SUPPORT_SYSRQ
33#endif
34
35#include <linux/delay.h>
29#include <linux/module.h> 36#include <linux/module.h>
30#include <linux/interrupt.h> 37#include <linux/interrupt.h>
31#include <linux/init.h> 38#include <linux/init.h>
32#include <linux/console.h> 39#include <linux/console.h>
40#include <linux/sysrq.h>
33#include <linux/tty.h> 41#include <linux/tty.h>
34#include <linux/tty_flip.h> 42#include <linux/tty_flip.h>
35#include <linux/serial_core.h> 43#include <linux/serial_core.h>
@@ -45,14 +53,10 @@
45#include <asm/system.h> 53#include <asm/system.h>
46#include <asm/uaccess.h> 54#include <asm/uaccess.h>
47 55
48#define CONSOLE_LINE (3) /* for definition of struct console */
49
50#include "dz.h" 56#include "dz.h"
51 57
52#define DZ_INTR_DEBUG 1
53
54static char *dz_name = "DECstation DZ serial driver version "; 58static char *dz_name = "DECstation DZ serial driver version ";
55static char *dz_version = "1.02"; 59static char *dz_version = "1.03";
56 60
57struct dz_port { 61struct dz_port {
58 struct uart_port port; 62 struct uart_port port;
@@ -61,22 +65,6 @@ struct dz_port {
61 65
62static struct dz_port dz_ports[DZ_NB_PORT]; 66static struct dz_port dz_ports[DZ_NB_PORT];
63 67
64#ifdef DEBUG_DZ
65/*
66 * debugging code to send out chars via prom
67 */
68static void debug_console(const char *s, int count)
69{
70 unsigned i;
71
72 for (i = 0; i < count; i++) {
73 if (*s == 10)
74 prom_printf("%c", 13);
75 prom_printf("%c", *s++);
76 }
77}
78#endif
79
80/* 68/*
81 * ------------------------------------------------------------ 69 * ------------------------------------------------------------
82 * dz_in () and dz_out () 70 * dz_in () and dz_out ()
@@ -90,6 +78,7 @@ static inline unsigned short dz_in(struct dz_port *dport, unsigned offset)
90{ 78{
91 volatile unsigned short *addr = 79 volatile unsigned short *addr =
92 (volatile unsigned short *) (dport->port.membase + offset); 80 (volatile unsigned short *) (dport->port.membase + offset);
81
93 return *addr; 82 return *addr;
94} 83}
95 84
@@ -98,6 +87,7 @@ static inline void dz_out(struct dz_port *dport, unsigned offset,
98{ 87{
99 volatile unsigned short *addr = 88 volatile unsigned short *addr =
100 (volatile unsigned short *) (dport->port.membase + offset); 89 (volatile unsigned short *) (dport->port.membase + offset);
90
101 *addr = value; 91 *addr = value;
102} 92}
103 93
@@ -144,7 +134,7 @@ static void dz_stop_rx(struct uart_port *uport)
144 134
145 spin_lock_irqsave(&dport->port.lock, flags); 135 spin_lock_irqsave(&dport->port.lock, flags);
146 dport->cflag &= ~DZ_CREAD; 136 dport->cflag &= ~DZ_CREAD;
147 dz_out(dport, DZ_LPR, dport->cflag); 137 dz_out(dport, DZ_LPR, dport->cflag | dport->port.line);
148 spin_unlock_irqrestore(&dport->port.lock, flags); 138 spin_unlock_irqrestore(&dport->port.lock, flags);
149} 139}
150 140
@@ -155,14 +145,14 @@ static void dz_enable_ms(struct uart_port *port)
155 145
156/* 146/*
157 * ------------------------------------------------------------ 147 * ------------------------------------------------------------
158 * Here starts the interrupt handling routines. All of the
159 * following subroutines are declared as inline and are folded
160 * into dz_interrupt. They were separated out for readability's
161 * sake.
162 * 148 *
163 * Note: rs_interrupt() is a "fast" interrupt, which means that it 149 * Here start the interrupt handling routines. All of the following
150 * subroutines are declared as inline and are folded into
151 * dz_interrupt. They were separated out for readability's sake.
152 *
153 * Note: dz_interrupt() is a "fast" interrupt, which means that it
164 * runs with interrupts turned off. People who may want to modify 154 * runs with interrupts turned off. People who may want to modify
165 * rs_interrupt() should try to keep the interrupt handler as fast as 155 * dz_interrupt() should try to keep the interrupt handler as fast as
166 * possible. After you are done making modifications, it is not a bad 156 * possible. After you are done making modifications, it is not a bad
167 * idea to do: 157 * idea to do:
168 * 158 *
@@ -180,92 +170,74 @@ static void dz_enable_ms(struct uart_port *port)
180 * This routine deals with inputs from any lines. 170 * This routine deals with inputs from any lines.
181 * ------------------------------------------------------------ 171 * ------------------------------------------------------------
182 */ 172 */
183static inline void dz_receive_chars(struct dz_port *dport) 173static inline void dz_receive_chars(struct dz_port *dport_in,
174 struct pt_regs *regs)
184{ 175{
176 struct dz_port *dport;
185 struct tty_struct *tty = NULL; 177 struct tty_struct *tty = NULL;
186 struct uart_icount *icount; 178 struct uart_icount *icount;
187 int ignore = 0; 179 int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 };
188 unsigned short status, tmp; 180 unsigned short status;
189 unsigned char ch, flag; 181 unsigned char ch, flag;
182 int i;
190 183
191 /* this code is going to be a problem... 184 while ((status = dz_in(dport_in, DZ_RBUF)) & DZ_DVAL) {
192 the call to tty_flip_buffer is going to need 185 dport = &dz_ports[LINE(status)];
193 to be rethought... 186 tty = dport->port.info->tty; /* point to the proper dev */
194 */
195 do {
196 status = dz_in(dport, DZ_RBUF);
197
198 /* punt so we don't get duplicate characters */
199 if (!(status & DZ_DVAL))
200 goto ignore_char;
201
202
203 ch = UCHAR(status); /* grab the char */
204 flag = TTY_NORMAL;
205 187
206#if 0 188 ch = UCHAR(status); /* grab the char */
207 if (info->is_console) {
208 if (ch == 0)
209 return; /* it's a break ... */
210 }
211#endif
212 189
213 tty = dport->port.info->tty;/* now tty points to the proper dev */
214 icount = &dport->port.icount; 190 icount = &dport->port.icount;
215
216 if (!tty)
217 break;
218
219 icount->rx++; 191 icount->rx++;
220 192
221 /* keep track of the statistics */ 193 flag = TTY_NORMAL;
222 if (status & (DZ_OERR | DZ_FERR | DZ_PERR)) { 194 if (status & DZ_FERR) { /* frame error */
223 if (status & DZ_PERR) /* parity error */ 195 /*
224 icount->parity++; 196 * There is no separate BREAK status bit, so
225 else if (status & DZ_FERR) /* frame error */ 197 * treat framing errors as BREAKs for Magic SysRq
226 icount->frame++; 198 * and SAK; normally, otherwise.
227 if (status & DZ_OERR) /* overrun error */
228 icount->overrun++;
229
230 /* check to see if we should ignore the character
231 and mask off conditions that should be ignored
232 */ 199 */
233 200 if (uart_handle_break(&dport->port))
234 if (status & dport->port.ignore_status_mask) { 201 continue;
235 if (++ignore > 100) 202 if (dport->port.flags & UPF_SAK)
236 break; 203 flag = TTY_BREAK;
237 goto ignore_char; 204 else
238 }
239 /* mask off the error conditions we want to ignore */
240 tmp = status & dport->port.read_status_mask;
241
242 if (tmp & DZ_PERR) {
243 flag = TTY_PARITY;
244#ifdef DEBUG_DZ
245 debug_console("PERR\n", 5);
246#endif
247 } else if (tmp & DZ_FERR) {
248 flag = TTY_FRAME; 205 flag = TTY_FRAME;
249#ifdef DEBUG_DZ 206 } else if (status & DZ_OERR) /* overrun error */
250 debug_console("FERR\n", 5); 207 flag = TTY_OVERRUN;
251#endif 208 else if (status & DZ_PERR) /* parity error */
252 } 209 flag = TTY_PARITY;
253 if (tmp & DZ_OERR) { 210
254#ifdef DEBUG_DZ 211 /* keep track of the statistics */
255 debug_console("OERR\n", 5); 212 switch (flag) {
256#endif 213 case TTY_FRAME:
257 tty_insert_flip_char(tty, ch, flag); 214 icount->frame++;
258 ch = 0; 215 break;
259 flag = TTY_OVERRUN; 216 case TTY_PARITY:
260 } 217 icount->parity++;
218 break;
219 case TTY_OVERRUN:
220 icount->overrun++;
221 break;
222 case TTY_BREAK:
223 icount->brk++;
224 break;
225 default:
226 break;
261 } 227 }
262 tty_insert_flip_char(tty, ch, flag);
263 ignore_char:
264 ;
265 } while (status & DZ_DVAL);
266 228
267 if (tty) 229 if (uart_handle_sysrq_char(&dport->port, ch, regs))
268 tty_flip_buffer_push(tty); 230 continue;
231
232 if ((status & dport->port.ignore_status_mask) == 0) {
233 uart_insert_char(&dport->port,
234 status, DZ_OERR, ch, flag);
235 lines_rx[LINE(status)] = 1;
236 }
237 }
238 for (i = 0; i < DZ_NB_PORT; i++)
239 if (lines_rx[i])
240 tty_flip_buffer_push(dz_ports[i].port.info->tty);
269} 241}
270 242
271/* 243/*
@@ -275,26 +247,32 @@ static inline void dz_receive_chars(struct dz_port *dport)
275 * This routine deals with outputs to any lines. 247 * This routine deals with outputs to any lines.
276 * ------------------------------------------------------------ 248 * ------------------------------------------------------------
277 */ 249 */
278static inline void dz_transmit_chars(struct dz_port *dport) 250static inline void dz_transmit_chars(struct dz_port *dport_in)
279{ 251{
280 struct circ_buf *xmit = &dport->port.info->xmit; 252 struct dz_port *dport;
253 struct circ_buf *xmit;
254 unsigned short status;
281 unsigned char tmp; 255 unsigned char tmp;
282 256
283 if (dport->port.x_char) { /* XON/XOFF chars */ 257 status = dz_in(dport_in, DZ_CSR);
258 dport = &dz_ports[LINE(status)];
259 xmit = &dport->port.info->xmit;
260
261 if (dport->port.x_char) { /* XON/XOFF chars */
284 dz_out(dport, DZ_TDR, dport->port.x_char); 262 dz_out(dport, DZ_TDR, dport->port.x_char);
285 dport->port.icount.tx++; 263 dport->port.icount.tx++;
286 dport->port.x_char = 0; 264 dport->port.x_char = 0;
287 return; 265 return;
288 } 266 }
289 /* if nothing to do or stopped or hardware stopped */ 267 /* If nothing to do or stopped or hardware stopped. */
290 if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) { 268 if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) {
291 dz_stop_tx(&dport->port); 269 dz_stop_tx(&dport->port);
292 return; 270 return;
293 } 271 }
294 272
295 /* 273 /*
296 * if something to do ... (rember the dz has no output fifo so we go 274 * If something to do... (remember the dz has no output fifo,
297 * one char at a time :-< 275 * so we go one char at a time) :-<
298 */ 276 */
299 tmp = xmit->buf[xmit->tail]; 277 tmp = xmit->buf[xmit->tail];
300 xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1); 278 xmit->tail = (xmit->tail + 1) & (DZ_XMIT_SIZE - 1);
@@ -304,23 +282,29 @@ static inline void dz_transmit_chars(struct dz_port *dport)
304 if (uart_circ_chars_pending(xmit) < DZ_WAKEUP_CHARS) 282 if (uart_circ_chars_pending(xmit) < DZ_WAKEUP_CHARS)
305 uart_write_wakeup(&dport->port); 283 uart_write_wakeup(&dport->port);
306 284
307 /* Are we done */ 285 /* Are we are done. */
308 if (uart_circ_empty(xmit)) 286 if (uart_circ_empty(xmit))
309 dz_stop_tx(&dport->port); 287 dz_stop_tx(&dport->port);
310} 288}
311 289
312/* 290/*
313 * ------------------------------------------------------------ 291 * ------------------------------------------------------------
314 * check_modem_status () 292 * check_modem_status()
315 * 293 *
316 * Only valid for the MODEM line duh ! 294 * DS 3100 & 5100: Only valid for the MODEM line, duh!
295 * DS 5000/200: Valid for the MODEM and PRINTER line.
317 * ------------------------------------------------------------ 296 * ------------------------------------------------------------
318 */ 297 */
319static inline void check_modem_status(struct dz_port *dport) 298static inline void check_modem_status(struct dz_port *dport)
320{ 299{
300 /*
301 * FIXME:
302 * 1. No status change interrupt; use a timer.
303 * 2. Handle the 3100/5000 as appropriate. --macro
304 */
321 unsigned short status; 305 unsigned short status;
322 306
323 /* if not ne modem line just return */ 307 /* If not the modem line just return. */
324 if (dport->port.line != DZ_MODEM) 308 if (dport->port.line != DZ_MODEM)
325 return; 309 return;
326 310
@@ -341,21 +325,18 @@ static inline void check_modem_status(struct dz_port *dport)
341 */ 325 */
342static irqreturn_t dz_interrupt(int irq, void *dev) 326static irqreturn_t dz_interrupt(int irq, void *dev)
343{ 327{
344 struct dz_port *dport; 328 struct dz_port *dport = (struct dz_port *)dev;
345 unsigned short status; 329 unsigned short status;
346 330
347 /* get the reason why we just got an irq */ 331 /* get the reason why we just got an irq */
348 status = dz_in((struct dz_port *)dev, DZ_CSR); 332 status = dz_in(dport, DZ_CSR);
349 dport = &dz_ports[LINE(status)];
350 333
351 if (status & DZ_RDONE) 334 if ((status & (DZ_RDONE | DZ_RIE)) == (DZ_RDONE | DZ_RIE))
352 dz_receive_chars(dport); 335 dz_receive_chars(dport, regs);
353 336
354 if (status & DZ_TRDY) 337 if ((status & (DZ_TRDY | DZ_TIE)) == (DZ_TRDY | DZ_TIE))
355 dz_transmit_chars(dport); 338 dz_transmit_chars(dport);
356 339
357 /* FIXME: what about check modem status??? --rmk */
358
359 return IRQ_HANDLED; 340 return IRQ_HANDLED;
360} 341}
361 342
@@ -367,13 +348,13 @@ static irqreturn_t dz_interrupt(int irq, void *dev)
367 348
368static unsigned int dz_get_mctrl(struct uart_port *uport) 349static unsigned int dz_get_mctrl(struct uart_port *uport)
369{ 350{
351 /*
352 * FIXME: Handle the 3100/5000 as appropriate. --macro
353 */
370 struct dz_port *dport = (struct dz_port *)uport; 354 struct dz_port *dport = (struct dz_port *)uport;
371 unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS; 355 unsigned int mctrl = TIOCM_CAR | TIOCM_DSR | TIOCM_CTS;
372 356
373 if (dport->port.line == DZ_MODEM) { 357 if (dport->port.line == DZ_MODEM) {
374 /*
375 * CHECKME: This is a guess from the other code... --rmk
376 */
377 if (dz_in(dport, DZ_MSR) & DZ_MODEM_DSR) 358 if (dz_in(dport, DZ_MSR) & DZ_MODEM_DSR)
378 mctrl &= ~TIOCM_DSR; 359 mctrl &= ~TIOCM_DSR;
379 } 360 }
@@ -383,6 +364,9 @@ static unsigned int dz_get_mctrl(struct uart_port *uport)
383 364
384static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl) 365static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl)
385{ 366{
367 /*
368 * FIXME: Handle the 3100/5000 as appropriate. --macro
369 */
386 struct dz_port *dport = (struct dz_port *)uport; 370 struct dz_port *dport = (struct dz_port *)uport;
387 unsigned short tmp; 371 unsigned short tmp;
388 372
@@ -409,13 +393,6 @@ static int dz_startup(struct uart_port *uport)
409 unsigned long flags; 393 unsigned long flags;
410 unsigned short tmp; 394 unsigned short tmp;
411 395
412 /* The dz lines for the mouse/keyboard must be
413 * opened using their respective drivers.
414 */
415 if ((dport->port.line == DZ_KEYBOARD) ||
416 (dport->port.line == DZ_MOUSE))
417 return -ENODEV;
418
419 spin_lock_irqsave(&dport->port.lock, flags); 396 spin_lock_irqsave(&dport->port.lock, flags);
420 397
421 /* enable the interrupt and the scanning */ 398 /* enable the interrupt and the scanning */
@@ -442,7 +419,8 @@ static void dz_shutdown(struct uart_port *uport)
442} 419}
443 420
444/* 421/*
445 * get_lsr_info - get line status register info 422 * -------------------------------------------------------------------
423 * dz_tx_empty() -- get the transmitter empty status
446 * 424 *
447 * Purpose: Let user call ioctl() to get info when the UART physically 425 * Purpose: Let user call ioctl() to get info when the UART physically
448 * is emptied. On bus types like RS485, the transmitter must 426 * is emptied. On bus types like RS485, the transmitter must
@@ -450,21 +428,28 @@ static void dz_shutdown(struct uart_port *uport)
450 * the transmit shift register is empty, not be done when the 428 * the transmit shift register is empty, not be done when the
451 * transmit holding register is empty. This functionality 429 * transmit holding register is empty. This functionality
452 * allows an RS485 driver to be written in user space. 430 * allows an RS485 driver to be written in user space.
431 * -------------------------------------------------------------------
453 */ 432 */
454static unsigned int dz_tx_empty(struct uart_port *uport) 433static unsigned int dz_tx_empty(struct uart_port *uport)
455{ 434{
456 struct dz_port *dport = (struct dz_port *)uport; 435 struct dz_port *dport = (struct dz_port *)uport;
457 unsigned short status = dz_in(dport, DZ_LPR); 436 unsigned short tmp, mask = 1 << dport->port.line;
458 437
459 /* FIXME: this appears to be obviously broken --rmk. */ 438 tmp = dz_in(dport, DZ_TCR);
460 return status ? TIOCSER_TEMT : 0; 439 tmp &= mask;
440
441 return tmp ? 0 : TIOCSER_TEMT;
461} 442}
462 443
463static void dz_break_ctl(struct uart_port *uport, int break_state) 444static void dz_break_ctl(struct uart_port *uport, int break_state)
464{ 445{
446 /*
447 * FIXME: Can't access BREAK bits in TDR easily;
448 * reuse the code for polled TX. --macro
449 */
465 struct dz_port *dport = (struct dz_port *)uport; 450 struct dz_port *dport = (struct dz_port *)uport;
466 unsigned long flags; 451 unsigned long flags;
467 unsigned short tmp, mask = 1 << uport->line; 452 unsigned short tmp, mask = 1 << dport->port.line;
468 453
469 spin_lock_irqsave(&uport->lock, flags); 454 spin_lock_irqsave(&uport->lock, flags);
470 tmp = dz_in(dport, DZ_TCR); 455 tmp = dz_in(dport, DZ_TCR);
@@ -561,7 +546,7 @@ static void dz_set_termios(struct uart_port *uport, struct termios *termios,
561 546
562 spin_lock_irqsave(&dport->port.lock, flags); 547 spin_lock_irqsave(&dport->port.lock, flags);
563 548
564 dz_out(dport, DZ_LPR, cflag); 549 dz_out(dport, DZ_LPR, cflag | dport->port.line);
565 dport->cflag = cflag; 550 dport->cflag = cflag;
566 551
567 /* setup accept flag */ 552 /* setup accept flag */
@@ -650,7 +635,7 @@ static void __init dz_init_ports(void)
650 for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) { 635 for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) {
651 spin_lock_init(&dport->port.lock); 636 spin_lock_init(&dport->port.lock);
652 dport->port.membase = (char *) base; 637 dport->port.membase = (char *) base;
653 dport->port.iotype = UPIO_PORT; 638 dport->port.iotype = UPIO_MEM;
654 dport->port.irq = dec_interrupt[DEC_IRQ_DZ11]; 639 dport->port.irq = dec_interrupt[DEC_IRQ_DZ11];
655 dport->port.line = i; 640 dport->port.line = i;
656 dport->port.fifosize = 1; 641 dport->port.fifosize = 1;
@@ -662,10 +647,7 @@ static void __init dz_init_ports(void)
662static void dz_reset(struct dz_port *dport) 647static void dz_reset(struct dz_port *dport)
663{ 648{
664 dz_out(dport, DZ_CSR, DZ_CLR); 649 dz_out(dport, DZ_CSR, DZ_CLR);
665
666 while (dz_in(dport, DZ_CSR) & DZ_CLR); 650 while (dz_in(dport, DZ_CSR) & DZ_CLR);
667 /* FIXME: cpu_relax? */
668
669 iob(); 651 iob();
670 652
671 /* enable scanning */ 653 /* enable scanning */
@@ -673,26 +655,55 @@ static void dz_reset(struct dz_port *dport)
673} 655}
674 656
675#ifdef CONFIG_SERIAL_DZ_CONSOLE 657#ifdef CONFIG_SERIAL_DZ_CONSOLE
658/*
659 * -------------------------------------------------------------------
660 * dz_console_putchar() -- transmit a character
661 *
662 * Polled transmission. This is tricky. We need to mask transmit
663 * interrupts so that they do not interfere, enable the transmitter
664 * for the line requested and then wait till the transmit scanner
665 * requests data for this line. But it may request data for another
666 * line first, in which case we have to disable its transmitter and
667 * repeat waiting till our line pops up. Only then the character may
668 * be transmitted. Finally, the state of the transmitter mask is
669 * restored. Welcome to the world of PDP-11!
670 * -------------------------------------------------------------------
671 */
676static void dz_console_putchar(struct uart_port *uport, int ch) 672static void dz_console_putchar(struct uart_port *uport, int ch)
677{ 673{
678 struct dz_port *dport = (struct dz_port *)uport; 674 struct dz_port *dport = (struct dz_port *)uport;
679 unsigned long flags; 675 unsigned long flags;
680 int loops = 2500; 676 unsigned short csr, tcr, trdy, mask;
681 unsigned short tmp = (unsigned char)ch; 677 int loops = 10000;
682 /* this code sends stuff out to serial device - spinning its
683 wheels and waiting. */
684 678
685 spin_lock_irqsave(&dport->port.lock, flags); 679 spin_lock_irqsave(&dport->port.lock, flags);
680 csr = dz_in(dport, DZ_CSR);
681 dz_out(dport, DZ_CSR, csr & ~DZ_TIE);
682 tcr = dz_in(dport, DZ_TCR);
683 tcr |= 1 << dport->port.line;
684 mask = tcr;
685 dz_out(dport, DZ_TCR, mask);
686 iob();
687 spin_unlock_irqrestore(&dport->port.lock, flags);
686 688
687 /* spin our wheels */ 689 while (loops--) {
688 while (((dz_in(dport, DZ_CSR) & DZ_TRDY) != DZ_TRDY) && loops--) 690 trdy = dz_in(dport, DZ_CSR);
689 /* FIXME: cpu_relax, udelay? --rmk */ 691 if (!(trdy & DZ_TRDY))
690 ; 692 continue;
693 trdy = (trdy & DZ_TLINE) >> 8;
694 if (trdy == dport->port.line)
695 break;
696 mask &= ~(1 << trdy);
697 dz_out(dport, DZ_TCR, mask);
698 iob();
699 udelay(2);
700 }
691 701
692 /* Actually transmit the character. */ 702 if (loops) /* Cannot send otherwise. */
693 dz_out(dport, DZ_TDR, tmp); 703 dz_out(dport, DZ_TDR, ch);
694 704
695 spin_unlock_irqrestore(&dport->port.lock, flags); 705 dz_out(dport, DZ_TCR, tcr);
706 dz_out(dport, DZ_CSR, csr);
696} 707}
697 708
698/* 709/*
@@ -703,11 +714,11 @@ static void dz_console_putchar(struct uart_port *uport, int ch)
703 * The console must be locked when we get here. 714 * The console must be locked when we get here.
704 * ------------------------------------------------------------------- 715 * -------------------------------------------------------------------
705 */ 716 */
706static void dz_console_print(struct console *cons, 717static void dz_console_print(struct console *co,
707 const char *str, 718 const char *str,
708 unsigned int count) 719 unsigned int count)
709{ 720{
710 struct dz_port *dport = &dz_ports[CONSOLE_LINE]; 721 struct dz_port *dport = &dz_ports[co->index];
711#ifdef DEBUG_DZ 722#ifdef DEBUG_DZ
712 prom_printf((char *) str); 723 prom_printf((char *) str);
713#endif 724#endif
@@ -716,49 +727,43 @@ static void dz_console_print(struct console *cons,
716 727
717static int __init dz_console_setup(struct console *co, char *options) 728static int __init dz_console_setup(struct console *co, char *options)
718{ 729{
719 struct dz_port *dport = &dz_ports[CONSOLE_LINE]; 730 struct dz_port *dport = &dz_ports[co->index];
720 int baud = 9600; 731 int baud = 9600;
721 int bits = 8; 732 int bits = 8;
722 int parity = 'n'; 733 int parity = 'n';
723 int flow = 'n'; 734 int flow = 'n';
724 int ret;
725 unsigned short mask, tmp;
726 735
727 if (options) 736 if (options)
728 uart_parse_options(options, &baud, &parity, &bits, &flow); 737 uart_parse_options(options, &baud, &parity, &bits, &flow);
729 738
730 dz_reset(dport); 739 dz_reset(dport);
731 740
732 ret = uart_set_options(&dport->port, co, baud, parity, bits, flow); 741 return uart_set_options(&dport->port, co, baud, parity, bits, flow);
733 if (ret == 0) {
734 mask = 1 << dport->port.line;
735 tmp = dz_in(dport, DZ_TCR); /* read the TX flag */
736 if (!(tmp & mask)) {
737 tmp |= mask; /* set the TX flag */
738 dz_out(dport, DZ_TCR, tmp);
739 }
740 }
741
742 return ret;
743} 742}
744 743
745static struct console dz_sercons = 744static struct uart_driver dz_reg;
746{ 745static struct console dz_sercons = {
747 .name = "ttyS", 746 .name = "ttyS",
748 .write = dz_console_print, 747 .write = dz_console_print,
749 .device = uart_console_device, 748 .device = uart_console_device,
750 .setup = dz_console_setup, 749 .setup = dz_console_setup,
751 .flags = CON_CONSDEV | CON_PRINTBUFFER, 750 .flags = CON_PRINTBUFFER,
752 .index = CONSOLE_LINE, 751 .index = -1,
752 .data = &dz_reg,
753}; 753};
754 754
755void __init dz_serial_console_init(void) 755static int __init dz_serial_console_init(void)
756{ 756{
757 dz_init_ports(); 757 if (!IOASIC) {
758 758 dz_init_ports();
759 register_console(&dz_sercons); 759 register_console(&dz_sercons);
760 return 0;
761 } else
762 return -ENXIO;
760} 763}
761 764
765console_initcall(dz_serial_console_init);
766
762#define SERIAL_DZ_CONSOLE &dz_sercons 767#define SERIAL_DZ_CONSOLE &dz_sercons
763#else 768#else
764#define SERIAL_DZ_CONSOLE NULL 769#define SERIAL_DZ_CONSOLE NULL
@@ -767,35 +772,29 @@ void __init dz_serial_console_init(void)
767static struct uart_driver dz_reg = { 772static struct uart_driver dz_reg = {
768 .owner = THIS_MODULE, 773 .owner = THIS_MODULE,
769 .driver_name = "serial", 774 .driver_name = "serial",
770 .dev_name = "ttyS%d", 775 .dev_name = "ttyS",
771 .major = TTY_MAJOR, 776 .major = TTY_MAJOR,
772 .minor = 64, 777 .minor = 64,
773 .nr = DZ_NB_PORT, 778 .nr = DZ_NB_PORT,
774 .cons = SERIAL_DZ_CONSOLE, 779 .cons = SERIAL_DZ_CONSOLE,
775}; 780};
776 781
777int __init dz_init(void) 782static int __init dz_init(void)
778{ 783{
779 unsigned long flags;
780 int ret, i; 784 int ret, i;
781 785
786 if (IOASIC)
787 return -ENXIO;
788
782 printk("%s%s\n", dz_name, dz_version); 789 printk("%s%s\n", dz_name, dz_version);
783 790
784 dz_init_ports(); 791 dz_init_ports();
785 792
786 save_flags(flags);
787 cli();
788
789#ifndef CONFIG_SERIAL_DZ_CONSOLE 793#ifndef CONFIG_SERIAL_DZ_CONSOLE
790 /* reset the chip */ 794 /* reset the chip */
791 dz_reset(&dz_ports[0]); 795 dz_reset(&dz_ports[0]);
792#endif 796#endif
793 797
794 /* order matters here... the trick is that flags
795 is updated... in request_irq - to immediatedly obliterate
796 it is unwise. */
797 restore_flags(flags);
798
799 if (request_irq(dz_ports[0].port.irq, dz_interrupt, 798 if (request_irq(dz_ports[0].port.irq, dz_interrupt,
800 IRQF_DISABLED, "DZ", &dz_ports[0])) 799 IRQF_DISABLED, "DZ", &dz_ports[0]))
801 panic("Unable to register DZ interrupt"); 800 panic("Unable to register DZ interrupt");
@@ -810,5 +809,7 @@ int __init dz_init(void)
810 return ret; 809 return ret;
811} 810}
812 811
812module_init(dz_init);
813
813MODULE_DESCRIPTION("DECstation DZ serial driver"); 814MODULE_DESCRIPTION("DECstation DZ serial driver");
814MODULE_LICENSE("GPL"); 815MODULE_LICENSE("GPL");
diff --git a/drivers/serial/dz.h b/drivers/serial/dz.h
index 86ef417382bb..9674d4e49872 100644
--- a/drivers/serial/dz.h
+++ b/drivers/serial/dz.h
@@ -1,20 +1,22 @@
1/* 1/*
2 * dz.h: Serial port driver for DECStations equiped 2 * dz.h: Serial port driver for DECstations equipped
3 * with the DZ chipset. 3 * with the DZ chipset.
4 * 4 *
5 * Copyright (C) 1998 Olivier A. D. Lebaillif 5 * Copyright (C) 1998 Olivier A. D. Lebaillif
6 * 6 *
7 * Email: olivier.lebaillif@ifrsys.com 7 * Email: olivier.lebaillif@ifrsys.com
8 * 8 *
9 * Copyright (C) 2004, 2006 Maciej W. Rozycki
9 */ 10 */
10#ifndef DZ_SERIAL_H 11#ifndef DZ_SERIAL_H
11#define DZ_SERIAL_H 12#define DZ_SERIAL_H
12 13
13/* 14/*
14 * Definitions for the Control and Status Received. 15 * Definitions for the Control and Status Register.
15 */ 16 */
16#define DZ_TRDY 0x8000 /* Transmitter empty */ 17#define DZ_TRDY 0x8000 /* Transmitter empty */
17#define DZ_TIE 0x4000 /* Transmitter Interrupt Enable */ 18#define DZ_TIE 0x4000 /* Transmitter Interrupt Enbl */
19#define DZ_TLINE 0x0300 /* Transmitter Line Number */
18#define DZ_RDONE 0x0080 /* Receiver data ready */ 20#define DZ_RDONE 0x0080 /* Receiver data ready */
19#define DZ_RIE 0x0040 /* Receive Interrupt Enable */ 21#define DZ_RIE 0x0040 /* Receive Interrupt Enable */
20#define DZ_MSE 0x0020 /* Master Scan Enable */ 22#define DZ_MSE 0x0020 /* Master Scan Enable */
@@ -22,32 +24,44 @@
22#define DZ_MAINT 0x0008 /* Loop Back Mode */ 24#define DZ_MAINT 0x0008 /* Loop Back Mode */
23 25
24/* 26/*
25 * Definitions for the Received buffer. 27 * Definitions for the Receiver Buffer Register.
26 */ 28 */
27#define DZ_RBUF_MASK 0x00FF /* Data Mask in the Receive Buffer */ 29#define DZ_RBUF_MASK 0x00FF /* Data Mask */
28#define DZ_LINE_MASK 0x0300 /* Line Mask in the Receive Buffer */ 30#define DZ_LINE_MASK 0x0300 /* Line Mask */
29#define DZ_DVAL 0x8000 /* Valid Data indicator */ 31#define DZ_DVAL 0x8000 /* Valid Data indicator */
30#define DZ_OERR 0x4000 /* Overrun error indicator */ 32#define DZ_OERR 0x4000 /* Overrun error indicator */
31#define DZ_FERR 0x2000 /* Frame error indicator */ 33#define DZ_FERR 0x2000 /* Frame error indicator */
32#define DZ_PERR 0x1000 /* Parity error indicator */ 34#define DZ_PERR 0x1000 /* Parity error indicator */
33 35
34#define LINE(x) (x & DZ_LINE_MASK) >> 8 /* Get the line number from the input buffer */ 36#define LINE(x) ((x & DZ_LINE_MASK) >> 8) /* Get the line number
35#define UCHAR(x) (unsigned char)(x & DZ_RBUF_MASK) 37 from the input buffer */
38#define UCHAR(x) ((unsigned char)(x & DZ_RBUF_MASK))
36 39
37/* 40/*
38 * Definitions for the Transmit Register. 41 * Definitions for the Transmit Control Register.
39 */ 42 */
40#define DZ_LINE_KEYBOARD 0x0001 43#define DZ_LINE_KEYBOARD 0x0001
41#define DZ_LINE_MOUSE 0x0002 44#define DZ_LINE_MOUSE 0x0002
42#define DZ_LINE_MODEM 0x0004 45#define DZ_LINE_MODEM 0x0004
43#define DZ_LINE_PRINTER 0x0008 46#define DZ_LINE_PRINTER 0x0008
44 47
48#define DZ_MODEM_RTS 0x0800 /* RTS for the modem line (2) */
45#define DZ_MODEM_DTR 0x0400 /* DTR for the modem line (2) */ 49#define DZ_MODEM_DTR 0x0400 /* DTR for the modem line (2) */
50#define DZ_PRINT_RTS 0x0200 /* RTS for the prntr line (3) */
51#define DZ_PRINT_DTR 0x0100 /* DTR for the prntr line (3) */
52#define DZ_LNENB 0x000f /* Transmitter Line Enable */
46 53
47/* 54/*
48 * Definitions for the Modem Status Register. 55 * Definitions for the Modem Status Register.
49 */ 56 */
57#define DZ_MODEM_RI 0x0800 /* RI for the modem line (2) */
58#define DZ_MODEM_CD 0x0400 /* CD for the modem line (2) */
50#define DZ_MODEM_DSR 0x0200 /* DSR for the modem line (2) */ 59#define DZ_MODEM_DSR 0x0200 /* DSR for the modem line (2) */
60#define DZ_MODEM_CTS 0x0100 /* CTS for the modem line (2) */
61#define DZ_PRINT_RI 0x0008 /* RI for the printer line (3) */
62#define DZ_PRINT_CD 0x0004 /* CD for the printer line (3) */
63#define DZ_PRINT_DSR 0x0002 /* DSR for the prntr line (3) */
64#define DZ_PRINT_CTS 0x0001 /* CTS for the prntr line (3) */
51 65
52/* 66/*
53 * Definitions for the Transmit Data Register. 67 * Definitions for the Transmit Data Register.
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index 8eea69f29989..29823bd60fb0 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -555,7 +555,7 @@ mpsc_sdma_start_tx(struct mpsc_port_info *pi)
555 if (!mpsc_sdma_tx_active(pi)) { 555 if (!mpsc_sdma_tx_active(pi)) {
556 txre = (struct mpsc_tx_desc *)(pi->txr + 556 txre = (struct mpsc_tx_desc *)(pi->txr +
557 (pi->txr_tail * MPSC_TXRE_SIZE)); 557 (pi->txr_tail * MPSC_TXRE_SIZE));
558 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); 558 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
559#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 559#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
560 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 560 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
561 invalidate_dcache_range((ulong)txre, 561 invalidate_dcache_range((ulong)txre,
@@ -931,7 +931,7 @@ mpsc_init_rings(struct mpsc_port_info *pi)
931 } 931 }
932 txre->link = cpu_to_be32(pi->txr_p); /* Wrap last back to first */ 932 txre->link = cpu_to_be32(pi->txr_p); /* Wrap last back to first */
933 933
934 dma_cache_sync((void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE, 934 dma_cache_sync(pi->port.dev, (void *) pi->dma_region, MPSC_DMA_ALLOC_SIZE,
935 DMA_BIDIRECTIONAL); 935 DMA_BIDIRECTIONAL);
936#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 936#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
937 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 937 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
@@ -1005,7 +1005,7 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1005 1005
1006 rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE)); 1006 rxre = (struct mpsc_rx_desc *)(pi->rxr + (pi->rxr_posn*MPSC_RXRE_SIZE));
1007 1007
1008 dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); 1008 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
1009#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1009#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1010 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1010 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1011 invalidate_dcache_range((ulong)rxre, 1011 invalidate_dcache_range((ulong)rxre,
@@ -1029,7 +1029,7 @@ mpsc_rx_intr(struct mpsc_port_info *pi)
1029 } 1029 }
1030 1030
1031 bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE); 1031 bp = pi->rxb + (pi->rxr_posn * MPSC_RXBE_SIZE);
1032 dma_cache_sync((void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE); 1032 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_RXBE_SIZE, DMA_FROM_DEVICE);
1033#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1033#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1034 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1034 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1035 invalidate_dcache_range((ulong)bp, 1035 invalidate_dcache_range((ulong)bp,
@@ -1098,7 +1098,7 @@ next_frame:
1098 SDMA_DESC_CMDSTAT_F | 1098 SDMA_DESC_CMDSTAT_F |
1099 SDMA_DESC_CMDSTAT_L); 1099 SDMA_DESC_CMDSTAT_L);
1100 wmb(); 1100 wmb();
1101 dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL); 1101 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_BIDIRECTIONAL);
1102#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1102#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1103 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1103 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1104 flush_dcache_range((ulong)rxre, 1104 flush_dcache_range((ulong)rxre,
@@ -1109,7 +1109,7 @@ next_frame:
1109 pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1); 1109 pi->rxr_posn = (pi->rxr_posn + 1) & (MPSC_RXR_ENTRIES - 1);
1110 rxre = (struct mpsc_rx_desc *)(pi->rxr + 1110 rxre = (struct mpsc_rx_desc *)(pi->rxr +
1111 (pi->rxr_posn * MPSC_RXRE_SIZE)); 1111 (pi->rxr_posn * MPSC_RXRE_SIZE));
1112 dma_cache_sync((void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE); 1112 dma_cache_sync(pi->port.dev, (void *)rxre, MPSC_RXRE_SIZE, DMA_FROM_DEVICE);
1113#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1113#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1114 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1114 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1115 invalidate_dcache_range((ulong)rxre, 1115 invalidate_dcache_range((ulong)rxre,
@@ -1143,7 +1143,7 @@ mpsc_setup_tx_desc(struct mpsc_port_info *pi, u32 count, u32 intr)
1143 SDMA_DESC_CMDSTAT_EI 1143 SDMA_DESC_CMDSTAT_EI
1144 : 0)); 1144 : 0));
1145 wmb(); 1145 wmb();
1146 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL); 1146 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_BIDIRECTIONAL);
1147#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1147#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1148 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1148 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1149 flush_dcache_range((ulong)txre, 1149 flush_dcache_range((ulong)txre,
@@ -1192,7 +1192,7 @@ mpsc_copy_tx_data(struct mpsc_port_info *pi)
1192 else /* All tx data copied into ring bufs */ 1192 else /* All tx data copied into ring bufs */
1193 return; 1193 return;
1194 1194
1195 dma_cache_sync((void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); 1195 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
1196#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1196#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1197 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1197 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1198 flush_dcache_range((ulong)bp, 1198 flush_dcache_range((ulong)bp,
@@ -1217,7 +1217,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
1217 txre = (struct mpsc_tx_desc *)(pi->txr + 1217 txre = (struct mpsc_tx_desc *)(pi->txr +
1218 (pi->txr_tail * MPSC_TXRE_SIZE)); 1218 (pi->txr_tail * MPSC_TXRE_SIZE));
1219 1219
1220 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE); 1220 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE, DMA_FROM_DEVICE);
1221#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1221#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1222 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1222 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1223 invalidate_dcache_range((ulong)txre, 1223 invalidate_dcache_range((ulong)txre,
@@ -1235,7 +1235,7 @@ mpsc_tx_intr(struct mpsc_port_info *pi)
1235 1235
1236 txre = (struct mpsc_tx_desc *)(pi->txr + 1236 txre = (struct mpsc_tx_desc *)(pi->txr +
1237 (pi->txr_tail * MPSC_TXRE_SIZE)); 1237 (pi->txr_tail * MPSC_TXRE_SIZE));
1238 dma_cache_sync((void *) txre, MPSC_TXRE_SIZE, 1238 dma_cache_sync(pi->port.dev, (void *) txre, MPSC_TXRE_SIZE,
1239 DMA_FROM_DEVICE); 1239 DMA_FROM_DEVICE);
1240#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1240#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1241 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1241 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
@@ -1652,7 +1652,7 @@ mpsc_console_write(struct console *co, const char *s, uint count)
1652 count--; 1652 count--;
1653 } 1653 }
1654 1654
1655 dma_cache_sync((void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL); 1655 dma_cache_sync(pi->port.dev, (void *) bp, MPSC_TXBE_SIZE, DMA_BIDIRECTIONAL);
1656#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE) 1656#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
1657 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */ 1657 if (pi->cache_mgmt) /* GT642[46]0 Res #COMM-2 */
1658 flush_dcache_range((ulong)bp, 1658 flush_dcache_range((ulong)bp,
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
new file mode 100644
index 000000000000..83690653b78b
--- /dev/null
+++ b/drivers/serial/uartlite.c
@@ -0,0 +1,505 @@
1/*
2 * uartlite.c: Serial driver for Xilinx uartlite serial controller
3 *
4 * Peter Korsgaard <jacmet@sunsite.dk>
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11#include <linux/platform_device.h>
12#include <linux/module.h>
13#include <linux/console.h>
14#include <linux/serial.h>
15#include <linux/serial_core.h>
16#include <linux/tty.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <asm/io.h>
20
21#define ULITE_MAJOR 204
22#define ULITE_MINOR 187
23#define ULITE_NR_UARTS 4
24
25/* For register details see datasheet:
26 http://www.xilinx.com/bvdocs/ipcenter/data_sheet/opb_uartlite.pdf
27*/
28#define ULITE_RX 0x00
29#define ULITE_TX 0x04
30#define ULITE_STATUS 0x08
31#define ULITE_CONTROL 0x0c
32
33#define ULITE_REGION 16
34
35#define ULITE_STATUS_RXVALID 0x01
36#define ULITE_STATUS_RXFULL 0x02
37#define ULITE_STATUS_TXEMPTY 0x04
38#define ULITE_STATUS_TXFULL 0x08
39#define ULITE_STATUS_IE 0x10
40#define ULITE_STATUS_OVERRUN 0x20
41#define ULITE_STATUS_FRAME 0x40
42#define ULITE_STATUS_PARITY 0x80
43
44#define ULITE_CONTROL_RST_TX 0x01
45#define ULITE_CONTROL_RST_RX 0x02
46#define ULITE_CONTROL_IE 0x10
47
48
49static struct uart_port ports[ULITE_NR_UARTS];
50
51static int ulite_receive(struct uart_port *port, int stat)
52{
53 struct tty_struct *tty = port->info->tty;
54 unsigned char ch = 0;
55 char flag = TTY_NORMAL;
56
57 if ((stat & (ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
58 | ULITE_STATUS_FRAME)) == 0)
59 return 0;
60
61 /* stats */
62 if (stat & ULITE_STATUS_RXVALID) {
63 port->icount.rx++;
64 ch = readb(port->membase + ULITE_RX);
65
66 if (stat & ULITE_STATUS_PARITY)
67 port->icount.parity++;
68 }
69
70 if (stat & ULITE_STATUS_OVERRUN)
71 port->icount.overrun++;
72
73 if (stat & ULITE_STATUS_FRAME)
74 port->icount.frame++;
75
76
77 /* drop byte with parity error if IGNPAR specificed */
78 if (stat & port->ignore_status_mask & ULITE_STATUS_PARITY)
79 stat &= ~ULITE_STATUS_RXVALID;
80
81 stat &= port->read_status_mask;
82
83 if (stat & ULITE_STATUS_PARITY)
84 flag = TTY_PARITY;
85
86
87 stat &= ~port->ignore_status_mask;
88
89 if (stat & ULITE_STATUS_RXVALID)
90 tty_insert_flip_char(tty, ch, flag);
91
92 if (stat & ULITE_STATUS_FRAME)
93 tty_insert_flip_char(tty, 0, TTY_FRAME);
94
95 if (stat & ULITE_STATUS_OVERRUN)
96 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
97
98 return 1;
99}
100
101static int ulite_transmit(struct uart_port *port, int stat)
102{
103 struct circ_buf *xmit = &port->info->xmit;
104
105 if (stat & ULITE_STATUS_TXFULL)
106 return 0;
107
108 if (port->x_char) {
109 writeb(port->x_char, port->membase + ULITE_TX);
110 port->x_char = 0;
111 port->icount.tx++;
112 return 1;
113 }
114
115 if (uart_circ_empty(xmit) || uart_tx_stopped(port))
116 return 0;
117
118 writeb(xmit->buf[xmit->tail], port->membase + ULITE_TX);
119 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE-1);
120 port->icount.tx++;
121
122 /* wake up */
123 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
124 uart_write_wakeup(port);
125
126 return 1;
127}
128
129static irqreturn_t ulite_isr(int irq, void *dev_id)
130{
131 struct uart_port *port = (struct uart_port *)dev_id;
132 int busy;
133
134 do {
135 int stat = readb(port->membase + ULITE_STATUS);
136 busy = ulite_receive(port, stat);
137 busy |= ulite_transmit(port, stat);
138 } while (busy);
139
140 tty_flip_buffer_push(port->info->tty);
141
142 return IRQ_HANDLED;
143}
144
145static unsigned int ulite_tx_empty(struct uart_port *port)
146{
147 unsigned long flags;
148 unsigned int ret;
149
150 spin_lock_irqsave(&port->lock, flags);
151 ret = readb(port->membase + ULITE_STATUS);
152 spin_unlock_irqrestore(&port->lock, flags);
153
154 return ret & ULITE_STATUS_TXEMPTY ? TIOCSER_TEMT : 0;
155}
156
157static unsigned int ulite_get_mctrl(struct uart_port *port)
158{
159 return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR;
160}
161
162static void ulite_set_mctrl(struct uart_port *port, unsigned int mctrl)
163{
164 /* N/A */
165}
166
167static void ulite_stop_tx(struct uart_port *port)
168{
169 /* N/A */
170}
171
172static void ulite_start_tx(struct uart_port *port)
173{
174 ulite_transmit(port, readb(port->membase + ULITE_STATUS));
175}
176
177static void ulite_stop_rx(struct uart_port *port)
178{
179 /* don't forward any more data (like !CREAD) */
180 port->ignore_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
181 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
182}
183
184static void ulite_enable_ms(struct uart_port *port)
185{
186 /* N/A */
187}
188
189static void ulite_break_ctl(struct uart_port *port, int ctl)
190{
191 /* N/A */
192}
193
194static int ulite_startup(struct uart_port *port)
195{
196 int ret;
197
198 ret = request_irq(port->irq, ulite_isr,
199 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "uartlite", port);
200 if (ret)
201 return ret;
202
203 writeb(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX,
204 port->membase + ULITE_CONTROL);
205 writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
206
207 return 0;
208}
209
210static void ulite_shutdown(struct uart_port *port)
211{
212 writeb(0, port->membase + ULITE_CONTROL);
213 readb(port->membase + ULITE_CONTROL); /* dummy */
214 free_irq(port->irq, port);
215}
216
217static void ulite_set_termios(struct uart_port *port, struct termios *termios,
218 struct termios *old)
219{
220 unsigned long flags;
221 unsigned int baud;
222
223 spin_lock_irqsave(&port->lock, flags);
224
225 port->read_status_mask = ULITE_STATUS_RXVALID | ULITE_STATUS_OVERRUN
226 | ULITE_STATUS_TXFULL;
227
228 if (termios->c_iflag & INPCK)
229 port->read_status_mask |=
230 ULITE_STATUS_PARITY | ULITE_STATUS_FRAME;
231
232 port->ignore_status_mask = 0;
233 if (termios->c_iflag & IGNPAR)
234 port->ignore_status_mask |= ULITE_STATUS_PARITY
235 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
236
237 /* ignore all characters if CREAD is not set */
238 if ((termios->c_cflag & CREAD) == 0)
239 port->ignore_status_mask |=
240 ULITE_STATUS_RXVALID | ULITE_STATUS_PARITY
241 | ULITE_STATUS_FRAME | ULITE_STATUS_OVERRUN;
242
243 /* update timeout */
244 baud = uart_get_baud_rate(port, termios, old, 0, 460800);
245 uart_update_timeout(port, termios->c_cflag, baud);
246
247 spin_unlock_irqrestore(&port->lock, flags);
248}
249
250static const char *ulite_type(struct uart_port *port)
251{
252 return port->type == PORT_UARTLITE ? "uartlite" : NULL;
253}
254
255static void ulite_release_port(struct uart_port *port)
256{
257 release_mem_region(port->mapbase, ULITE_REGION);
258 iounmap(port->membase);
259 port->membase = 0;
260}
261
262static int ulite_request_port(struct uart_port *port)
263{
264 if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
265 dev_err(port->dev, "Memory region busy\n");
266 return -EBUSY;
267 }
268
269 port->membase = ioremap(port->mapbase, ULITE_REGION);
270 if (!port->membase) {
271 dev_err(port->dev, "Unable to map registers\n");
272 release_mem_region(port->mapbase, ULITE_REGION);
273 return -EBUSY;
274 }
275
276 return 0;
277}
278
279static void ulite_config_port(struct uart_port *port, int flags)
280{
281 ulite_request_port(port);
282 port->type = PORT_UARTLITE;
283}
284
285static int ulite_verify_port(struct uart_port *port, struct serial_struct *ser)
286{
287 /* we don't want the core code to modify any port params */
288 return -EINVAL;
289}
290
291static struct uart_ops ulite_ops = {
292 .tx_empty = ulite_tx_empty,
293 .set_mctrl = ulite_set_mctrl,
294 .get_mctrl = ulite_get_mctrl,
295 .stop_tx = ulite_stop_tx,
296 .start_tx = ulite_start_tx,
297 .stop_rx = ulite_stop_rx,
298 .enable_ms = ulite_enable_ms,
299 .break_ctl = ulite_break_ctl,
300 .startup = ulite_startup,
301 .shutdown = ulite_shutdown,
302 .set_termios = ulite_set_termios,
303 .type = ulite_type,
304 .release_port = ulite_release_port,
305 .request_port = ulite_request_port,
306 .config_port = ulite_config_port,
307 .verify_port = ulite_verify_port
308};
309
310#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
311static void ulite_console_wait_tx(struct uart_port *port)
312{
313 int i;
314
315 /* wait up to 10ms for the character(s) to be sent */
316 for (i = 0; i < 10000; i++) {
317 if (readb(port->membase + ULITE_STATUS) & ULITE_STATUS_TXEMPTY)
318 break;
319 udelay(1);
320 }
321}
322
323static void ulite_console_putchar(struct uart_port *port, int ch)
324{
325 ulite_console_wait_tx(port);
326 writeb(ch, port->membase + ULITE_TX);
327}
328
329static void ulite_console_write(struct console *co, const char *s,
330 unsigned int count)
331{
332 struct uart_port *port = &ports[co->index];
333 unsigned long flags;
334 unsigned int ier;
335 int locked = 1;
336
337 if (oops_in_progress) {
338 locked = spin_trylock_irqsave(&port->lock, flags);
339 } else
340 spin_lock_irqsave(&port->lock, flags);
341
342 /* save and disable interrupt */
343 ier = readb(port->membase + ULITE_STATUS) & ULITE_STATUS_IE;
344 writeb(0, port->membase + ULITE_CONTROL);
345
346 uart_console_write(port, s, count, ulite_console_putchar);
347
348 ulite_console_wait_tx(port);
349
350 /* restore interrupt state */
351 if (ier)
352 writeb(ULITE_CONTROL_IE, port->membase + ULITE_CONTROL);
353
354 if (locked)
355 spin_unlock_irqrestore(&port->lock, flags);
356}
357
358static int __init ulite_console_setup(struct console *co, char *options)
359{
360 struct uart_port *port;
361 int baud = 9600;
362 int bits = 8;
363 int parity = 'n';
364 int flow = 'n';
365
366 if (co->index < 0 || co->index >= ULITE_NR_UARTS)
367 return -EINVAL;
368
369 port = &ports[co->index];
370
371 /* not initialized yet? */
372 if (!port->membase)
373 return -ENODEV;
374
375 if (options)
376 uart_parse_options(options, &baud, &parity, &bits, &flow);
377
378 return uart_set_options(port, co, baud, parity, bits, flow);
379}
380
381static struct uart_driver ulite_uart_driver;
382
383static struct console ulite_console = {
384 .name = "ttyUL",
385 .write = ulite_console_write,
386 .device = uart_console_device,
387 .setup = ulite_console_setup,
388 .flags = CON_PRINTBUFFER,
389 .index = -1, /* Specified on the cmdline (e.g. console=ttyUL0 ) */
390 .data = &ulite_uart_driver,
391};
392
393static int __init ulite_console_init(void)
394{
395 register_console(&ulite_console);
396 return 0;
397}
398
399console_initcall(ulite_console_init);
400
401#endif /* CONFIG_SERIAL_UARTLITE_CONSOLE */
402
403static struct uart_driver ulite_uart_driver = {
404 .owner = THIS_MODULE,
405 .driver_name = "uartlite",
406 .dev_name = "ttyUL",
407 .major = ULITE_MAJOR,
408 .minor = ULITE_MINOR,
409 .nr = ULITE_NR_UARTS,
410#ifdef CONFIG_SERIAL_UARTLITE_CONSOLE
411 .cons = &ulite_console,
412#endif
413};
414
415static int __devinit ulite_probe(struct platform_device *pdev)
416{
417 struct resource *res, *res2;
418 struct uart_port *port;
419
420 if (pdev->id < 0 || pdev->id >= ULITE_NR_UARTS)
421 return -EINVAL;
422
423 if (ports[pdev->id].membase)
424 return -EBUSY;
425
426 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
427 if (!res)
428 return -ENODEV;
429
430 res2 = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
431 if (!res2)
432 return -ENODEV;
433
434 port = &ports[pdev->id];
435
436 port->fifosize = 16;
437 port->regshift = 2;
438 port->iotype = UPIO_MEM;
439 port->iobase = 1; /* mark port in use */
440 port->mapbase = res->start;
441 port->membase = 0;
442 port->ops = &ulite_ops;
443 port->irq = res2->start;
444 port->flags = UPF_BOOT_AUTOCONF;
445 port->dev = &pdev->dev;
446 port->type = PORT_UNKNOWN;
447 port->line = pdev->id;
448
449 uart_add_one_port(&ulite_uart_driver, port);
450 platform_set_drvdata(pdev, port);
451
452 return 0;
453}
454
455static int ulite_remove(struct platform_device *pdev)
456{
457 struct uart_port *port = platform_get_drvdata(pdev);
458
459 platform_set_drvdata(pdev, NULL);
460
461 if (port)
462 uart_remove_one_port(&ulite_uart_driver, port);
463
464 /* mark port as free */
465 port->membase = 0;
466
467 return 0;
468}
469
470static struct platform_driver ulite_platform_driver = {
471 .probe = ulite_probe,
472 .remove = ulite_remove,
473 .driver = {
474 .owner = THIS_MODULE,
475 .name = "uartlite",
476 },
477};
478
479int __init ulite_init(void)
480{
481 int ret;
482
483 ret = uart_register_driver(&ulite_uart_driver);
484 if (ret)
485 return ret;
486
487 ret = platform_driver_register(&ulite_platform_driver);
488 if (ret)
489 uart_unregister_driver(&ulite_uart_driver);
490
491 return ret;
492}
493
494void __exit ulite_exit(void)
495{
496 platform_driver_unregister(&ulite_platform_driver);
497 uart_unregister_driver(&ulite_uart_driver);
498}
499
500module_init(ulite_init);
501module_exit(ulite_exit);
502
503MODULE_AUTHOR("Peter Korsgaard <jacmet@sunsite.dk>");
504MODULE_DESCRIPTION("Xilinx uartlite serial driver");
505MODULE_LICENSE("GPL");
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index c3c0626f550b..270e6211c2e3 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -360,12 +360,13 @@ spi_alloc_master(struct device *dev, unsigned size)
360 if (!dev) 360 if (!dev)
361 return NULL; 361 return NULL;
362 362
363 master = kzalloc(size + sizeof *master, SLAB_KERNEL); 363 master = kzalloc(size + sizeof *master, GFP_KERNEL);
364 if (!master) 364 if (!master)
365 return NULL; 365 return NULL;
366 366
367 class_device_initialize(&master->cdev); 367 class_device_initialize(&master->cdev);
368 master->cdev.class = &spi_master_class; 368 master->cdev.class = &spi_master_class;
369 kobj_set_kset_s(&master->cdev, spi_master_class.subsys);
369 master->cdev.dev = get_device(dev); 370 master->cdev.dev = get_device(dev);
370 spi_master_set_devdata(master, &master[1]); 371 spi_master_set_devdata(master, &master[1]);
371 372
@@ -447,7 +448,9 @@ static int __unregister(struct device *dev, void *unused)
447 */ 448 */
448void spi_unregister_master(struct spi_master *master) 449void spi_unregister_master(struct spi_master *master)
449{ 450{
450 (void) device_for_each_child(master->cdev.dev, NULL, __unregister); 451 int dummy;
452
453 dummy = device_for_each_child(master->cdev.dev, NULL, __unregister);
451 class_device_unregister(&master->cdev); 454 class_device_unregister(&master->cdev);
452} 455}
453EXPORT_SYMBOL_GPL(spi_unregister_master); 456EXPORT_SYMBOL_GPL(spi_unregister_master);
@@ -463,15 +466,13 @@ EXPORT_SYMBOL_GPL(spi_unregister_master);
463 */ 466 */
464struct spi_master *spi_busnum_to_master(u16 bus_num) 467struct spi_master *spi_busnum_to_master(u16 bus_num)
465{ 468{
466 if (bus_num) { 469 char name[9];
467 char name[8]; 470 struct kobject *bus;
468 struct kobject *bus; 471
469 472 snprintf(name, sizeof name, "spi%u", bus_num);
470 snprintf(name, sizeof name, "spi%u", bus_num); 473 bus = kset_find_obj(&spi_master_class.subsys.kset, name);
471 bus = kset_find_obj(&spi_master_class.subsys.kset, name); 474 if (bus)
472 if (bus) 475 return container_of(bus, struct spi_master, cdev.kobj);
473 return container_of(bus, struct spi_master, cdev.kobj);
474 }
475 return NULL; 476 return NULL;
476} 477}
477EXPORT_SYMBOL_GPL(spi_busnum_to_master); 478EXPORT_SYMBOL_GPL(spi_busnum_to_master);
@@ -607,7 +608,7 @@ static int __init spi_init(void)
607{ 608{
608 int status; 609 int status;
609 610
610 buf = kmalloc(SPI_BUFSIZ, SLAB_KERNEL); 611 buf = kmalloc(SPI_BUFSIZ, GFP_KERNEL);
611 if (!buf) { 612 if (!buf) {
612 status = -ENOMEM; 613 status = -ENOMEM;
613 goto err0; 614 goto err0;
diff --git a/drivers/spi/spi_bitbang.c b/drivers/spi/spi_bitbang.c
index 08c1c57c6128..57289b61d0be 100644
--- a/drivers/spi/spi_bitbang.c
+++ b/drivers/spi/spi_bitbang.c
@@ -196,7 +196,7 @@ int spi_bitbang_setup(struct spi_device *spi)
196 return -EINVAL; 196 return -EINVAL;
197 197
198 if (!cs) { 198 if (!cs) {
199 cs = kzalloc(sizeof *cs, SLAB_KERNEL); 199 cs = kzalloc(sizeof *cs, GFP_KERNEL);
200 if (!cs) 200 if (!cs)
201 return -ENOMEM; 201 return -ENOMEM;
202 spi->controller_state = cs; 202 spi->controller_state = cs;
diff --git a/drivers/spi/spi_butterfly.c b/drivers/spi/spi_butterfly.c
index c2f601f8e4f2..312987a03210 100644
--- a/drivers/spi/spi_butterfly.c
+++ b/drivers/spi/spi_butterfly.c
@@ -251,6 +251,8 @@ static void butterfly_attach(struct parport *p)
251 * setting up a platform device like this is an ugly kluge... 251 * setting up a platform device like this is an ugly kluge...
252 */ 252 */
253 pdev = platform_device_register_simple("butterfly", -1, NULL, 0); 253 pdev = platform_device_register_simple("butterfly", -1, NULL, 0);
254 if (IS_ERR(pdev))
255 return;
254 256
255 master = spi_alloc_master(&pdev->dev, sizeof *pp); 257 master = spi_alloc_master(&pdev->dev, sizeof *pp);
256 if (!master) { 258 if (!master) {
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index f2d196fa1e8b..dae4ef1e8fe5 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -64,6 +64,8 @@
64#include <linux/kthread.h> 64#include <linux/kthread.h>
65#include <linux/version.h> 65#include <linux/version.h>
66#include <linux/mutex.h> 66#include <linux/mutex.h>
67#include <linux/freezer.h>
68
67#include <asm/unaligned.h> 69#include <asm/unaligned.h>
68 70
69#include "usbatm.h" 71#include "usbatm.h"
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 840442a25b61..c3915dc28608 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -93,7 +93,7 @@ void hcd_buffer_destroy (struct usb_hcd *hcd)
93} 93}
94 94
95 95
96/* sometimes alloc/free could use kmalloc with SLAB_DMA, for 96/* sometimes alloc/free could use kmalloc with GFP_DMA, for
97 * better sharing and to leverage mm/slab.c intelligence. 97 * better sharing and to leverage mm/slab.c intelligence.
98 */ 98 */
99 99
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 9be41ed1f9a6..2651c2e2a89f 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -22,6 +22,7 @@
22#include <linux/usbdevice_fs.h> 22#include <linux/usbdevice_fs.h>
23#include <linux/kthread.h> 23#include <linux/kthread.h>
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/freezer.h>
25 26
26#include <asm/semaphore.h> 27#include <asm/semaphore.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
@@ -460,7 +461,7 @@ void usb_hub_tt_clear_buffer (struct usb_device *udev, int pipe)
460 * since each TT has "at least two" buffers that can need it (and 461 * since each TT has "at least two" buffers that can need it (and
461 * there can be many TTs per hub). even if they're uncommon. 462 * there can be many TTs per hub). even if they're uncommon.
462 */ 463 */
463 if ((clear = kmalloc (sizeof *clear, SLAB_ATOMIC)) == NULL) { 464 if ((clear = kmalloc (sizeof *clear, GFP_ATOMIC)) == NULL) {
464 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n"); 465 dev_err (&udev->dev, "can't save CLEAR_TT_BUFFER state\n");
465 /* FIXME recover somehow ... RESET_TT? */ 466 /* FIXME recover somehow ... RESET_TT? */
466 return; 467 return;
@@ -2371,7 +2372,7 @@ check_highspeed (struct usb_hub *hub, struct usb_device *udev, int port1)
2371 struct usb_qualifier_descriptor *qual; 2372 struct usb_qualifier_descriptor *qual;
2372 int status; 2373 int status;
2373 2374
2374 qual = kmalloc (sizeof *qual, SLAB_KERNEL); 2375 qual = kmalloc (sizeof *qual, GFP_KERNEL);
2375 if (qual == NULL) 2376 if (qual == NULL)
2376 return; 2377 return;
2377 2378
@@ -2922,7 +2923,7 @@ static int config_descriptors_changed(struct usb_device *udev)
2922 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength)) 2923 if (len < le16_to_cpu(udev->config[index].desc.wTotalLength))
2923 len = le16_to_cpu(udev->config[index].desc.wTotalLength); 2924 len = le16_to_cpu(udev->config[index].desc.wTotalLength);
2924 } 2925 }
2925 buf = kmalloc (len, SLAB_KERNEL); 2926 buf = kmalloc (len, GFP_KERNEL);
2926 if (buf == NULL) { 2927 if (buf == NULL) {
2927 dev_err(&udev->dev, "no mem to re-read configs after reset\n"); 2928 dev_err(&udev->dev, "no mem to re-read configs after reset\n");
2928 /* assume the worst */ 2929 /* assume the worst */
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 7390b67c609d..149aa8bfb1fe 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -488,7 +488,7 @@ void usb_sg_wait (struct usb_sg_request *io)
488 int retval; 488 int retval;
489 489
490 io->urbs [i]->dev = io->dev; 490 io->urbs [i]->dev = io->dev;
491 retval = usb_submit_urb (io->urbs [i], SLAB_ATOMIC); 491 retval = usb_submit_urb (io->urbs [i], GFP_ATOMIC);
492 492
493 /* after we submit, let completions or cancelations fire; 493 /* after we submit, let completions or cancelations fire;
494 * we handshake using io->status. 494 * we handshake using io->status.
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 8b975d15538d..c98316ce8384 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -250,7 +250,7 @@
250#include <linux/slab.h> 250#include <linux/slab.h>
251#include <linux/spinlock.h> 251#include <linux/spinlock.h>
252#include <linux/string.h> 252#include <linux/string.h>
253#include <linux/suspend.h> 253#include <linux/freezer.h>
254#include <linux/utsname.h> 254#include <linux/utsname.h>
255 255
256#include <linux/usb_ch9.h> 256#include <linux/usb_ch9.h>
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 64554acad63f..31351826f2ba 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -1236,7 +1236,7 @@ autoconf_fail:
1236 1236
1237 1237
1238 /* ok, we made sense of the hardware ... */ 1238 /* ok, we made sense of the hardware ... */
1239 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1239 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1240 if (!dev) { 1240 if (!dev) {
1241 return -ENOMEM; 1241 return -ENOMEM;
1242 } 1242 }
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index a3076da3f4eb..805a9826842d 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1864,7 +1864,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1864 } 1864 }
1865 1865
1866 /* alloc, and start init */ 1866 /* alloc, and start init */
1867 dev = kmalloc (sizeof *dev, SLAB_KERNEL); 1867 dev = kmalloc (sizeof *dev, GFP_KERNEL);
1868 if (dev == NULL){ 1868 if (dev == NULL){
1869 pr_debug("enomem %s\n", pci_name(pdev)); 1869 pr_debug("enomem %s\n", pci_name(pdev));
1870 retval = -ENOMEM; 1870 retval = -ENOMEM;
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 86924f9cdd7e..3fb1044a4db0 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -412,7 +412,7 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
412 /* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */ 412 /* FIXME readahead for O_NONBLOCK and poll(); careful with ZLPs */
413 413
414 value = -ENOMEM; 414 value = -ENOMEM;
415 kbuf = kmalloc (len, SLAB_KERNEL); 415 kbuf = kmalloc (len, GFP_KERNEL);
416 if (unlikely (!kbuf)) 416 if (unlikely (!kbuf))
417 goto free1; 417 goto free1;
418 418
@@ -456,7 +456,7 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
456 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */ 456 /* FIXME writebehind for O_NONBLOCK and poll(), qlen = 1 */
457 457
458 value = -ENOMEM; 458 value = -ENOMEM;
459 kbuf = kmalloc (len, SLAB_KERNEL); 459 kbuf = kmalloc (len, GFP_KERNEL);
460 if (!kbuf) 460 if (!kbuf)
461 goto free1; 461 goto free1;
462 if (copy_from_user (kbuf, buf, len)) { 462 if (copy_from_user (kbuf, buf, len)) {
@@ -1898,7 +1898,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1898 buf += 4; 1898 buf += 4;
1899 length -= 4; 1899 length -= 4;
1900 1900
1901 kbuf = kmalloc (length, SLAB_KERNEL); 1901 kbuf = kmalloc (length, GFP_KERNEL);
1902 if (!kbuf) 1902 if (!kbuf)
1903 return -ENOMEM; 1903 return -ENOMEM;
1904 if (copy_from_user (kbuf, buf, length)) { 1904 if (copy_from_user (kbuf, buf, length)) {
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 0b590831582c..3024c679e38e 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2861,7 +2861,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2861 } 2861 }
2862 2862
2863 /* alloc, and start init */ 2863 /* alloc, and start init */
2864 dev = kzalloc (sizeof *dev, SLAB_KERNEL); 2864 dev = kzalloc (sizeof *dev, GFP_KERNEL);
2865 if (dev == NULL){ 2865 if (dev == NULL){
2866 retval = -ENOMEM; 2866 retval = -ENOMEM;
2867 goto done; 2867 goto done;
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 48a09fd89d18..030d87c28c2f 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2581,7 +2581,7 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
2581 /* UDC_PULLUP_EN gates the chip clock */ 2581 /* UDC_PULLUP_EN gates the chip clock */
2582 // OTG_SYSCON_1_REG |= DEV_IDLE_EN; 2582 // OTG_SYSCON_1_REG |= DEV_IDLE_EN;
2583 2583
2584 udc = kzalloc(sizeof(*udc), SLAB_KERNEL); 2584 udc = kzalloc(sizeof(*udc), GFP_KERNEL);
2585 if (!udc) 2585 if (!udc)
2586 return -ENOMEM; 2586 return -ENOMEM;
2587 2587
diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c
index 0f809dd68492..40710ea1b490 100644
--- a/drivers/usb/gadget/zero.c
+++ b/drivers/usb/gadget/zero.c
@@ -1190,7 +1190,7 @@ autoconf_fail:
1190 1190
1191 1191
1192 /* ok, we made sense of the hardware ... */ 1192 /* ok, we made sense of the hardware ... */
1193 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1193 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1194 if (!dev) 1194 if (!dev)
1195 return -ENOMEM; 1195 return -ENOMEM;
1196 spin_lock_init (&dev->lock); 1196 spin_lock_init (&dev->lock);
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 34b7a31cd85b..56349d21e6ea 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -492,7 +492,7 @@ show_periodic (struct class_device *class_dev, char *buf)
492 unsigned i; 492 unsigned i;
493 __le32 tag; 493 __le32 tag;
494 494
495 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC))) 495 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
496 return 0; 496 return 0;
497 seen_count = 0; 497 seen_count = 0;
498 498
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 87eca6aeacf2..9325e46a68c0 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -188,7 +188,7 @@ static DEFINE_TIMER(bulk_eot_timer, NULL, 0, 0);
188#define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \ 188#define CHECK_ALIGN(x) if (((__u32)(x)) & 0x00000003) \
189{panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);} 189{panic("Alignment check (DWORD) failed at %s:%s:%d\n", __FILE__, __FUNCTION__, __LINE__);}
190 190
191#define SLAB_FLAG (in_interrupt() ? SLAB_ATOMIC : SLAB_KERNEL) 191#define SLAB_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
192#define KMALLOC_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL) 192#define KMALLOC_FLAG (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL)
193 193
194/* Most helpful debugging aid */ 194/* Most helpful debugging aid */
@@ -275,13 +275,13 @@ static volatile USB_SB_Desc_t TxIntrSB_zout __attribute__ ((aligned (4)));
275static int zout_buffer[4] __attribute__ ((aligned (4))); 275static int zout_buffer[4] __attribute__ ((aligned (4)));
276 276
277/* Cache for allocating new EP and SB descriptors. */ 277/* Cache for allocating new EP and SB descriptors. */
278static kmem_cache_t *usb_desc_cache; 278static struct kmem_cache *usb_desc_cache;
279 279
280/* Cache for the registers allocated in the top half. */ 280/* Cache for the registers allocated in the top half. */
281static kmem_cache_t *top_half_reg_cache; 281static struct kmem_cache *top_half_reg_cache;
282 282
283/* Cache for the data allocated in the isoc descr top half. */ 283/* Cache for the data allocated in the isoc descr top half. */
284static kmem_cache_t *isoc_compl_cache; 284static struct kmem_cache *isoc_compl_cache;
285 285
286static struct usb_bus *etrax_usb_bus; 286static struct usb_bus *etrax_usb_bus;
287 287
@@ -1743,7 +1743,7 @@ static irqreturn_t etrax_usb_tx_interrupt(int irq, void *vhc)
1743 1743
1744 *R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do); 1744 *R_DMA_CH8_SUB3_CLR_INTR = IO_STATE(R_DMA_CH8_SUB3_CLR_INTR, clr_descr, do);
1745 1745
1746 comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, SLAB_ATOMIC); 1746 comp_data = (usb_isoc_complete_data_t*)kmem_cache_alloc(isoc_compl_cache, GFP_ATOMIC);
1747 assert(comp_data != NULL); 1747 assert(comp_data != NULL);
1748 1748
1749 INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data); 1749 INIT_WORK(&comp_data->usb_bh, etrax_usb_isoc_descr_interrupt_bottom_half, comp_data);
@@ -3010,7 +3010,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
3010 if (!urb->iso_frame_desc[i].length) 3010 if (!urb->iso_frame_desc[i].length)
3011 continue; 3011 continue;
3012 3012
3013 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC); 3013 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
3014 assert(next_sb_desc != NULL); 3014 assert(next_sb_desc != NULL);
3015 3015
3016 if (urb->iso_frame_desc[i].length > 0) { 3016 if (urb->iso_frame_desc[i].length > 0) {
@@ -3063,7 +3063,7 @@ static void etrax_usb_add_to_isoc_sb_list(struct urb *urb, int epid)
3063 if (TxIsocEPList[epid].sub == 0) { 3063 if (TxIsocEPList[epid].sub == 0) {
3064 dbg_isoc("Isoc traffic not already running, allocating SB"); 3064 dbg_isoc("Isoc traffic not already running, allocating SB");
3065 3065
3066 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, SLAB_ATOMIC); 3066 next_sb_desc = (USB_SB_Desc_t*)kmem_cache_alloc(usb_desc_cache, GFP_ATOMIC);
3067 assert(next_sb_desc != NULL); 3067 assert(next_sb_desc != NULL);
3068 3068
3069 next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) | 3069 next_sb_desc->command = (IO_STATE(USB_SB_command, tt, in) |
@@ -3317,7 +3317,7 @@ static irqreturn_t etrax_usb_hc_interrupt_top_half(int irq, void *vhc)
3317 3317
3318 restore_flags(flags); 3318 restore_flags(flags);
3319 3319
3320 reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, SLAB_ATOMIC); 3320 reg = (usb_interrupt_registers_t *)kmem_cache_alloc(top_half_reg_cache, GFP_ATOMIC);
3321 3321
3322 assert(reg != NULL); 3322 assert(reg != NULL);
3323 3323
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 8293c1d4be3f..0f47a57dac28 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -505,7 +505,7 @@ show_periodic (struct class_device *class_dev, char *buf)
505 char *next; 505 char *next;
506 unsigned i; 506 unsigned i;
507 507
508 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, SLAB_ATOMIC))) 508 if (!(seen = kmalloc (DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC)))
509 return 0; 509 return 0;
510 seen_count = 0; 510 seen_count = 0;
511 511
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 2dbb77414905..7f26f9bdbaf1 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -134,7 +134,7 @@ static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind)
134{ 134{
135 struct i2c_client *c; 135 struct i2c_client *c;
136 136
137 c = (struct i2c_client *)kzalloc(sizeof(*c), SLAB_KERNEL); 137 c = (struct i2c_client *)kzalloc(sizeof(*c), GFP_KERNEL);
138 138
139 if (!c) 139 if (!c)
140 return -ENOMEM; 140 return -ENOMEM;
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 226bf3de8edd..e87692c31be4 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -81,7 +81,7 @@ MODULE_PARM_DESC(debug, "Debug level");
81static char *errbuf; 81static char *errbuf;
82#define ERRBUF_LEN (32 * 1024) 82#define ERRBUF_LEN (32 * 1024)
83 83
84static kmem_cache_t *uhci_up_cachep; /* urb_priv */ 84static struct kmem_cache *uhci_up_cachep; /* urb_priv */
85 85
86static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state); 86static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state);
87static void wakeup_rh(struct uhci_hcd *uhci); 87static void wakeup_rh(struct uhci_hcd *uhci);
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 06115f22a4fa..30b88459ac7d 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -498,7 +498,7 @@ static inline struct urb_priv *uhci_alloc_urb_priv(struct uhci_hcd *uhci,
498{ 498{
499 struct urb_priv *urbp; 499 struct urb_priv *urbp;
500 500
501 urbp = kmem_cache_alloc(uhci_up_cachep, SLAB_ATOMIC); 501 urbp = kmem_cache_alloc(uhci_up_cachep, GFP_ATOMIC);
502 if (!urbp) 502 if (!urbp)
503 return NULL; 503 return NULL;
504 504
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index 0096373b5f98..909138e5aa04 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -152,7 +152,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
152 if (!acecad || !input_dev) 152 if (!acecad || !input_dev)
153 goto fail1; 153 goto fail1;
154 154
155 acecad->data = usb_buffer_alloc(dev, 8, SLAB_KERNEL, &acecad->data_dma); 155 acecad->data = usb_buffer_alloc(dev, 8, GFP_KERNEL, &acecad->data_dma);
156 if (!acecad->data) 156 if (!acecad->data)
157 goto fail1; 157 goto fail1;
158 158
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index bf428184608f..9f52429ce654 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -1988,7 +1988,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
1988 goto fail1; 1988 goto fail1;
1989 1989
1990 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH, 1990 aiptek->data = usb_buffer_alloc(usbdev, AIPTEK_PACKET_LENGTH,
1991 SLAB_ATOMIC, &aiptek->data_dma); 1991 GFP_ATOMIC, &aiptek->data_dma);
1992 if (!aiptek->data) 1992 if (!aiptek->data)
1993 goto fail1; 1993 goto fail1;
1994 1994
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index ff23318dc301..b724e36f7b92 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -592,7 +592,7 @@ static void ati_remote_irq_in(struct urb *urb)
592 __FUNCTION__, urb->status); 592 __FUNCTION__, urb->status);
593 } 593 }
594 594
595 retval = usb_submit_urb(urb, SLAB_ATOMIC); 595 retval = usb_submit_urb(urb, GFP_ATOMIC);
596 if (retval) 596 if (retval)
597 dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n", 597 dev_err(&ati_remote->interface->dev, "%s: usb_submit_urb()=%d\n",
598 __FUNCTION__, retval); 598 __FUNCTION__, retval);
@@ -604,12 +604,12 @@ static void ati_remote_irq_in(struct urb *urb)
604static int ati_remote_alloc_buffers(struct usb_device *udev, 604static int ati_remote_alloc_buffers(struct usb_device *udev,
605 struct ati_remote *ati_remote) 605 struct ati_remote *ati_remote)
606{ 606{
607 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 607 ati_remote->inbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
608 &ati_remote->inbuf_dma); 608 &ati_remote->inbuf_dma);
609 if (!ati_remote->inbuf) 609 if (!ati_remote->inbuf)
610 return -1; 610 return -1;
611 611
612 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, SLAB_ATOMIC, 612 ati_remote->outbuf = usb_buffer_alloc(udev, DATA_BUFSIZE, GFP_ATOMIC,
613 &ati_remote->outbuf_dma); 613 &ati_remote->outbuf_dma);
614 if (!ati_remote->outbuf) 614 if (!ati_remote->outbuf)
615 return -1; 615 return -1;
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 4295bab4f1e2..f1d0e1d69828 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1079,7 +1079,7 @@ static void hid_irq_in(struct urb *urb)
1079 warn("input irq status %d received", urb->status); 1079 warn("input irq status %d received", urb->status);
1080 } 1080 }
1081 1081
1082 status = usb_submit_urb(urb, SLAB_ATOMIC); 1082 status = usb_submit_urb(urb, GFP_ATOMIC);
1083 if (status) { 1083 if (status) {
1084 clear_bit(HID_IN_RUNNING, &hid->iofl); 1084 clear_bit(HID_IN_RUNNING, &hid->iofl);
1085 if (status != -EPERM) { 1085 if (status != -EPERM) {
@@ -1864,13 +1864,13 @@ static void hid_find_max_report(struct hid_device *hid, unsigned int type, int *
1864 1864
1865static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid) 1865static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
1866{ 1866{
1867 if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->inbuf_dma))) 1867 if (!(hid->inbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->inbuf_dma)))
1868 return -1; 1868 return -1;
1869 if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->outbuf_dma))) 1869 if (!(hid->outbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->outbuf_dma)))
1870 return -1; 1870 return -1;
1871 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), SLAB_ATOMIC, &hid->cr_dma))) 1871 if (!(hid->cr = usb_buffer_alloc(dev, sizeof(*(hid->cr)), GFP_ATOMIC, &hid->cr_dma)))
1872 return -1; 1872 return -1;
1873 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, SLAB_ATOMIC, &hid->ctrlbuf_dma))) 1873 if (!(hid->ctrlbuf = usb_buffer_alloc(dev, hid->bufsize, GFP_ATOMIC, &hid->ctrlbuf_dma)))
1874 return -1; 1874 return -1;
1875 1875
1876 return 0; 1876 return 0;
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index 50aa8108a50b..98bd323369c7 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -456,7 +456,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
456 remote->in_endpoint = endpoint; 456 remote->in_endpoint = endpoint;
457 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */ 457 remote->toggle = -1; /* Set to -1 so we will always not match the toggle from the first remote message. */
458 458
459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, SLAB_ATOMIC, &remote->in_dma); 459 remote->in_buffer = usb_buffer_alloc(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma);
460 if (!remote->in_buffer) { 460 if (!remote->in_buffer) {
461 retval = -ENOMEM; 461 retval = -ENOMEM;
462 goto fail1; 462 goto fail1;
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 79a85d46cb13..92c4e07da4c8 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -164,7 +164,7 @@ static int mtouchusb_alloc_buffers(struct usb_device *udev, struct mtouch_usb *m
164 dbg("%s - called", __FUNCTION__); 164 dbg("%s - called", __FUNCTION__);
165 165
166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE, 166 mtouch->data = usb_buffer_alloc(udev, MTOUCHUSB_REPORT_DATA_SIZE,
167 SLAB_ATOMIC, &mtouch->data_dma); 167 GFP_ATOMIC, &mtouch->data_dma);
168 168
169 if (!mtouch->data) 169 if (!mtouch->data)
170 return -1; 170 return -1;
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index 0bf91778c40d..fea97e5437f8 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -277,12 +277,12 @@ static int powermate_input_event(struct input_dev *dev, unsigned int type, unsig
277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm) 277static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_device *pm)
278{ 278{
279 pm->data = usb_buffer_alloc(udev, POWERMATE_PAYLOAD_SIZE_MAX, 279 pm->data = usb_buffer_alloc(udev, POWERMATE_PAYLOAD_SIZE_MAX,
280 SLAB_ATOMIC, &pm->data_dma); 280 GFP_ATOMIC, &pm->data_dma);
281 if (!pm->data) 281 if (!pm->data)
282 return -1; 282 return -1;
283 283
284 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)), 284 pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)),
285 SLAB_ATOMIC, &pm->configcr_dma); 285 GFP_ATOMIC, &pm->configcr_dma);
286 if (!pm->configcr) 286 if (!pm->configcr)
287 return -1; 287 return -1;
288 288
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 05c0d1ca39ab..2a314b065922 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -248,7 +248,7 @@ static int touchkit_alloc_buffers(struct usb_device *udev,
248 struct touchkit_usb *touchkit) 248 struct touchkit_usb *touchkit)
249{ 249{
250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE, 250 touchkit->data = usb_buffer_alloc(udev, TOUCHKIT_REPORT_DATA_SIZE,
251 SLAB_ATOMIC, &touchkit->data_dma); 251 GFP_ATOMIC, &touchkit->data_dma);
252 252
253 if (!touchkit->data) 253 if (!touchkit->data)
254 return -1; 254 return -1;
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index dac88640eab6..8505824848f6 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -122,7 +122,7 @@ static void usb_kbd_irq(struct urb *urb)
122 memcpy(kbd->old, kbd->new, 8); 122 memcpy(kbd->old, kbd->new, 8);
123 123
124resubmit: 124resubmit:
125 i = usb_submit_urb (urb, SLAB_ATOMIC); 125 i = usb_submit_urb (urb, GFP_ATOMIC);
126 if (i) 126 if (i)
127 err ("can't resubmit intr, %s-%s/input0, status %d", 127 err ("can't resubmit intr, %s-%s/input0, status %d",
128 kbd->usbdev->bus->bus_name, 128 kbd->usbdev->bus->bus_name,
@@ -196,11 +196,11 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
196 return -1; 196 return -1;
197 if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL))) 197 if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL)))
198 return -1; 198 return -1;
199 if (!(kbd->new = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &kbd->new_dma))) 199 if (!(kbd->new = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
200 return -1; 200 return -1;
201 if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), SLAB_ATOMIC, &kbd->cr_dma))) 201 if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), GFP_ATOMIC, &kbd->cr_dma)))
202 return -1; 202 return -1;
203 if (!(kbd->leds = usb_buffer_alloc(dev, 1, SLAB_ATOMIC, &kbd->leds_dma))) 203 if (!(kbd->leds = usb_buffer_alloc(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
204 return -1; 204 return -1;
205 205
206 return 0; 206 return 0;
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index 68a55642c082..64a33e420cfb 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -86,7 +86,7 @@ static void usb_mouse_irq(struct urb *urb)
86 86
87 input_sync(dev); 87 input_sync(dev);
88resubmit: 88resubmit:
89 status = usb_submit_urb (urb, SLAB_ATOMIC); 89 status = usb_submit_urb (urb, GFP_ATOMIC);
90 if (status) 90 if (status)
91 err ("can't resubmit intr, %s-%s/input0, status %d", 91 err ("can't resubmit intr, %s-%s/input0, status %d",
92 mouse->usbdev->bus->bus_name, 92 mouse->usbdev->bus->bus_name,
@@ -137,7 +137,7 @@ static int usb_mouse_probe(struct usb_interface *intf, const struct usb_device_i
137 if (!mouse || !input_dev) 137 if (!mouse || !input_dev)
138 goto fail1; 138 goto fail1;
139 139
140 mouse->data = usb_buffer_alloc(dev, 8, SLAB_ATOMIC, &mouse->data_dma); 140 mouse->data = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &mouse->data_dma);
141 if (!mouse->data) 141 if (!mouse->data)
142 goto fail1; 142 goto fail1;
143 143
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index 49704d4ed0e2..7f3c57da9bc0 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -680,7 +680,7 @@ static int usbtouch_probe(struct usb_interface *intf,
680 type->process_pkt = usbtouch_process_pkt; 680 type->process_pkt = usbtouch_process_pkt;
681 681
682 usbtouch->data = usb_buffer_alloc(udev, type->rept_size, 682 usbtouch->data = usb_buffer_alloc(udev, type->rept_size,
683 SLAB_KERNEL, &usbtouch->data_dma); 683 GFP_KERNEL, &usbtouch->data_dma);
684 if (!usbtouch->data) 684 if (!usbtouch->data)
685 goto out_free; 685 goto out_free;
686 686
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index df97e5c803f9..e4bc76ebc835 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -325,7 +325,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
325 goto fail1; 325 goto fail1;
326 326
327 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN, 327 xpad->idata = usb_buffer_alloc(udev, XPAD_PKT_LEN,
328 SLAB_ATOMIC, &xpad->idata_dma); 328 GFP_ATOMIC, &xpad->idata_dma);
329 if (!xpad->idata) 329 if (!xpad->idata)
330 goto fail1; 330 goto fail1;
331 331
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 2268ca311ade..caff8e6d7448 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -874,17 +874,17 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
874 874
875 /* allocate usb buffers */ 875 /* allocate usb buffers */
876 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN, 876 yld->irq_data = usb_buffer_alloc(udev, USB_PKT_LEN,
877 SLAB_ATOMIC, &yld->irq_dma); 877 GFP_ATOMIC, &yld->irq_dma);
878 if (yld->irq_data == NULL) 878 if (yld->irq_data == NULL)
879 return usb_cleanup(yld, -ENOMEM); 879 return usb_cleanup(yld, -ENOMEM);
880 880
881 yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN, 881 yld->ctl_data = usb_buffer_alloc(udev, USB_PKT_LEN,
882 SLAB_ATOMIC, &yld->ctl_dma); 882 GFP_ATOMIC, &yld->ctl_dma);
883 if (!yld->ctl_data) 883 if (!yld->ctl_data)
884 return usb_cleanup(yld, -ENOMEM); 884 return usb_cleanup(yld, -ENOMEM);
885 885
886 yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)), 886 yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)),
887 SLAB_ATOMIC, &yld->ctl_req_dma); 887 GFP_ATOMIC, &yld->ctl_req_dma);
888 if (yld->ctl_req == NULL) 888 if (yld->ctl_req == NULL)
889 return usb_cleanup(yld, -ENOMEM); 889 return usb_cleanup(yld, -ENOMEM);
890 890
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index 9659c79e187e..371bf2b1197d 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -377,7 +377,7 @@ static void interfacekit_irq(struct urb *urb)
377 schedule_delayed_work(&kit->do_notify, 0); 377 schedule_delayed_work(&kit->do_notify, 0);
378 378
379resubmit: 379resubmit:
380 status = usb_submit_urb(urb, SLAB_ATOMIC); 380 status = usb_submit_urb(urb, GFP_ATOMIC);
381 if (status) 381 if (status)
382 err("can't resubmit intr, %s-%s/interfacekit0, status %d", 382 err("can't resubmit intr, %s-%s/interfacekit0, status %d",
383 kit->udev->bus->bus_name, 383 kit->udev->bus->bus_name,
@@ -568,7 +568,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
568 568
569 kit->dev_no = -1; 569 kit->dev_no = -1;
570 kit->ifkit = ifkit; 570 kit->ifkit = ifkit;
571 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &kit->data_dma); 571 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &kit->data_dma);
572 if (!kit->data) 572 if (!kit->data)
573 goto out; 573 goto out;
574 574
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
index 2bb4fa572bb7..5727e1ea2f91 100644
--- a/drivers/usb/misc/phidgetmotorcontrol.c
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -151,7 +151,7 @@ static void motorcontrol_irq(struct urb *urb)
151 schedule_delayed_work(&mc->do_notify, 0); 151 schedule_delayed_work(&mc->do_notify, 0);
152 152
153resubmit: 153resubmit:
154 status = usb_submit_urb(urb, SLAB_ATOMIC); 154 status = usb_submit_urb(urb, GFP_ATOMIC);
155 if (status) 155 if (status)
156 dev_err(&mc->intf->dev, 156 dev_err(&mc->intf->dev,
157 "can't resubmit intr, %s-%s/motorcontrol0, status %d", 157 "can't resubmit intr, %s-%s/motorcontrol0, status %d",
@@ -338,7 +338,7 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic
338 goto out; 338 goto out;
339 339
340 mc->dev_no = -1; 340 mc->dev_no = -1;
341 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &mc->data_dma); 341 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, GFP_ATOMIC, &mc->data_dma);
342 if (!mc->data) 342 if (!mc->data)
343 goto out; 343 goto out;
344 344
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 194065dbb51f..fb321864a92d 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -213,7 +213,7 @@ static struct urb *simple_alloc_urb (
213 213
214 if (bytes < 0) 214 if (bytes < 0)
215 return NULL; 215 return NULL;
216 urb = usb_alloc_urb (0, SLAB_KERNEL); 216 urb = usb_alloc_urb (0, GFP_KERNEL);
217 if (!urb) 217 if (!urb)
218 return urb; 218 return urb;
219 usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL); 219 usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL);
@@ -223,7 +223,7 @@ static struct urb *simple_alloc_urb (
223 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP; 223 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
224 if (usb_pipein (pipe)) 224 if (usb_pipein (pipe))
225 urb->transfer_flags |= URB_SHORT_NOT_OK; 225 urb->transfer_flags |= URB_SHORT_NOT_OK;
226 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL, 226 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
227 &urb->transfer_dma); 227 &urb->transfer_dma);
228 if (!urb->transfer_buffer) { 228 if (!urb->transfer_buffer) {
229 usb_free_urb (urb); 229 usb_free_urb (urb);
@@ -315,7 +315,7 @@ static int simple_io (
315 init_completion (&completion); 315 init_completion (&completion);
316 if (usb_pipeout (urb->pipe)) 316 if (usb_pipeout (urb->pipe))
317 simple_fill_buf (urb); 317 simple_fill_buf (urb);
318 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) 318 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0)
319 break; 319 break;
320 320
321 /* NOTE: no timeouts; can't be broken out of by interrupt */ 321 /* NOTE: no timeouts; can't be broken out of by interrupt */
@@ -374,7 +374,7 @@ alloc_sglist (int nents, int max, int vary)
374 unsigned i; 374 unsigned i;
375 unsigned size = max; 375 unsigned size = max;
376 376
377 sg = kmalloc (nents * sizeof *sg, SLAB_KERNEL); 377 sg = kmalloc (nents * sizeof *sg, GFP_KERNEL);
378 if (!sg) 378 if (!sg)
379 return NULL; 379 return NULL;
380 380
@@ -382,7 +382,7 @@ alloc_sglist (int nents, int max, int vary)
382 char *buf; 382 char *buf;
383 unsigned j; 383 unsigned j;
384 384
385 buf = kzalloc (size, SLAB_KERNEL); 385 buf = kzalloc (size, GFP_KERNEL);
386 if (!buf) { 386 if (!buf) {
387 free_sglist (sg, i); 387 free_sglist (sg, i);
388 return NULL; 388 return NULL;
@@ -428,7 +428,7 @@ static int perform_sglist (
428 (udev->speed == USB_SPEED_HIGH) 428 (udev->speed == USB_SPEED_HIGH)
429 ? (INTERRUPT_RATE << 3) 429 ? (INTERRUPT_RATE << 3)
430 : INTERRUPT_RATE, 430 : INTERRUPT_RATE,
431 sg, nents, 0, SLAB_KERNEL); 431 sg, nents, 0, GFP_KERNEL);
432 432
433 if (retval) 433 if (retval)
434 break; 434 break;
@@ -819,7 +819,7 @@ error:
819 819
820 /* resubmit if we need to, else mark this as done */ 820 /* resubmit if we need to, else mark this as done */
821 if ((status == 0) && (ctx->pending < ctx->count)) { 821 if ((status == 0) && (ctx->pending < ctx->count)) {
822 if ((status = usb_submit_urb (urb, SLAB_ATOMIC)) != 0) { 822 if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) {
823 dbg ("can't resubmit ctrl %02x.%02x, err %d", 823 dbg ("can't resubmit ctrl %02x.%02x, err %d",
824 reqp->bRequestType, reqp->bRequest, status); 824 reqp->bRequestType, reqp->bRequest, status);
825 urb->dev = NULL; 825 urb->dev = NULL;
@@ -855,7 +855,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
855 * as with bulk/intr sglists, sglen is the queue depth; it also 855 * as with bulk/intr sglists, sglen is the queue depth; it also
856 * controls which subtests run (more tests than sglen) or rerun. 856 * controls which subtests run (more tests than sglen) or rerun.
857 */ 857 */
858 urb = kcalloc(param->sglen, sizeof(struct urb *), SLAB_KERNEL); 858 urb = kcalloc(param->sglen, sizeof(struct urb *), GFP_KERNEL);
859 if (!urb) 859 if (!urb)
860 return -ENOMEM; 860 return -ENOMEM;
861 for (i = 0; i < param->sglen; i++) { 861 for (i = 0; i < param->sglen; i++) {
@@ -981,7 +981,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
981 if (!u) 981 if (!u)
982 goto cleanup; 982 goto cleanup;
983 983
984 reqp = usb_buffer_alloc (udev, sizeof *reqp, SLAB_KERNEL, 984 reqp = usb_buffer_alloc (udev, sizeof *reqp, GFP_KERNEL,
985 &u->setup_dma); 985 &u->setup_dma);
986 if (!reqp) 986 if (!reqp)
987 goto cleanup; 987 goto cleanup;
@@ -999,7 +999,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
999 context.urb = urb; 999 context.urb = urb;
1000 spin_lock_irq (&context.lock); 1000 spin_lock_irq (&context.lock);
1001 for (i = 0; i < param->sglen; i++) { 1001 for (i = 0; i < param->sglen; i++) {
1002 context.status = usb_submit_urb (urb [i], SLAB_ATOMIC); 1002 context.status = usb_submit_urb (urb [i], GFP_ATOMIC);
1003 if (context.status != 0) { 1003 if (context.status != 0) {
1004 dbg ("can't submit urb[%d], status %d", 1004 dbg ("can't submit urb[%d], status %d",
1005 i, context.status); 1005 i, context.status);
@@ -1041,7 +1041,7 @@ static void unlink1_callback (struct urb *urb)
1041 1041
1042 // we "know" -EPIPE (stall) never happens 1042 // we "know" -EPIPE (stall) never happens
1043 if (!status) 1043 if (!status)
1044 status = usb_submit_urb (urb, SLAB_ATOMIC); 1044 status = usb_submit_urb (urb, GFP_ATOMIC);
1045 if (status) { 1045 if (status) {
1046 urb->status = status; 1046 urb->status = status;
1047 complete ((struct completion *) urb->context); 1047 complete ((struct completion *) urb->context);
@@ -1067,7 +1067,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
1067 * FIXME want additional tests for when endpoint is STALLing 1067 * FIXME want additional tests for when endpoint is STALLing
1068 * due to errors, or is just NAKing requests. 1068 * due to errors, or is just NAKing requests.
1069 */ 1069 */
1070 if ((retval = usb_submit_urb (urb, SLAB_KERNEL)) != 0) { 1070 if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) {
1071 dev_dbg (&dev->intf->dev, "submit fail %d\n", retval); 1071 dev_dbg (&dev->intf->dev, "submit fail %d\n", retval);
1072 return retval; 1072 return retval;
1073 } 1073 }
@@ -1251,7 +1251,7 @@ static int ctrl_out (struct usbtest_dev *dev,
1251 if (length < 1 || length > 0xffff || vary >= length) 1251 if (length < 1 || length > 0xffff || vary >= length)
1252 return -EINVAL; 1252 return -EINVAL;
1253 1253
1254 buf = kmalloc(length, SLAB_KERNEL); 1254 buf = kmalloc(length, GFP_KERNEL);
1255 if (!buf) 1255 if (!buf)
1256 return -ENOMEM; 1256 return -ENOMEM;
1257 1257
@@ -1403,7 +1403,7 @@ static struct urb *iso_alloc_urb (
1403 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11)); 1403 maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
1404 packets = (bytes + maxp - 1) / maxp; 1404 packets = (bytes + maxp - 1) / maxp;
1405 1405
1406 urb = usb_alloc_urb (packets, SLAB_KERNEL); 1406 urb = usb_alloc_urb (packets, GFP_KERNEL);
1407 if (!urb) 1407 if (!urb)
1408 return urb; 1408 return urb;
1409 urb->dev = udev; 1409 urb->dev = udev;
@@ -1411,7 +1411,7 @@ static struct urb *iso_alloc_urb (
1411 1411
1412 urb->number_of_packets = packets; 1412 urb->number_of_packets = packets;
1413 urb->transfer_buffer_length = bytes; 1413 urb->transfer_buffer_length = bytes;
1414 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, SLAB_KERNEL, 1414 urb->transfer_buffer = usb_buffer_alloc (udev, bytes, GFP_KERNEL,
1415 &urb->transfer_dma); 1415 &urb->transfer_dma);
1416 if (!urb->transfer_buffer) { 1416 if (!urb->transfer_buffer) {
1417 usb_free_urb (urb); 1417 usb_free_urb (urb);
@@ -1481,7 +1481,7 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
1481 spin_lock_irq (&context.lock); 1481 spin_lock_irq (&context.lock);
1482 for (i = 0; i < param->sglen; i++) { 1482 for (i = 0; i < param->sglen; i++) {
1483 ++context.pending; 1483 ++context.pending;
1484 status = usb_submit_urb (urbs [i], SLAB_ATOMIC); 1484 status = usb_submit_urb (urbs [i], GFP_ATOMIC);
1485 if (status < 0) { 1485 if (status < 0) {
1486 ERROR (dev, "submit iso[%d], error %d\n", i, status); 1486 ERROR (dev, "submit iso[%d], error %d\n", i, status);
1487 if (i == 0) { 1487 if (i == 0) {
@@ -1900,7 +1900,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1900 } 1900 }
1901#endif 1901#endif
1902 1902
1903 dev = kzalloc(sizeof(*dev), SLAB_KERNEL); 1903 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1904 if (!dev) 1904 if (!dev)
1905 return -ENOMEM; 1905 return -ENOMEM;
1906 info = (struct usbtest_info *) id->driver_info; 1906 info = (struct usbtest_info *) id->driver_info;
@@ -1910,7 +1910,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
1910 dev->intf = intf; 1910 dev->intf = intf;
1911 1911
1912 /* cacheline-aligned scratch for i/o */ 1912 /* cacheline-aligned scratch for i/o */
1913 if ((dev->buf = kmalloc (TBUF_SIZE, SLAB_KERNEL)) == NULL) { 1913 if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) {
1914 kfree (dev); 1914 kfree (dev);
1915 return -ENOMEM; 1915 return -ENOMEM;
1916 } 1916 }
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 7a2346c53284..05cf2c9a8f84 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -50,7 +50,7 @@ struct mon_event_text {
50 50
51#define SLAB_NAME_SZ 30 51#define SLAB_NAME_SZ 30
52struct mon_reader_text { 52struct mon_reader_text {
53 kmem_cache_t *e_slab; 53 struct kmem_cache *e_slab;
54 int nevents; 54 int nevents;
55 struct list_head e_list; 55 struct list_head e_list;
56 struct mon_reader r; /* In C, parent class can be placed anywhere */ 56 struct mon_reader r; /* In C, parent class can be placed anywhere */
@@ -63,7 +63,7 @@ struct mon_reader_text {
63 char slab_name[SLAB_NAME_SZ]; 63 char slab_name[SLAB_NAME_SZ];
64}; 64};
65 65
66static void mon_text_ctor(void *, kmem_cache_t *, unsigned long); 66static void mon_text_ctor(void *, struct kmem_cache *, unsigned long);
67 67
68/* 68/*
69 * mon_text_submit 69 * mon_text_submit
@@ -147,7 +147,7 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
147 stamp = mon_get_timestamp(); 147 stamp = mon_get_timestamp();
148 148
149 if (rp->nevents >= EVENT_MAX || 149 if (rp->nevents >= EVENT_MAX ||
150 (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) { 150 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
151 rp->r.m_bus->cnt_text_lost++; 151 rp->r.m_bus->cnt_text_lost++;
152 return; 152 return;
153 } 153 }
@@ -188,7 +188,7 @@ static void mon_text_error(void *data, struct urb *urb, int error)
188 struct mon_event_text *ep; 188 struct mon_event_text *ep;
189 189
190 if (rp->nevents >= EVENT_MAX || 190 if (rp->nevents >= EVENT_MAX ||
191 (ep = kmem_cache_alloc(rp->e_slab, SLAB_ATOMIC)) == NULL) { 191 (ep = kmem_cache_alloc(rp->e_slab, GFP_ATOMIC)) == NULL) {
192 rp->r.m_bus->cnt_text_lost++; 192 rp->r.m_bus->cnt_text_lost++;
193 return; 193 return;
194 } 194 }
@@ -450,7 +450,7 @@ const struct file_operations mon_fops_text = {
450/* 450/*
451 * Slab interface: constructor. 451 * Slab interface: constructor.
452 */ 452 */
453static void mon_text_ctor(void *mem, kmem_cache_t *slab, unsigned long sflags) 453static void mon_text_ctor(void *mem, struct kmem_cache *slab, unsigned long sflags)
454{ 454{
455 /* 455 /*
456 * Nothing to initialize. No, really! 456 * Nothing to initialize. No, really!
diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c
index 907b820a5faf..4852012735f6 100644
--- a/drivers/usb/net/catc.c
+++ b/drivers/usb/net/catc.c
@@ -345,7 +345,7 @@ static void catc_irq_done(struct urb *urb)
345 } 345 }
346 } 346 }
347resubmit: 347resubmit:
348 status = usb_submit_urb (urb, SLAB_ATOMIC); 348 status = usb_submit_urb (urb, GFP_ATOMIC);
349 if (status) 349 if (status)
350 err ("can't resubmit intr, %s-%s, status %d", 350 err ("can't resubmit intr, %s-%s, status %d",
351 catc->usbdev->bus->bus_name, 351 catc->usbdev->bus->bus_name,
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index a77410562e12..493635954513 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -383,7 +383,7 @@ static void nc_ensure_sync(struct usbnet *dev)
383 int status; 383 int status;
384 384
385 /* Send a flush */ 385 /* Send a flush */
386 urb = usb_alloc_urb(0, SLAB_ATOMIC); 386 urb = usb_alloc_urb(0, GFP_ATOMIC);
387 if (!urb) 387 if (!urb)
388 return; 388 return;
389 389
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index b5690b3834e3..d48c024cff59 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -856,7 +856,7 @@ static void intr_callback(struct urb *urb)
856 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4]; 856 pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4];
857 } 857 }
858 858
859 status = usb_submit_urb(urb, SLAB_ATOMIC); 859 status = usb_submit_urb(urb, GFP_ATOMIC);
860 if (status == -ENODEV) 860 if (status == -ENODEV)
861 netif_device_detach(pegasus->net); 861 netif_device_detach(pegasus->net);
862 if (status && netif_msg_timer(pegasus)) 862 if (status && netif_msg_timer(pegasus))
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c
index c2a28d88ef3c..99f26b3e502f 100644
--- a/drivers/usb/net/rndis_host.c
+++ b/drivers/usb/net/rndis_host.c
@@ -469,7 +469,7 @@ static void rndis_unbind(struct usbnet *dev, struct usb_interface *intf)
469 struct rndis_halt *halt; 469 struct rndis_halt *halt;
470 470
471 /* try to clear any rndis state/activity (no i/o from stack!) */ 471 /* try to clear any rndis state/activity (no i/o from stack!) */
472 halt = kcalloc(1, sizeof *halt, SLAB_KERNEL); 472 halt = kcalloc(1, sizeof *halt, GFP_KERNEL);
473 if (halt) { 473 if (halt) {
474 halt->msg_type = RNDIS_MSG_HALT; 474 halt->msg_type = RNDIS_MSG_HALT;
475 halt->msg_len = ccpu2(sizeof *halt); 475 halt->msg_len = ccpu2(sizeof *halt);
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index 72171f94ded4..c54235f73cb6 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -587,7 +587,7 @@ static void intr_callback(struct urb *urb)
587 } 587 }
588 588
589resubmit: 589resubmit:
590 status = usb_submit_urb (urb, SLAB_ATOMIC); 590 status = usb_submit_urb (urb, GFP_ATOMIC);
591 if (status == -ENODEV) 591 if (status == -ENODEV)
592 netif_device_detach(dev->netdev); 592 netif_device_detach(dev->netdev);
593 else if (status) 593 else if (status)
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 327f97555679..6e39e9988259 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -179,9 +179,9 @@ static int init_status (struct usbnet *dev, struct usb_interface *intf)
179 period = max ((int) dev->status->desc.bInterval, 179 period = max ((int) dev->status->desc.bInterval,
180 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3); 180 (dev->udev->speed == USB_SPEED_HIGH) ? 7 : 3);
181 181
182 buf = kmalloc (maxp, SLAB_KERNEL); 182 buf = kmalloc (maxp, GFP_KERNEL);
183 if (buf) { 183 if (buf) {
184 dev->interrupt = usb_alloc_urb (0, SLAB_KERNEL); 184 dev->interrupt = usb_alloc_urb (0, GFP_KERNEL);
185 if (!dev->interrupt) { 185 if (!dev->interrupt) {
186 kfree (buf); 186 kfree (buf);
187 return -ENOMEM; 187 return -ENOMEM;
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 82cd15b894b0..70f93b18292f 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -363,7 +363,7 @@ static int mos7720_open(struct usb_serial_port *port, struct file * filp)
363 363
364 /* Initialising the write urb pool */ 364 /* Initialising the write urb pool */
365 for (j = 0; j < NUM_URBS; ++j) { 365 for (j = 0; j < NUM_URBS; ++j) {
366 urb = usb_alloc_urb(0,SLAB_ATOMIC); 366 urb = usb_alloc_urb(0,GFP_ATOMIC);
367 mos7720_port->write_urb_pool[j] = urb; 367 mos7720_port->write_urb_pool[j] = urb;
368 368
369 if (urb == NULL) { 369 if (urb == NULL) {
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 02c89e10b2cf..5432c6340086 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -826,7 +826,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
826 826
827 /* Initialising the write urb pool */ 827 /* Initialising the write urb pool */
828 for (j = 0; j < NUM_URBS; ++j) { 828 for (j = 0; j < NUM_URBS; ++j) {
829 urb = usb_alloc_urb(0, SLAB_ATOMIC); 829 urb = usb_alloc_urb(0, GFP_ATOMIC);
830 mos7840_port->write_urb_pool[j] = urb; 830 mos7840_port->write_urb_pool[j] = urb;
831 831
832 if (urb == NULL) { 832 if (urb == NULL) {
@@ -2786,7 +2786,7 @@ static int mos7840_startup(struct usb_serial *serial)
2786 i + 1, status); 2786 i + 1, status);
2787 2787
2788 } 2788 }
2789 mos7840_port->control_urb = usb_alloc_urb(0, SLAB_ATOMIC); 2789 mos7840_port->control_urb = usb_alloc_urb(0, GFP_ATOMIC);
2790 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL); 2790 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
2791 2791
2792 } 2792 }
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 3a158d58441f..e565d3d2ab29 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -76,7 +76,7 @@ static void usb_onetouch_irq(struct urb *urb)
76 input_sync(dev); 76 input_sync(dev);
77 77
78resubmit: 78resubmit:
79 status = usb_submit_urb (urb, SLAB_ATOMIC); 79 status = usb_submit_urb (urb, GFP_ATOMIC);
80 if (status) 80 if (status)
81 err ("can't resubmit intr, %s-%s/input0, status %d", 81 err ("can't resubmit intr, %s-%s/input0, status %d",
82 onetouch->udev->bus->bus_name, 82 onetouch->udev->bus->bus_name,
@@ -154,7 +154,7 @@ int onetouch_connect_input(struct us_data *ss)
154 goto fail1; 154 goto fail1;
155 155
156 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, 156 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,
157 SLAB_ATOMIC, &onetouch->data_dma); 157 GFP_ATOMIC, &onetouch->data_dma);
158 if (!onetouch->data) 158 if (!onetouch->data)
159 goto fail1; 159 goto fail1;
160 160
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 47644b5b6155..323293a3e61f 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -427,7 +427,7 @@ static int usb_stor_bulk_transfer_sglist(struct us_data *us, unsigned int pipe,
427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__, 427 US_DEBUGP("%s: xfer %u bytes, %d entries\n", __FUNCTION__,
428 length, num_sg); 428 length, num_sg);
429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0, 429 result = usb_sg_init(&us->current_sg, us->pusb_dev, pipe, 0,
430 sg, num_sg, length, SLAB_NOIO); 430 sg, num_sg, length, GFP_NOIO);
431 if (result) { 431 if (result) {
432 US_DEBUGP("usb_sg_init returned %d\n", result); 432 US_DEBUGP("usb_sg_init returned %d\n", result);
433 return USB_STOR_XFER_ERROR; 433 return USB_STOR_XFER_ERROR;
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index b401084b3d22..70644506651f 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -49,7 +49,7 @@
49 49
50#include <linux/sched.h> 50#include <linux/sched.h>
51#include <linux/errno.h> 51#include <linux/errno.h>
52#include <linux/suspend.h> 52#include <linux/freezer.h>
53#include <linux/module.h> 53#include <linux/module.h>
54#include <linux/init.h> 54#include <linux/init.h>
55#include <linux/slab.h> 55#include <linux/slab.h>
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 0d3643fc6293..a454dcb8e215 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -380,7 +380,7 @@ static void gxfb_remove(struct pci_dev *pdev)
380} 380}
381 381
382static struct pci_device_id gxfb_id_table[] = { 382static struct pci_device_id gxfb_id_table[] = {
383 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_VIDEO, 383 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_GX_VIDEO,
384 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16, 384 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
385 0xff0000, 0 }, 385 0xff0000, 0 },
386 { 0, } 386 { 0, }
diff --git a/drivers/w1/Makefile b/drivers/w1/Makefile
index 93845a2c7c21..6bb0b54965f2 100644
--- a/drivers/w1/Makefile
+++ b/drivers/w1/Makefile
@@ -2,10 +2,6 @@
2# Makefile for the Dallas's 1-wire bus. 2# Makefile for the Dallas's 1-wire bus.
3# 3#
4 4
5ifeq ($(CONFIG_W1_DS2433_CRC), y)
6EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC
7endif
8
9obj-$(CONFIG_W1) += wire.o 5obj-$(CONFIG_W1) += wire.o
10wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o 6wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o
11 7
diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile
index 70e21e2d70c3..725dcfdfddb4 100644
--- a/drivers/w1/slaves/Makefile
+++ b/drivers/w1/slaves/Makefile
@@ -2,10 +2,6 @@
2# Makefile for the Dallas's 1-wire slaves. 2# Makefile for the Dallas's 1-wire slaves.
3# 3#
4 4
5ifeq ($(CONFIG_W1_SLAVE_DS2433_CRC), y)
6EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC
7endif
8
9obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o 5obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o
10obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o 6obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o
11obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o 7obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o
diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index 2ac238f1480e..8ea17a53eed8 100644
--- a/drivers/w1/slaves/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -13,7 +13,7 @@
13#include <linux/device.h> 13#include <linux/device.h>
14#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#ifdef CONFIG_W1_F23_CRC 16#ifdef CONFIG_W1_SLAVE_DS2433_CRC
17#include <linux/crc16.h> 17#include <linux/crc16.h>
18 18
19#define CRC16_INIT 0 19#define CRC16_INIT 0
@@ -62,7 +62,7 @@ static inline size_t w1_f23_fix_count(loff_t off, size_t count, size_t size)
62 return count; 62 return count;
63} 63}
64 64
65#ifdef CONFIG_W1_F23_CRC 65#ifdef CONFIG_W1_SLAVE_DS2433_CRC
66static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data, 66static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data,
67 int block) 67 int block)
68{ 68{
@@ -89,13 +89,13 @@ static int w1_f23_refresh_block(struct w1_slave *sl, struct w1_f23_data *data,
89 89
90 return 0; 90 return 0;
91} 91}
92#endif /* CONFIG_W1_F23_CRC */ 92#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
93 93
94static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off, 94static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
95 size_t count) 95 size_t count)
96{ 96{
97 struct w1_slave *sl = kobj_to_w1_slave(kobj); 97 struct w1_slave *sl = kobj_to_w1_slave(kobj);
98#ifdef CONFIG_W1_F23_CRC 98#ifdef CONFIG_W1_SLAVE_DS2433_CRC
99 struct w1_f23_data *data = sl->family_data; 99 struct w1_f23_data *data = sl->family_data;
100 int i, min_page, max_page; 100 int i, min_page, max_page;
101#else 101#else
@@ -107,7 +107,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
107 107
108 mutex_lock(&sl->master->mutex); 108 mutex_lock(&sl->master->mutex);
109 109
110#ifdef CONFIG_W1_F23_CRC 110#ifdef CONFIG_W1_SLAVE_DS2433_CRC
111 111
112 min_page = (off >> W1_PAGE_BITS); 112 min_page = (off >> W1_PAGE_BITS);
113 max_page = (off + count - 1) >> W1_PAGE_BITS; 113 max_page = (off + count - 1) >> W1_PAGE_BITS;
@@ -119,7 +119,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
119 } 119 }
120 memcpy(buf, &data->memory[off], count); 120 memcpy(buf, &data->memory[off], count);
121 121
122#else /* CONFIG_W1_F23_CRC */ 122#else /* CONFIG_W1_SLAVE_DS2433_CRC */
123 123
124 /* read directly from the EEPROM */ 124 /* read directly from the EEPROM */
125 if (w1_reset_select_slave(sl)) { 125 if (w1_reset_select_slave(sl)) {
@@ -133,7 +133,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
133 w1_write_block(sl->master, wrbuf, 3); 133 w1_write_block(sl->master, wrbuf, 3);
134 w1_read_block(sl->master, buf, count); 134 w1_read_block(sl->master, buf, count);
135 135
136#endif /* CONFIG_W1_F23_CRC */ 136#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
137 137
138out_up: 138out_up:
139 mutex_unlock(&sl->master->mutex); 139 mutex_unlock(&sl->master->mutex);
@@ -208,7 +208,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
208 if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0) 208 if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0)
209 return 0; 209 return 0;
210 210
211#ifdef CONFIG_W1_F23_CRC 211#ifdef CONFIG_W1_SLAVE_DS2433_CRC
212 /* can only write full blocks in cached mode */ 212 /* can only write full blocks in cached mode */
213 if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) { 213 if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) {
214 dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n", 214 dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n",
@@ -223,7 +223,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
223 return -EINVAL; 223 return -EINVAL;
224 } 224 }
225 } 225 }
226#endif /* CONFIG_W1_F23_CRC */ 226#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
227 227
228 mutex_lock(&sl->master->mutex); 228 mutex_lock(&sl->master->mutex);
229 229
@@ -262,7 +262,7 @@ static struct bin_attribute w1_f23_bin_attr = {
262static int w1_f23_add_slave(struct w1_slave *sl) 262static int w1_f23_add_slave(struct w1_slave *sl)
263{ 263{
264 int err; 264 int err;
265#ifdef CONFIG_W1_F23_CRC 265#ifdef CONFIG_W1_SLAVE_DS2433_CRC
266 struct w1_f23_data *data; 266 struct w1_f23_data *data;
267 267
268 data = kmalloc(sizeof(struct w1_f23_data), GFP_KERNEL); 268 data = kmalloc(sizeof(struct w1_f23_data), GFP_KERNEL);
@@ -271,24 +271,24 @@ static int w1_f23_add_slave(struct w1_slave *sl)
271 memset(data, 0, sizeof(struct w1_f23_data)); 271 memset(data, 0, sizeof(struct w1_f23_data));
272 sl->family_data = data; 272 sl->family_data = data;
273 273
274#endif /* CONFIG_W1_F23_CRC */ 274#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
275 275
276 err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 276 err = sysfs_create_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
277 277
278#ifdef CONFIG_W1_F23_CRC 278#ifdef CONFIG_W1_SLAVE_DS2433_CRC
279 if (err) 279 if (err)
280 kfree(data); 280 kfree(data);
281#endif /* CONFIG_W1_F23_CRC */ 281#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
282 282
283 return err; 283 return err;
284} 284}
285 285
286static void w1_f23_remove_slave(struct w1_slave *sl) 286static void w1_f23_remove_slave(struct w1_slave *sl)
287{ 287{
288#ifdef CONFIG_W1_F23_CRC 288#ifdef CONFIG_W1_SLAVE_DS2433_CRC
289 kfree(sl->family_data); 289 kfree(sl->family_data);
290 sl->family_data = NULL; 290 sl->family_data = NULL;
291#endif /* CONFIG_W1_F23_CRC */ 291#endif /* CONFIG_W1_SLAVE_DS2433_CRC */
292 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr); 292 sysfs_remove_bin_file(&sl->dev.kobj, &w1_f23_bin_attr);
293} 293}
294 294
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index de3e9791f80d..63c07243993c 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -31,6 +31,7 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/kthread.h> 33#include <linux/kthread.h>
34#include <linux/freezer.h>
34 35
35#include <asm/atomic.h> 36#include <asm/atomic.h>
36 37
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 5241c600ce28..18f26cdfd882 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -256,7 +256,7 @@ static int
256v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, u32 perm, 256v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, u32 perm,
257 u8 mode, char *extension, u32 *fidp, struct v9fs_qid *qid, u32 *iounit) 257 u8 mode, char *extension, u32 *fidp, struct v9fs_qid *qid, u32 *iounit)
258{ 258{
259 u32 fid; 259 int fid;
260 int err; 260 int err;
261 struct v9fs_fcall *fcall; 261 struct v9fs_fcall *fcall;
262 262
@@ -310,7 +310,7 @@ static struct v9fs_fid*
310v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry) 310v9fs_clone_walk(struct v9fs_session_info *v9ses, u32 fid, struct dentry *dentry)
311{ 311{
312 int err; 312 int err;
313 u32 nfid; 313 int nfid;
314 struct v9fs_fid *ret; 314 struct v9fs_fid *ret;
315 struct v9fs_fcall *fcall; 315 struct v9fs_fcall *fcall;
316 316
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 9ade139086fc..5023351a7afe 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -36,7 +36,7 @@ void __adfs_error(struct super_block *sb, const char *function, const char *fmt,
36 va_list args; 36 va_list args;
37 37
38 va_start(args, fmt); 38 va_start(args, fmt);
39 vsprintf(error_buf, fmt, args); 39 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
40 va_end(args); 40 va_end(args);
41 41
42 printk(KERN_CRIT "ADFS-fs error (device %s)%s%s: %s\n", 42 printk(KERN_CRIT "ADFS-fs error (device %s)%s%s: %s\n",
@@ -212,12 +212,12 @@ static int adfs_statfs(struct dentry *dentry, struct kstatfs *buf)
212 return 0; 212 return 0;
213} 213}
214 214
215static kmem_cache_t *adfs_inode_cachep; 215static struct kmem_cache *adfs_inode_cachep;
216 216
217static struct inode *adfs_alloc_inode(struct super_block *sb) 217static struct inode *adfs_alloc_inode(struct super_block *sb)
218{ 218{
219 struct adfs_inode_info *ei; 219 struct adfs_inode_info *ei;
220 ei = (struct adfs_inode_info *)kmem_cache_alloc(adfs_inode_cachep, SLAB_KERNEL); 220 ei = (struct adfs_inode_info *)kmem_cache_alloc(adfs_inode_cachep, GFP_KERNEL);
221 if (!ei) 221 if (!ei)
222 return NULL; 222 return NULL;
223 return &ei->vfs_inode; 223 return &ei->vfs_inode;
@@ -228,7 +228,7 @@ static void adfs_destroy_inode(struct inode *inode)
228 kmem_cache_free(adfs_inode_cachep, ADFS_I(inode)); 228 kmem_cache_free(adfs_inode_cachep, ADFS_I(inode));
229} 229}
230 230
231static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 231static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
232{ 232{
233 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo; 233 struct adfs_inode_info *ei = (struct adfs_inode_info *) foo;
234 234
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index ccd624ef4272..f4de4b98004f 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -445,7 +445,7 @@ affs_error(struct super_block *sb, const char *function, const char *fmt, ...)
445 va_list args; 445 va_list args;
446 446
447 va_start(args,fmt); 447 va_start(args,fmt);
448 vsprintf(ErrorBuffer,fmt,args); 448 vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args);
449 va_end(args); 449 va_end(args);
450 450
451 printk(KERN_CRIT "AFFS error (device %s): %s(): %s\n", sb->s_id, 451 printk(KERN_CRIT "AFFS error (device %s): %s(): %s\n", sb->s_id,
@@ -461,7 +461,7 @@ affs_warning(struct super_block *sb, const char *function, const char *fmt, ...)
461 va_list args; 461 va_list args;
462 462
463 va_start(args,fmt); 463 va_start(args,fmt);
464 vsprintf(ErrorBuffer,fmt,args); 464 vsnprintf(ErrorBuffer,sizeof(ErrorBuffer),fmt,args);
465 va_end(args); 465 va_end(args);
466 466
467 printk(KERN_WARNING "AFFS warning (device %s): %s(): %s\n", sb->s_id, 467 printk(KERN_WARNING "AFFS warning (device %s): %s(): %s\n", sb->s_id,
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c
index b0b953683c1a..b330009fe42d 100644
--- a/fs/affs/bitmap.c
+++ b/fs/affs/bitmap.c
@@ -289,12 +289,11 @@ int affs_init_bitmap(struct super_block *sb, int *flags)
289 sbi->s_bmap_count = (sbi->s_partition_size - sbi->s_reserved + 289 sbi->s_bmap_count = (sbi->s_partition_size - sbi->s_reserved +
290 sbi->s_bmap_bits - 1) / sbi->s_bmap_bits; 290 sbi->s_bmap_bits - 1) / sbi->s_bmap_bits;
291 size = sbi->s_bmap_count * sizeof(*bm); 291 size = sbi->s_bmap_count * sizeof(*bm);
292 bm = sbi->s_bitmap = kmalloc(size, GFP_KERNEL); 292 bm = sbi->s_bitmap = kzalloc(size, GFP_KERNEL);
293 if (!sbi->s_bitmap) { 293 if (!sbi->s_bitmap) {
294 printk(KERN_ERR "AFFS: Bitmap allocation failed\n"); 294 printk(KERN_ERR "AFFS: Bitmap allocation failed\n");
295 return -ENOMEM; 295 return -ENOMEM;
296 } 296 }
297 memset(sbi->s_bitmap, 0, size);
298 297
299 bmap_blk = (__be32 *)sbi->s_root_bh->b_data; 298 bmap_blk = (__be32 *)sbi->s_root_bh->b_data;
300 blk = sb->s_blocksize / 4 - 49; 299 blk = sb->s_blocksize / 4 - 49;
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 5ea72c3a16c3..3de93e799949 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -66,12 +66,12 @@ affs_write_super(struct super_block *sb)
66 pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean); 66 pr_debug("AFFS: write_super() at %lu, clean=%d\n", get_seconds(), clean);
67} 67}
68 68
69static kmem_cache_t * affs_inode_cachep; 69static struct kmem_cache * affs_inode_cachep;
70 70
71static struct inode *affs_alloc_inode(struct super_block *sb) 71static struct inode *affs_alloc_inode(struct super_block *sb)
72{ 72{
73 struct affs_inode_info *ei; 73 struct affs_inode_info *ei;
74 ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, SLAB_KERNEL); 74 ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, GFP_KERNEL);
75 if (!ei) 75 if (!ei)
76 return NULL; 76 return NULL;
77 ei->vfs_inode.i_version = 1; 77 ei->vfs_inode.i_version = 1;
@@ -83,7 +83,7 @@ static void affs_destroy_inode(struct inode *inode)
83 kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); 83 kmem_cache_free(affs_inode_cachep, AFFS_I(inode));
84} 84}
85 85
86static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 86static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
87{ 87{
88 struct affs_inode_info *ei = (struct affs_inode_info *) foo; 88 struct affs_inode_info *ei = (struct affs_inode_info *) foo;
89 89
diff --git a/fs/afs/kafsasyncd.c b/fs/afs/kafsasyncd.c
index f09a794f248e..615df2407cb2 100644
--- a/fs/afs/kafsasyncd.c
+++ b/fs/afs/kafsasyncd.c
@@ -20,6 +20,7 @@
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/sched.h> 21#include <linux/sched.h>
22#include <linux/completion.h> 22#include <linux/completion.h>
23#include <linux/freezer.h>
23#include "cell.h" 24#include "cell.h"
24#include "server.h" 25#include "server.h"
25#include "volume.h" 26#include "volume.h"
diff --git a/fs/afs/kafstimod.c b/fs/afs/kafstimod.c
index 65bc05ab8182..694344e4d3c7 100644
--- a/fs/afs/kafstimod.c
+++ b/fs/afs/kafstimod.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/completion.h> 15#include <linux/completion.h>
16#include <linux/freezer.h>
16#include "cell.h" 17#include "cell.h"
17#include "volume.h" 18#include "volume.h"
18#include "kafstimod.h" 19#include "kafstimod.h"
diff --git a/fs/afs/server.c b/fs/afs/server.c
index 22afaae1a4ce..44aff81dc6a7 100644
--- a/fs/afs/server.c
+++ b/fs/afs/server.c
@@ -55,13 +55,12 @@ int afs_server_lookup(struct afs_cell *cell, const struct in_addr *addr,
55 _enter("%p,%08x,", cell, ntohl(addr->s_addr)); 55 _enter("%p,%08x,", cell, ntohl(addr->s_addr));
56 56
57 /* allocate and initialise a server record */ 57 /* allocate and initialise a server record */
58 server = kmalloc(sizeof(struct afs_server), GFP_KERNEL); 58 server = kzalloc(sizeof(struct afs_server), GFP_KERNEL);
59 if (!server) { 59 if (!server) {
60 _leave(" = -ENOMEM"); 60 _leave(" = -ENOMEM");
61 return -ENOMEM; 61 return -ENOMEM;
62 } 62 }
63 63
64 memset(server, 0, sizeof(struct afs_server));
65 atomic_set(&server->usage, 1); 64 atomic_set(&server->usage, 1);
66 65
67 INIT_LIST_HEAD(&server->link); 66 INIT_LIST_HEAD(&server->link);
diff --git a/fs/afs/super.c b/fs/afs/super.c
index 67d1f5c819ec..18d9b77ba40f 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -35,7 +35,7 @@ struct afs_mount_params {
35 struct afs_volume *volume; 35 struct afs_volume *volume;
36}; 36};
37 37
38static void afs_i_init_once(void *foo, kmem_cache_t *cachep, 38static void afs_i_init_once(void *foo, struct kmem_cache *cachep,
39 unsigned long flags); 39 unsigned long flags);
40 40
41static int afs_get_sb(struct file_system_type *fs_type, 41static int afs_get_sb(struct file_system_type *fs_type,
@@ -65,7 +65,7 @@ static struct super_operations afs_super_ops = {
65 .put_super = afs_put_super, 65 .put_super = afs_put_super,
66}; 66};
67 67
68static kmem_cache_t *afs_inode_cachep; 68static struct kmem_cache *afs_inode_cachep;
69static atomic_t afs_count_active_inodes; 69static atomic_t afs_count_active_inodes;
70 70
71/*****************************************************************************/ 71/*****************************************************************************/
@@ -242,14 +242,12 @@ static int afs_fill_super(struct super_block *sb, void *data, int silent)
242 kenter(""); 242 kenter("");
243 243
244 /* allocate a superblock info record */ 244 /* allocate a superblock info record */
245 as = kmalloc(sizeof(struct afs_super_info), GFP_KERNEL); 245 as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
246 if (!as) { 246 if (!as) {
247 _leave(" = -ENOMEM"); 247 _leave(" = -ENOMEM");
248 return -ENOMEM; 248 return -ENOMEM;
249 } 249 }
250 250
251 memset(as, 0, sizeof(struct afs_super_info));
252
253 afs_get_volume(params->volume); 251 afs_get_volume(params->volume);
254 as->volume = params->volume; 252 as->volume = params->volume;
255 253
@@ -384,7 +382,7 @@ static void afs_put_super(struct super_block *sb)
384/* 382/*
385 * initialise an inode cache slab element prior to any use 383 * initialise an inode cache slab element prior to any use
386 */ 384 */
387static void afs_i_init_once(void *_vnode, kmem_cache_t *cachep, 385static void afs_i_init_once(void *_vnode, struct kmem_cache *cachep,
388 unsigned long flags) 386 unsigned long flags)
389{ 387{
390 struct afs_vnode *vnode = (struct afs_vnode *) _vnode; 388 struct afs_vnode *vnode = (struct afs_vnode *) _vnode;
@@ -412,7 +410,7 @@ static struct inode *afs_alloc_inode(struct super_block *sb)
412 struct afs_vnode *vnode; 410 struct afs_vnode *vnode;
413 411
414 vnode = (struct afs_vnode *) 412 vnode = (struct afs_vnode *)
415 kmem_cache_alloc(afs_inode_cachep, SLAB_KERNEL); 413 kmem_cache_alloc(afs_inode_cachep, GFP_KERNEL);
416 if (!vnode) 414 if (!vnode)
417 return NULL; 415 return NULL;
418 416
diff --git a/fs/aio.c b/fs/aio.c
index 287a1bc7a182..d3a6ec2c9627 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -47,8 +47,8 @@ unsigned long aio_nr; /* current system wide number of aio requests */
47unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */ 47unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
48/*----end sysctl variables---*/ 48/*----end sysctl variables---*/
49 49
50static kmem_cache_t *kiocb_cachep; 50static struct kmem_cache *kiocb_cachep;
51static kmem_cache_t *kioctx_cachep; 51static struct kmem_cache *kioctx_cachep;
52 52
53static struct workqueue_struct *aio_wq; 53static struct workqueue_struct *aio_wq;
54 54
@@ -666,17 +666,6 @@ static ssize_t aio_run_iocb(struct kiocb *iocb)
666 ssize_t (*retry)(struct kiocb *); 666 ssize_t (*retry)(struct kiocb *);
667 ssize_t ret; 667 ssize_t ret;
668 668
669 if (iocb->ki_retried++ > 1024*1024) {
670 printk("Maximal retry count. Bytes done %Zd\n",
671 iocb->ki_nbytes - iocb->ki_left);
672 return -EAGAIN;
673 }
674
675 if (!(iocb->ki_retried & 0xff)) {
676 pr_debug("%ld retry: %zd of %zd\n", iocb->ki_retried,
677 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
678 }
679
680 if (!(retry = iocb->ki_retry)) { 669 if (!(retry = iocb->ki_retry)) {
681 printk("aio_run_iocb: iocb->ki_retry = NULL\n"); 670 printk("aio_run_iocb: iocb->ki_retry = NULL\n");
682 return 0; 671 return 0;
@@ -1005,9 +994,6 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2)
1005 kunmap_atomic(ring, KM_IRQ1); 994 kunmap_atomic(ring, KM_IRQ1);
1006 995
1007 pr_debug("added to ring %p at [%lu]\n", iocb, tail); 996 pr_debug("added to ring %p at [%lu]\n", iocb, tail);
1008
1009 pr_debug("%ld retries: %zd of %zd\n", iocb->ki_retried,
1010 iocb->ki_nbytes - iocb->ki_left, iocb->ki_nbytes);
1011put_rq: 997put_rq:
1012 /* everything turned out well, dispose of the aiocb. */ 998 /* everything turned out well, dispose of the aiocb. */
1013 ret = __aio_put_req(ctx, iocb); 999 ret = __aio_put_req(ctx, iocb);
@@ -1413,7 +1399,6 @@ static ssize_t aio_setup_single_vector(struct kiocb *kiocb)
1413 kiocb->ki_iovec->iov_len = kiocb->ki_left; 1399 kiocb->ki_iovec->iov_len = kiocb->ki_left;
1414 kiocb->ki_nr_segs = 1; 1400 kiocb->ki_nr_segs = 1;
1415 kiocb->ki_cur_seg = 0; 1401 kiocb->ki_cur_seg = 0;
1416 kiocb->ki_nbytes = kiocb->ki_left;
1417 return 0; 1402 return 0;
1418} 1403}
1419 1404
@@ -1591,7 +1576,6 @@ int fastcall io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1591 req->ki_opcode = iocb->aio_lio_opcode; 1576 req->ki_opcode = iocb->aio_lio_opcode;
1592 init_waitqueue_func_entry(&req->ki_wait, aio_wake_function); 1577 init_waitqueue_func_entry(&req->ki_wait, aio_wake_function);
1593 INIT_LIST_HEAD(&req->ki_wait.task_list); 1578 INIT_LIST_HEAD(&req->ki_wait.task_list);
1594 req->ki_retried = 0;
1595 1579
1596 ret = aio_setup_iocb(req); 1580 ret = aio_setup_iocb(req);
1597 1581
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index 38ede5c9d6fd..f968d1342808 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -28,10 +28,11 @@ void autofs_kill_sb(struct super_block *sb)
28 /* 28 /*
29 * In the event of a failure in get_sb_nodev the superblock 29 * In the event of a failure in get_sb_nodev the superblock
30 * info is not present so nothing else has been setup, so 30 * info is not present so nothing else has been setup, so
31 * just exit when we are called from deactivate_super. 31 * just call kill_anon_super when we are called from
32 * deactivate_super.
32 */ 33 */
33 if (!sbi) 34 if (!sbi)
34 return; 35 goto out_kill_sb;
35 36
36 if ( !sbi->catatonic ) 37 if ( !sbi->catatonic )
37 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */ 38 autofs_catatonic_mode(sbi); /* Free wait queues, close pipe */
@@ -44,6 +45,7 @@ void autofs_kill_sb(struct super_block *sb)
44 45
45 kfree(sb->s_fs_info); 46 kfree(sb->s_fs_info);
46 47
48out_kill_sb:
47 DPRINTK(("autofs: shutting down\n")); 49 DPRINTK(("autofs: shutting down\n"));
48 kill_anon_super(sb); 50 kill_anon_super(sb);
49} 51}
@@ -209,7 +211,6 @@ fail_iput:
209fail_free: 211fail_free:
210 kfree(sbi); 212 kfree(sbi);
211 s->s_fs_info = NULL; 213 s->s_fs_info = NULL;
212 kill_anon_super(s);
213fail_unlock: 214fail_unlock:
214 return -EINVAL; 215 return -EINVAL;
215} 216}
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index ce7c0f1dd529..9c48250fd726 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -152,10 +152,11 @@ void autofs4_kill_sb(struct super_block *sb)
152 /* 152 /*
153 * In the event of a failure in get_sb_nodev the superblock 153 * In the event of a failure in get_sb_nodev the superblock
154 * info is not present so nothing else has been setup, so 154 * info is not present so nothing else has been setup, so
155 * just exit when we are called from deactivate_super. 155 * just call kill_anon_super when we are called from
156 * deactivate_super.
156 */ 157 */
157 if (!sbi) 158 if (!sbi)
158 return; 159 goto out_kill_sb;
159 160
160 sb->s_fs_info = NULL; 161 sb->s_fs_info = NULL;
161 162
@@ -167,6 +168,7 @@ void autofs4_kill_sb(struct super_block *sb)
167 168
168 kfree(sbi); 169 kfree(sbi);
169 170
171out_kill_sb:
170 DPRINTK("shutting down"); 172 DPRINTK("shutting down");
171 kill_anon_super(sb); 173 kill_anon_super(sb);
172} 174}
@@ -426,7 +428,6 @@ fail_ino:
426fail_free: 428fail_free:
427 kfree(sbi); 429 kfree(sbi);
428 s->s_fs_info = NULL; 430 s->s_fs_info = NULL;
429 kill_anon_super(s);
430fail_unlock: 431fail_unlock:
431 return -EINVAL; 432 return -EINVAL;
432} 433}
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 07f7144f0e2e..bce402eee554 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -61,7 +61,7 @@ static const struct super_operations befs_sops = {
61}; 61};
62 62
63/* slab cache for befs_inode_info objects */ 63/* slab cache for befs_inode_info objects */
64static kmem_cache_t *befs_inode_cachep; 64static struct kmem_cache *befs_inode_cachep;
65 65
66static const struct file_operations befs_dir_operations = { 66static const struct file_operations befs_dir_operations = {
67 .read = generic_read_dir, 67 .read = generic_read_dir,
@@ -277,7 +277,7 @@ befs_alloc_inode(struct super_block *sb)
277{ 277{
278 struct befs_inode_info *bi; 278 struct befs_inode_info *bi;
279 bi = (struct befs_inode_info *)kmem_cache_alloc(befs_inode_cachep, 279 bi = (struct befs_inode_info *)kmem_cache_alloc(befs_inode_cachep,
280 SLAB_KERNEL); 280 GFP_KERNEL);
281 if (!bi) 281 if (!bi)
282 return NULL; 282 return NULL;
283 return &bi->vfs_inode; 283 return &bi->vfs_inode;
@@ -289,7 +289,7 @@ befs_destroy_inode(struct inode *inode)
289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); 289 kmem_cache_free(befs_inode_cachep, BEFS_I(inode));
290} 290}
291 291
292static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 292static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
293{ 293{
294 struct befs_inode_info *bi = (struct befs_inode_info *) foo; 294 struct befs_inode_info *bi = (struct befs_inode_info *) foo;
295 295
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index ed27ffb3459e..eac175ed9f44 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -228,12 +228,12 @@ static void bfs_write_super(struct super_block *s)
228 unlock_kernel(); 228 unlock_kernel();
229} 229}
230 230
231static kmem_cache_t * bfs_inode_cachep; 231static struct kmem_cache * bfs_inode_cachep;
232 232
233static struct inode *bfs_alloc_inode(struct super_block *sb) 233static struct inode *bfs_alloc_inode(struct super_block *sb)
234{ 234{
235 struct bfs_inode_info *bi; 235 struct bfs_inode_info *bi;
236 bi = kmem_cache_alloc(bfs_inode_cachep, SLAB_KERNEL); 236 bi = kmem_cache_alloc(bfs_inode_cachep, GFP_KERNEL);
237 if (!bi) 237 if (!bi)
238 return NULL; 238 return NULL;
239 return &bi->vfs_inode; 239 return &bi->vfs_inode;
@@ -244,7 +244,7 @@ static void bfs_destroy_inode(struct inode *inode)
244 kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); 244 kmem_cache_free(bfs_inode_cachep, BFS_I(inode));
245} 245}
246 246
247static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 247static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
248{ 248{
249 struct bfs_inode_info *bi = foo; 249 struct bfs_inode_info *bi = foo;
250 250
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index cc72bb43061d..be5869d34999 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -47,10 +47,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs);
47static int load_elf_library(struct file *); 47static int load_elf_library(struct file *);
48static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int); 48static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int);
49 49
50#ifndef elf_addr_t
51#define elf_addr_t unsigned long
52#endif
53
54/* 50/*
55 * If we don't support core dumping, then supply a NULL so we 51 * If we don't support core dumping, then supply a NULL so we
56 * don't even try. 52 * don't even try.
@@ -243,8 +239,9 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
243 if (interp_aout) { 239 if (interp_aout) {
244 argv = sp + 2; 240 argv = sp + 2;
245 envp = argv + argc + 1; 241 envp = argv + argc + 1;
246 __put_user((elf_addr_t)(unsigned long)argv, sp++); 242 if (__put_user((elf_addr_t)(unsigned long)argv, sp++) ||
247 __put_user((elf_addr_t)(unsigned long)envp, sp++); 243 __put_user((elf_addr_t)(unsigned long)envp, sp++))
244 return -EFAULT;
248 } else { 245 } else {
249 argv = sp; 246 argv = sp;
250 envp = argv + argc + 1; 247 envp = argv + argc + 1;
@@ -254,7 +251,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
254 p = current->mm->arg_end = current->mm->arg_start; 251 p = current->mm->arg_end = current->mm->arg_start;
255 while (argc-- > 0) { 252 while (argc-- > 0) {
256 size_t len; 253 size_t len;
257 __put_user((elf_addr_t)p, argv++); 254 if (__put_user((elf_addr_t)p, argv++))
255 return -EFAULT;
258 len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES); 256 len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES);
259 if (!len || len > PAGE_SIZE*MAX_ARG_PAGES) 257 if (!len || len > PAGE_SIZE*MAX_ARG_PAGES)
260 return 0; 258 return 0;
@@ -265,7 +263,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
265 current->mm->arg_end = current->mm->env_start = p; 263 current->mm->arg_end = current->mm->env_start = p;
266 while (envc-- > 0) { 264 while (envc-- > 0) {
267 size_t len; 265 size_t len;
268 __put_user((elf_addr_t)p, envp++); 266 if (__put_user((elf_addr_t)p, envp++))
267 return -EFAULT;
269 len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES); 268 len = strnlen_user((void __user *)p, PAGE_SIZE*MAX_ARG_PAGES);
270 if (!len || len > PAGE_SIZE*MAX_ARG_PAGES) 269 if (!len || len > PAGE_SIZE*MAX_ARG_PAGES)
271 return 0; 270 return 0;
@@ -545,7 +544,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
545 unsigned long reloc_func_desc = 0; 544 unsigned long reloc_func_desc = 0;
546 char passed_fileno[6]; 545 char passed_fileno[6];
547 struct files_struct *files; 546 struct files_struct *files;
548 int have_pt_gnu_stack, executable_stack = EXSTACK_DEFAULT; 547 int executable_stack = EXSTACK_DEFAULT;
549 unsigned long def_flags = 0; 548 unsigned long def_flags = 0;
550 struct { 549 struct {
551 struct elfhdr elf_ex; 550 struct elfhdr elf_ex;
@@ -708,7 +707,6 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
708 executable_stack = EXSTACK_DISABLE_X; 707 executable_stack = EXSTACK_DISABLE_X;
709 break; 708 break;
710 } 709 }
711 have_pt_gnu_stack = (i < loc->elf_ex.e_phnum);
712 710
713 /* Some simple consistency checks for the interpreter */ 711 /* Some simple consistency checks for the interpreter */
714 if (elf_interpreter) { 712 if (elf_interpreter) {
@@ -856,7 +854,13 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
856 * default mmap base, as well as whatever program they 854 * default mmap base, as well as whatever program they
857 * might try to exec. This is because the brk will 855 * might try to exec. This is because the brk will
858 * follow the loader, and is not movable. */ 856 * follow the loader, and is not movable. */
859 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr); 857 if (current->flags & PF_RANDOMIZE)
858 load_bias = randomize_range(0x10000,
859 ELF_ET_DYN_BASE,
860 0);
861 else
862 load_bias = ELF_ET_DYN_BASE;
863 load_bias = ELF_PAGESTART(load_bias - vaddr);
860 } 864 }
861 865
862 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, 866 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index f86d5c9ce5eb..ed9a61c6beb3 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -40,9 +40,6 @@
40#include <asm/pgalloc.h> 40#include <asm/pgalloc.h>
41 41
42typedef char *elf_caddr_t; 42typedef char *elf_caddr_t;
43#ifndef elf_addr_t
44#define elf_addr_t unsigned long
45#endif
46 43
47#if 0 44#if 0
48#define kdebug(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ ) 45#define kdebug(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ )
diff --git a/fs/bio.c b/fs/bio.c
index 50c40ce2cead..7ec737eda72b 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -30,7 +30,7 @@
30 30
31#define BIO_POOL_SIZE 256 31#define BIO_POOL_SIZE 256
32 32
33static kmem_cache_t *bio_slab __read_mostly; 33static struct kmem_cache *bio_slab __read_mostly;
34 34
35#define BIOVEC_NR_POOLS 6 35#define BIOVEC_NR_POOLS 6
36 36
@@ -44,7 +44,7 @@ mempool_t *bio_split_pool __read_mostly;
44struct biovec_slab { 44struct biovec_slab {
45 int nr_vecs; 45 int nr_vecs;
46 char *name; 46 char *name;
47 kmem_cache_t *slab; 47 struct kmem_cache *slab;
48}; 48};
49 49
50/* 50/*
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 36c0e7af9d0f..13816b4d76f6 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -235,11 +235,11 @@ static int block_fsync(struct file *filp, struct dentry *dentry, int datasync)
235 */ 235 */
236 236
237static __cacheline_aligned_in_smp DEFINE_SPINLOCK(bdev_lock); 237static __cacheline_aligned_in_smp DEFINE_SPINLOCK(bdev_lock);
238static kmem_cache_t * bdev_cachep __read_mostly; 238static struct kmem_cache * bdev_cachep __read_mostly;
239 239
240static struct inode *bdev_alloc_inode(struct super_block *sb) 240static struct inode *bdev_alloc_inode(struct super_block *sb)
241{ 241{
242 struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, SLAB_KERNEL); 242 struct bdev_inode *ei = kmem_cache_alloc(bdev_cachep, GFP_KERNEL);
243 if (!ei) 243 if (!ei)
244 return NULL; 244 return NULL;
245 return &ei->vfs_inode; 245 return &ei->vfs_inode;
@@ -253,7 +253,7 @@ static void bdev_destroy_inode(struct inode *inode)
253 kmem_cache_free(bdev_cachep, bdi); 253 kmem_cache_free(bdev_cachep, bdi);
254} 254}
255 255
256static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 256static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
257{ 257{
258 struct bdev_inode *ei = (struct bdev_inode *) foo; 258 struct bdev_inode *ei = (struct bdev_inode *) foo;
259 struct block_device *bdev = &ei->bdev; 259 struct block_device *bdev = &ei->bdev;
diff --git a/fs/buffer.c b/fs/buffer.c
index 35527dca1dbc..517860f2d75b 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2908,7 +2908,7 @@ asmlinkage long sys_bdflush(int func, long data)
2908/* 2908/*
2909 * Buffer-head allocation 2909 * Buffer-head allocation
2910 */ 2910 */
2911static kmem_cache_t *bh_cachep; 2911static struct kmem_cache *bh_cachep;
2912 2912
2913/* 2913/*
2914 * Once the number of bh's in the machine exceeds this level, we start 2914 * Once the number of bh's in the machine exceeds this level, we start
@@ -2961,7 +2961,7 @@ void free_buffer_head(struct buffer_head *bh)
2961EXPORT_SYMBOL(free_buffer_head); 2961EXPORT_SYMBOL(free_buffer_head);
2962 2962
2963static void 2963static void
2964init_buffer_head(void *data, kmem_cache_t *cachep, unsigned long flags) 2964init_buffer_head(void *data, struct kmem_cache *cachep, unsigned long flags)
2965{ 2965{
2966 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 2966 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
2967 SLAB_CTOR_CONSTRUCTOR) { 2967 SLAB_CTOR_CONSTRUCTOR) {
@@ -2972,7 +2972,6 @@ init_buffer_head(void *data, kmem_cache_t *cachep, unsigned long flags)
2972 } 2972 }
2973} 2973}
2974 2974
2975#ifdef CONFIG_HOTPLUG_CPU
2976static void buffer_exit_cpu(int cpu) 2975static void buffer_exit_cpu(int cpu)
2977{ 2976{
2978 int i; 2977 int i;
@@ -2994,7 +2993,6 @@ static int buffer_cpu_notify(struct notifier_block *self,
2994 buffer_exit_cpu((unsigned long)hcpu); 2993 buffer_exit_cpu((unsigned long)hcpu);
2995 return NOTIFY_OK; 2994 return NOTIFY_OK;
2996} 2995}
2997#endif /* CONFIG_HOTPLUG_CPU */
2998 2996
2999void __init buffer_init(void) 2997void __init buffer_init(void)
3000{ 2998{
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 84976cdbe713..71bc87a37fc1 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -34,6 +34,7 @@
34#include <linux/mempool.h> 34#include <linux/mempool.h>
35#include <linux/delay.h> 35#include <linux/delay.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/freezer.h>
37#include "cifsfs.h" 38#include "cifsfs.h"
38#include "cifspdu.h" 39#include "cifspdu.h"
39#define DECLARE_GLOBALS_HERE 40#define DECLARE_GLOBALS_HERE
@@ -81,7 +82,7 @@ extern mempool_t *cifs_sm_req_poolp;
81extern mempool_t *cifs_req_poolp; 82extern mempool_t *cifs_req_poolp;
82extern mempool_t *cifs_mid_poolp; 83extern mempool_t *cifs_mid_poolp;
83 84
84extern kmem_cache_t *cifs_oplock_cachep; 85extern struct kmem_cache *cifs_oplock_cachep;
85 86
86static int 87static int
87cifs_read_super(struct super_block *sb, void *data, 88cifs_read_super(struct super_block *sb, void *data,
@@ -232,11 +233,11 @@ static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
232 return generic_permission(inode, mask, NULL); 233 return generic_permission(inode, mask, NULL);
233} 234}
234 235
235static kmem_cache_t *cifs_inode_cachep; 236static struct kmem_cache *cifs_inode_cachep;
236static kmem_cache_t *cifs_req_cachep; 237static struct kmem_cache *cifs_req_cachep;
237static kmem_cache_t *cifs_mid_cachep; 238static struct kmem_cache *cifs_mid_cachep;
238kmem_cache_t *cifs_oplock_cachep; 239struct kmem_cache *cifs_oplock_cachep;
239static kmem_cache_t *cifs_sm_req_cachep; 240static struct kmem_cache *cifs_sm_req_cachep;
240mempool_t *cifs_sm_req_poolp; 241mempool_t *cifs_sm_req_poolp;
241mempool_t *cifs_req_poolp; 242mempool_t *cifs_req_poolp;
242mempool_t *cifs_mid_poolp; 243mempool_t *cifs_mid_poolp;
@@ -245,7 +246,7 @@ static struct inode *
245cifs_alloc_inode(struct super_block *sb) 246cifs_alloc_inode(struct super_block *sb)
246{ 247{
247 struct cifsInodeInfo *cifs_inode; 248 struct cifsInodeInfo *cifs_inode;
248 cifs_inode = kmem_cache_alloc(cifs_inode_cachep, SLAB_KERNEL); 249 cifs_inode = kmem_cache_alloc(cifs_inode_cachep, GFP_KERNEL);
249 if (!cifs_inode) 250 if (!cifs_inode)
250 return NULL; 251 return NULL;
251 cifs_inode->cifsAttrs = 0x20; /* default */ 252 cifs_inode->cifsAttrs = 0x20; /* default */
@@ -668,7 +669,7 @@ const struct file_operations cifs_dir_ops = {
668}; 669};
669 670
670static void 671static void
671cifs_init_once(void *inode, kmem_cache_t * cachep, unsigned long flags) 672cifs_init_once(void *inode, struct kmem_cache * cachep, unsigned long flags)
672{ 673{
673 struct cifsInodeInfo *cifsi = inode; 674 struct cifsInodeInfo *cifsi = inode;
674 675
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 71f77914ce93..2caca06b4bae 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -31,6 +31,7 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/completion.h> 32#include <linux/completion.h>
33#include <linux/pagevec.h> 33#include <linux/pagevec.h>
34#include <linux/freezer.h>
34#include <asm/uaccess.h> 35#include <asm/uaccess.h>
35#include <asm/processor.h> 36#include <asm/processor.h>
36#include "cifspdu.h" 37#include "cifspdu.h"
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index bbc9cd34b6ea..aedf683f011f 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -153,7 +153,7 @@ cifs_buf_get(void)
153 albeit slightly larger than necessary and maxbuffersize 153 albeit slightly larger than necessary and maxbuffersize
154 defaults to this and can not be bigger */ 154 defaults to this and can not be bigger */
155 ret_buf = 155 ret_buf =
156 (struct smb_hdr *) mempool_alloc(cifs_req_poolp, SLAB_KERNEL | SLAB_NOFS); 156 (struct smb_hdr *) mempool_alloc(cifs_req_poolp, GFP_KERNEL | GFP_NOFS);
157 157
158 /* clear the first few header bytes */ 158 /* clear the first few header bytes */
159 /* for most paths, more is cleared in header_assemble */ 159 /* for most paths, more is cleared in header_assemble */
@@ -192,7 +192,7 @@ cifs_small_buf_get(void)
192 albeit slightly larger than necessary and maxbuffersize 192 albeit slightly larger than necessary and maxbuffersize
193 defaults to this and can not be bigger */ 193 defaults to this and can not be bigger */
194 ret_buf = 194 ret_buf =
195 (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, SLAB_KERNEL | SLAB_NOFS); 195 (struct smb_hdr *) mempool_alloc(cifs_sm_req_poolp, GFP_KERNEL | GFP_NOFS);
196 if (ret_buf) { 196 if (ret_buf) {
197 /* No need to clear memory here, cleared in header assemble */ 197 /* No need to clear memory here, cleared in header assemble */
198 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/ 198 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 48d47b46b1fb..f80007eaebf4 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -34,7 +34,7 @@
34#include "cifs_debug.h" 34#include "cifs_debug.h"
35 35
36extern mempool_t *cifs_mid_poolp; 36extern mempool_t *cifs_mid_poolp;
37extern kmem_cache_t *cifs_oplock_cachep; 37extern struct kmem_cache *cifs_oplock_cachep;
38 38
39static struct mid_q_entry * 39static struct mid_q_entry *
40AllocMidQEntry(const struct smb_hdr *smb_buffer, struct cifsSesInfo *ses) 40AllocMidQEntry(const struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
@@ -51,7 +51,7 @@ AllocMidQEntry(const struct smb_hdr *smb_buffer, struct cifsSesInfo *ses)
51 } 51 }
52 52
53 temp = (struct mid_q_entry *) mempool_alloc(cifs_mid_poolp, 53 temp = (struct mid_q_entry *) mempool_alloc(cifs_mid_poolp,
54 SLAB_KERNEL | SLAB_NOFS); 54 GFP_KERNEL | GFP_NOFS);
55 if (temp == NULL) 55 if (temp == NULL)
56 return temp; 56 return temp;
57 else { 57 else {
@@ -118,7 +118,7 @@ AllocOplockQEntry(struct inode * pinode, __u16 fid, struct cifsTconInfo * tcon)
118 return NULL; 118 return NULL;
119 } 119 }
120 temp = (struct oplock_q_entry *) kmem_cache_alloc(cifs_oplock_cachep, 120 temp = (struct oplock_q_entry *) kmem_cache_alloc(cifs_oplock_cachep,
121 SLAB_KERNEL); 121 GFP_KERNEL);
122 if (temp == NULL) 122 if (temp == NULL)
123 return temp; 123 return temp;
124 else { 124 else {
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 88d123321164..b64659fa82d0 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -38,12 +38,12 @@ static void coda_clear_inode(struct inode *);
38static void coda_put_super(struct super_block *); 38static void coda_put_super(struct super_block *);
39static int coda_statfs(struct dentry *dentry, struct kstatfs *buf); 39static int coda_statfs(struct dentry *dentry, struct kstatfs *buf);
40 40
41static kmem_cache_t * coda_inode_cachep; 41static struct kmem_cache * coda_inode_cachep;
42 42
43static struct inode *coda_alloc_inode(struct super_block *sb) 43static struct inode *coda_alloc_inode(struct super_block *sb)
44{ 44{
45 struct coda_inode_info *ei; 45 struct coda_inode_info *ei;
46 ei = (struct coda_inode_info *)kmem_cache_alloc(coda_inode_cachep, SLAB_KERNEL); 46 ei = (struct coda_inode_info *)kmem_cache_alloc(coda_inode_cachep, GFP_KERNEL);
47 if (!ei) 47 if (!ei)
48 return NULL; 48 return NULL;
49 memset(&ei->c_fid, 0, sizeof(struct CodaFid)); 49 memset(&ei->c_fid, 0, sizeof(struct CodaFid));
@@ -58,7 +58,7 @@ static void coda_destroy_inode(struct inode *inode)
58 kmem_cache_free(coda_inode_cachep, ITOC(inode)); 58 kmem_cache_free(coda_inode_cachep, ITOC(inode));
59} 59}
60 60
61static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 61static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
62{ 62{
63 struct coda_inode_info *ei = (struct coda_inode_info *) foo; 63 struct coda_inode_info *ei = (struct coda_inode_info *) foo;
64 64
diff --git a/fs/compat.c b/fs/compat.c
index 06dad665b88f..a7e3f162fb15 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -871,7 +871,7 @@ asmlinkage long compat_sys_mount(char __user * dev_name, char __user * dir_name,
871 871
872 retval = -EINVAL; 872 retval = -EINVAL;
873 873
874 if (type_page) { 874 if (type_page && data_page) {
875 if (!strcmp((char *)type_page, SMBFS_NAME)) { 875 if (!strcmp((char *)type_page, SMBFS_NAME)) {
876 do_smb_super_data_conv((void *)data_page); 876 do_smb_super_data_conv((void *)data_page);
877 } else if (!strcmp((char *)type_page, NCPFS_NAME)) { 877 } else if (!strcmp((char *)type_page, NCPFS_NAME)) {
@@ -1144,7 +1144,9 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
1144 lastdirent = buf.previous; 1144 lastdirent = buf.previous;
1145 if (lastdirent) { 1145 if (lastdirent) {
1146 typeof(lastdirent->d_off) d_off = file->f_pos; 1146 typeof(lastdirent->d_off) d_off = file->f_pos;
1147 __put_user_unaligned(d_off, &lastdirent->d_off); 1147 error = -EFAULT;
1148 if (__put_user_unaligned(d_off, &lastdirent->d_off))
1149 goto out_putf;
1148 error = count - buf.count; 1150 error = count - buf.count;
1149 } 1151 }
1150 1152
@@ -1611,14 +1613,14 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1611 nr &= ~1UL; 1613 nr &= ~1UL;
1612 while (nr) { 1614 while (nr) {
1613 unsigned long h, l; 1615 unsigned long h, l;
1614 __get_user(l, ufdset); 1616 if (__get_user(l, ufdset) || __get_user(h, ufdset+1))
1615 __get_user(h, ufdset+1); 1617 return -EFAULT;
1616 ufdset += 2; 1618 ufdset += 2;
1617 *fdset++ = h << 32 | l; 1619 *fdset++ = h << 32 | l;
1618 nr -= 2; 1620 nr -= 2;
1619 } 1621 }
1620 if (odd) 1622 if (odd && __get_user(*fdset, ufdset))
1621 __get_user(*fdset, ufdset); 1623 return -EFAULT;
1622 } else { 1624 } else {
1623 /* Tricky, must clear full unsigned long in the 1625 /* Tricky, must clear full unsigned long in the
1624 * kernel fdset at the end, this makes sure that 1626 * kernel fdset at the end, this makes sure that
@@ -1630,14 +1632,14 @@ int compat_get_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1630} 1632}
1631 1633
1632static 1634static
1633void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset, 1635int compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1634 unsigned long *fdset) 1636 unsigned long *fdset)
1635{ 1637{
1636 unsigned long odd; 1638 unsigned long odd;
1637 nr = ROUND_UP(nr, __COMPAT_NFDBITS); 1639 nr = ROUND_UP(nr, __COMPAT_NFDBITS);
1638 1640
1639 if (!ufdset) 1641 if (!ufdset)
1640 return; 1642 return 0;
1641 1643
1642 odd = nr & 1UL; 1644 odd = nr & 1UL;
1643 nr &= ~1UL; 1645 nr &= ~1UL;
@@ -1645,13 +1647,14 @@ void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
1645 unsigned long h, l; 1647 unsigned long h, l;
1646 l = *fdset++; 1648 l = *fdset++;
1647 h = l >> 32; 1649 h = l >> 32;
1648 __put_user(l, ufdset); 1650 if (__put_user(l, ufdset) || __put_user(h, ufdset+1))
1649 __put_user(h, ufdset+1); 1651 return -EFAULT;
1650 ufdset += 2; 1652 ufdset += 2;
1651 nr -= 2; 1653 nr -= 2;
1652 } 1654 }
1653 if (odd) 1655 if (odd && __put_user(*fdset, ufdset))
1654 __put_user(*fdset, ufdset); 1656 return -EFAULT;
1657 return 0;
1655} 1658}
1656 1659
1657 1660
@@ -1726,10 +1729,10 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
1726 ret = 0; 1729 ret = 0;
1727 } 1730 }
1728 1731
1729 compat_set_fd_set(n, inp, fds.res_in); 1732 if (compat_set_fd_set(n, inp, fds.res_in) ||
1730 compat_set_fd_set(n, outp, fds.res_out); 1733 compat_set_fd_set(n, outp, fds.res_out) ||
1731 compat_set_fd_set(n, exp, fds.res_ex); 1734 compat_set_fd_set(n, exp, fds.res_ex))
1732 1735 ret = -EFAULT;
1733out: 1736out:
1734 kfree(bits); 1737 kfree(bits);
1735out_nofds: 1738out_nofds:
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index a91f2628c981..bcc3caf5d820 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -211,8 +211,10 @@ static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned lon
211 up_native = 211 up_native =
212 compat_alloc_user_space(sizeof(struct video_still_picture)); 212 compat_alloc_user_space(sizeof(struct video_still_picture));
213 213
214 put_user(compat_ptr(fp), &up_native->iFrame); 214 err = put_user(compat_ptr(fp), &up_native->iFrame);
215 put_user(size, &up_native->size); 215 err |= put_user(size, &up_native->size);
216 if (err)
217 return -EFAULT;
216 218
217 err = sys_ioctl(fd, cmd, (unsigned long) up_native); 219 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
218 220
@@ -236,8 +238,10 @@ static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned
236 err |= get_user(length, &up->length); 238 err |= get_user(length, &up->length);
237 239
238 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette)); 240 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
239 put_user(compat_ptr(palp), &up_native->palette); 241 err = put_user(compat_ptr(palp), &up_native->palette);
240 put_user(length, &up_native->length); 242 err |= put_user(length, &up_native->length);
243 if (err)
244 return -EFAULT;
241 245
242 err = sys_ioctl(fd, cmd, (unsigned long) up_native); 246 err = sys_ioctl(fd, cmd, (unsigned long) up_native);
243 247
@@ -2043,16 +2047,19 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2043 struct serial_struct ss; 2047 struct serial_struct ss;
2044 mm_segment_t oldseg = get_fs(); 2048 mm_segment_t oldseg = get_fs();
2045 __u32 udata; 2049 __u32 udata;
2050 unsigned int base;
2046 2051
2047 if (cmd == TIOCSSERIAL) { 2052 if (cmd == TIOCSSERIAL) {
2048 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32))) 2053 if (!access_ok(VERIFY_READ, ss32, sizeof(SS32)))
2049 return -EFAULT; 2054 return -EFAULT;
2050 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base))) 2055 if (__copy_from_user(&ss, ss32, offsetof(SS32, iomem_base)))
2051 return -EFAULT; 2056 return -EFAULT;
2052 __get_user(udata, &ss32->iomem_base); 2057 if (__get_user(udata, &ss32->iomem_base))
2058 return -EFAULT;
2053 ss.iomem_base = compat_ptr(udata); 2059 ss.iomem_base = compat_ptr(udata);
2054 __get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift); 2060 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
2055 __get_user(ss.port_high, &ss32->port_high); 2061 __get_user(ss.port_high, &ss32->port_high))
2062 return -EFAULT;
2056 ss.iomap_base = 0UL; 2063 ss.iomap_base = 0UL;
2057 } 2064 }
2058 set_fs(KERNEL_DS); 2065 set_fs(KERNEL_DS);
@@ -2063,12 +2070,12 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
2063 return -EFAULT; 2070 return -EFAULT;
2064 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base))) 2071 if (__copy_to_user(ss32,&ss,offsetof(SS32,iomem_base)))
2065 return -EFAULT; 2072 return -EFAULT;
2066 __put_user((unsigned long)ss.iomem_base >> 32 ? 2073 base = (unsigned long)ss.iomem_base >> 32 ?
2067 0xffffffff : (unsigned)(unsigned long)ss.iomem_base, 2074 0xffffffff : (unsigned)(unsigned long)ss.iomem_base;
2068 &ss32->iomem_base); 2075 if (__put_user(base, &ss32->iomem_base) ||
2069 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift); 2076 __put_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
2070 __put_user(ss.port_high, &ss32->port_high); 2077 __put_user(ss.port_high, &ss32->port_high))
2071 2078 return -EFAULT;
2072 } 2079 }
2073 return err; 2080 return err;
2074} 2081}
@@ -2397,6 +2404,7 @@ HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc)
2397HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc) 2404HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc)
2398HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc) 2405HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc)
2399HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc) 2406HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc)
2407HANDLE_IOCTL(SIOCSIFHWBROADCAST, dev_ifsioc)
2400 2408
2401/* ioctls used by appletalk ddp.c */ 2409/* ioctls used by appletalk ddp.c */
2402HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc) 2410HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc)
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
index 3f4ff7a242b9..f92cd303d2c9 100644
--- a/fs/configfs/configfs_internal.h
+++ b/fs/configfs/configfs_internal.h
@@ -49,7 +49,7 @@ struct configfs_dirent {
49#define CONFIGFS_NOT_PINNED (CONFIGFS_ITEM_ATTR) 49#define CONFIGFS_NOT_PINNED (CONFIGFS_ITEM_ATTR)
50 50
51extern struct vfsmount * configfs_mount; 51extern struct vfsmount * configfs_mount;
52extern kmem_cache_t *configfs_dir_cachep; 52extern struct kmem_cache *configfs_dir_cachep;
53 53
54extern int configfs_is_root(struct config_item *item); 54extern int configfs_is_root(struct config_item *item);
55 55
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 68bd5c93ca52..ed678529ebb2 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -38,7 +38,7 @@
38 38
39struct vfsmount * configfs_mount = NULL; 39struct vfsmount * configfs_mount = NULL;
40struct super_block * configfs_sb = NULL; 40struct super_block * configfs_sb = NULL;
41kmem_cache_t *configfs_dir_cachep; 41struct kmem_cache *configfs_dir_cachep;
42static int configfs_mnt_count = 0; 42static int configfs_mnt_count = 0;
43 43
44static struct super_operations configfs_ops = { 44static struct super_operations configfs_ops = {
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index a624c3ec8189..0509cedd415c 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -481,6 +481,8 @@ static int cramfs_readpage(struct file *file, struct page * page)
481 pgdata = kmap(page); 481 pgdata = kmap(page);
482 if (compr_len == 0) 482 if (compr_len == 0)
483 ; /* hole */ 483 ; /* hole */
484 else if (compr_len > (PAGE_CACHE_SIZE << 1))
485 printk(KERN_ERR "cramfs: bad compressed blocksize %u\n", compr_len);
484 else { 486 else {
485 mutex_lock(&read_mutex); 487 mutex_lock(&read_mutex);
486 bytes_filled = cramfs_uncompress_block(pgdata, 488 bytes_filled = cramfs_uncompress_block(pgdata,
diff --git a/fs/dcache.c b/fs/dcache.c
index fd4a428998ef..d68631f18df1 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -43,7 +43,7 @@ static __cacheline_aligned_in_smp DEFINE_SEQLOCK(rename_lock);
43 43
44EXPORT_SYMBOL(dcache_lock); 44EXPORT_SYMBOL(dcache_lock);
45 45
46static kmem_cache_t *dentry_cache __read_mostly; 46static struct kmem_cache *dentry_cache __read_mostly;
47 47
48#define DNAME_INLINE_LEN (sizeof(struct dentry)-offsetof(struct dentry,d_iname)) 48#define DNAME_INLINE_LEN (sizeof(struct dentry)-offsetof(struct dentry,d_iname))
49 49
@@ -68,15 +68,19 @@ struct dentry_stat_t dentry_stat = {
68 .age_limit = 45, 68 .age_limit = 45,
69}; 69};
70 70
71static void d_callback(struct rcu_head *head) 71static void __d_free(struct dentry *dentry)
72{ 72{
73 struct dentry * dentry = container_of(head, struct dentry, d_u.d_rcu);
74
75 if (dname_external(dentry)) 73 if (dname_external(dentry))
76 kfree(dentry->d_name.name); 74 kfree(dentry->d_name.name);
77 kmem_cache_free(dentry_cache, dentry); 75 kmem_cache_free(dentry_cache, dentry);
78} 76}
79 77
78static void d_callback(struct rcu_head *head)
79{
80 struct dentry * dentry = container_of(head, struct dentry, d_u.d_rcu);
81 __d_free(dentry);
82}
83
80/* 84/*
81 * no dcache_lock, please. The caller must decrement dentry_stat.nr_dentry 85 * no dcache_lock, please. The caller must decrement dentry_stat.nr_dentry
82 * inside dcache_lock. 86 * inside dcache_lock.
@@ -85,7 +89,11 @@ static void d_free(struct dentry *dentry)
85{ 89{
86 if (dentry->d_op && dentry->d_op->d_release) 90 if (dentry->d_op && dentry->d_op->d_release)
87 dentry->d_op->d_release(dentry); 91 dentry->d_op->d_release(dentry);
88 call_rcu(&dentry->d_u.d_rcu, d_callback); 92 /* if dentry was never inserted into hash, immediate free is OK */
93 if (dentry->d_hash.pprev == NULL)
94 __d_free(dentry);
95 else
96 call_rcu(&dentry->d_u.d_rcu, d_callback);
89} 97}
90 98
91/* 99/*
@@ -2072,10 +2080,10 @@ static void __init dcache_init(unsigned long mempages)
2072} 2080}
2073 2081
2074/* SLAB cache for __getname() consumers */ 2082/* SLAB cache for __getname() consumers */
2075kmem_cache_t *names_cachep __read_mostly; 2083struct kmem_cache *names_cachep __read_mostly;
2076 2084
2077/* SLAB cache for file structures */ 2085/* SLAB cache for file structures */
2078kmem_cache_t *filp_cachep __read_mostly; 2086struct kmem_cache *filp_cachep __read_mostly;
2079 2087
2080EXPORT_SYMBOL(d_genocide); 2088EXPORT_SYMBOL(d_genocide);
2081 2089
diff --git a/fs/dcookies.c b/fs/dcookies.c
index 0c4b0674854b..21af1629f9bc 100644
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -37,7 +37,7 @@ struct dcookie_struct {
37 37
38static LIST_HEAD(dcookie_users); 38static LIST_HEAD(dcookie_users);
39static DEFINE_MUTEX(dcookie_mutex); 39static DEFINE_MUTEX(dcookie_mutex);
40static kmem_cache_t *dcookie_cache __read_mostly; 40static struct kmem_cache *dcookie_cache __read_mostly;
41static struct list_head *dcookie_hashtable __read_mostly; 41static struct list_head *dcookie_hashtable __read_mostly;
42static size_t hash_size __read_mostly; 42static size_t hash_size __read_mostly;
43 43
diff --git a/fs/dlm/Kconfig b/fs/dlm/Kconfig
index 81b2c6465eeb..b5654a284fef 100644
--- a/fs/dlm/Kconfig
+++ b/fs/dlm/Kconfig
@@ -1,14 +1,32 @@
1menu "Distributed Lock Manager" 1menu "Distributed Lock Manager"
2 depends on INET && IP_SCTP && EXPERIMENTAL 2 depends on EXPERIMENTAL && INET
3 3
4config DLM 4config DLM
5 tristate "Distributed Lock Manager (DLM)" 5 tristate "Distributed Lock Manager (DLM)"
6 depends on IPV6 || IPV6=n 6 depends on IPV6 || IPV6=n
7 select CONFIGFS_FS 7 select CONFIGFS_FS
8 select IP_SCTP if DLM_SCTP
8 help 9 help
9 A general purpose distributed lock manager for kernel or userspace 10 A general purpose distributed lock manager for kernel or userspace
10 applications. 11 applications.
11 12
13choice
14 prompt "Select DLM communications protocol"
15 depends on DLM
16 default DLM_TCP
17 help
18 The DLM Can use TCP or SCTP for it's network communications.
19 SCTP supports multi-homed operations whereas TCP doesn't.
20 However, SCTP seems to have stability problems at the moment.
21
22config DLM_TCP
23 bool "TCP/IP"
24
25config DLM_SCTP
26 bool "SCTP"
27
28endchoice
29
12config DLM_DEBUG 30config DLM_DEBUG
13 bool "DLM debugging" 31 bool "DLM debugging"
14 depends on DLM 32 depends on DLM
diff --git a/fs/dlm/Makefile b/fs/dlm/Makefile
index 1832e0297f7d..65388944eba0 100644
--- a/fs/dlm/Makefile
+++ b/fs/dlm/Makefile
@@ -4,7 +4,6 @@ dlm-y := ast.o \
4 dir.o \ 4 dir.o \
5 lock.o \ 5 lock.o \
6 lockspace.o \ 6 lockspace.o \
7 lowcomms.o \
8 main.o \ 7 main.o \
9 member.o \ 8 member.o \
10 memory.o \ 9 memory.o \
@@ -17,3 +16,6 @@ dlm-y := ast.o \
17 util.o 16 util.o
18dlm-$(CONFIG_DLM_DEBUG) += debug_fs.o 17dlm-$(CONFIG_DLM_DEBUG) += debug_fs.o
19 18
19dlm-$(CONFIG_DLM_TCP) += lowcomms-tcp.o
20
21dlm-$(CONFIG_DLM_SCTP) += lowcomms-sctp.o \ No newline at end of file
diff --git a/fs/dlm/dlm_internal.h b/fs/dlm/dlm_internal.h
index 1e5cd67e1b7a..1ee8195e6fc0 100644
--- a/fs/dlm/dlm_internal.h
+++ b/fs/dlm/dlm_internal.h
@@ -471,6 +471,7 @@ struct dlm_ls {
471 char *ls_recover_buf; 471 char *ls_recover_buf;
472 int ls_recover_nodeid; /* for debugging */ 472 int ls_recover_nodeid; /* for debugging */
473 uint64_t ls_rcom_seq; 473 uint64_t ls_rcom_seq;
474 spinlock_t ls_rcom_spin;
474 struct list_head ls_recover_list; 475 struct list_head ls_recover_list;
475 spinlock_t ls_recover_list_lock; 476 spinlock_t ls_recover_list_lock;
476 int ls_recover_list_count; 477 int ls_recover_list_count;
@@ -488,7 +489,8 @@ struct dlm_ls {
488#define LSFL_RUNNING 1 489#define LSFL_RUNNING 1
489#define LSFL_RECOVERY_STOP 2 490#define LSFL_RECOVERY_STOP 2
490#define LSFL_RCOM_READY 3 491#define LSFL_RCOM_READY 3
491#define LSFL_UEVENT_WAIT 4 492#define LSFL_RCOM_WAIT 4
493#define LSFL_UEVENT_WAIT 5
492 494
493/* much of this is just saving user space pointers associated with the 495/* much of this is just saving user space pointers associated with the
494 lock that we pass back to the user lib with an ast */ 496 lock that we pass back to the user lib with an ast */
diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
index 3f2befa4797b..30878defaeb6 100644
--- a/fs/dlm/lock.c
+++ b/fs/dlm/lock.c
@@ -2372,6 +2372,7 @@ static int send_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms_in,
2372static void receive_flags(struct dlm_lkb *lkb, struct dlm_message *ms) 2372static void receive_flags(struct dlm_lkb *lkb, struct dlm_message *ms)
2373{ 2373{
2374 lkb->lkb_exflags = ms->m_exflags; 2374 lkb->lkb_exflags = ms->m_exflags;
2375 lkb->lkb_sbflags = ms->m_sbflags;
2375 lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) | 2376 lkb->lkb_flags = (lkb->lkb_flags & 0xFFFF0000) |
2376 (ms->m_flags & 0x0000FFFF); 2377 (ms->m_flags & 0x0000FFFF);
2377} 2378}
@@ -3028,10 +3029,17 @@ int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
3028 3029
3029 while (1) { 3030 while (1) {
3030 if (dlm_locking_stopped(ls)) { 3031 if (dlm_locking_stopped(ls)) {
3031 if (!recovery) 3032 if (recovery) {
3032 dlm_add_requestqueue(ls, nodeid, hd); 3033 error = -EINTR;
3033 error = -EINTR; 3034 goto out;
3034 goto out; 3035 }
3036 error = dlm_add_requestqueue(ls, nodeid, hd);
3037 if (error == -EAGAIN)
3038 continue;
3039 else {
3040 error = -EINTR;
3041 goto out;
3042 }
3035 } 3043 }
3036 3044
3037 if (lock_recovery_try(ls)) 3045 if (lock_recovery_try(ls))
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index f8842ca443c2..59012b089e8d 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -22,6 +22,7 @@
22#include "memory.h" 22#include "memory.h"
23#include "lock.h" 23#include "lock.h"
24#include "recover.h" 24#include "recover.h"
25#include "requestqueue.h"
25 26
26#ifdef CONFIG_DLM_DEBUG 27#ifdef CONFIG_DLM_DEBUG
27int dlm_create_debug_file(struct dlm_ls *ls); 28int dlm_create_debug_file(struct dlm_ls *ls);
@@ -478,6 +479,8 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
478 ls->ls_recoverd_task = NULL; 479 ls->ls_recoverd_task = NULL;
479 mutex_init(&ls->ls_recoverd_active); 480 mutex_init(&ls->ls_recoverd_active);
480 spin_lock_init(&ls->ls_recover_lock); 481 spin_lock_init(&ls->ls_recover_lock);
482 spin_lock_init(&ls->ls_rcom_spin);
483 get_random_bytes(&ls->ls_rcom_seq, sizeof(uint64_t));
481 ls->ls_recover_status = 0; 484 ls->ls_recover_status = 0;
482 ls->ls_recover_seq = 0; 485 ls->ls_recover_seq = 0;
483 ls->ls_recover_args = NULL; 486 ls->ls_recover_args = NULL;
@@ -684,6 +687,7 @@ static int release_lockspace(struct dlm_ls *ls, int force)
684 * Free structures on any other lists 687 * Free structures on any other lists
685 */ 688 */
686 689
690 dlm_purge_requestqueue(ls);
687 kfree(ls->ls_recover_args); 691 kfree(ls->ls_recover_args);
688 dlm_clear_free_entries(ls); 692 dlm_clear_free_entries(ls);
689 dlm_clear_members(ls); 693 dlm_clear_members(ls);
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms-sctp.c
index 6da6b14d5a61..fe158d7a9285 100644
--- a/fs/dlm/lowcomms.c
+++ b/fs/dlm/lowcomms-sctp.c
@@ -2,7 +2,7 @@
2******************************************************************************* 2*******************************************************************************
3** 3**
4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. 5** Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
6** 6**
7** This copyrighted material is made available to anyone wishing to use, 7** This copyrighted material is made available to anyone wishing to use,
8** modify, copy, or redistribute it subject to the terms and conditions 8** modify, copy, or redistribute it subject to the terms and conditions
@@ -75,13 +75,13 @@ struct nodeinfo {
75}; 75};
76 76
77static DEFINE_IDR(nodeinfo_idr); 77static DEFINE_IDR(nodeinfo_idr);
78static struct rw_semaphore nodeinfo_lock; 78static DECLARE_RWSEM(nodeinfo_lock);
79static int max_nodeid; 79static int max_nodeid;
80 80
81struct cbuf { 81struct cbuf {
82 unsigned base; 82 unsigned int base;
83 unsigned len; 83 unsigned int len;
84 unsigned mask; 84 unsigned int mask;
85}; 85};
86 86
87/* Just the one of these, now. But this struct keeps 87/* Just the one of these, now. But this struct keeps
@@ -90,9 +90,9 @@ struct cbuf {
90#define CF_READ_PENDING 1 90#define CF_READ_PENDING 1
91 91
92struct connection { 92struct connection {
93 struct socket *sock; 93 struct socket *sock;
94 unsigned long flags; 94 unsigned long flags;
95 struct page *rx_page; 95 struct page *rx_page;
96 atomic_t waiting_requests; 96 atomic_t waiting_requests;
97 struct cbuf cb; 97 struct cbuf cb;
98 int eagain_flag; 98 int eagain_flag;
@@ -102,36 +102,40 @@ struct connection {
102 102
103struct writequeue_entry { 103struct writequeue_entry {
104 struct list_head list; 104 struct list_head list;
105 struct page *page; 105 struct page *page;
106 int offset; 106 int offset;
107 int len; 107 int len;
108 int end; 108 int end;
109 int users; 109 int users;
110 struct nodeinfo *ni; 110 struct nodeinfo *ni;
111}; 111};
112 112
113#define CBUF_ADD(cb, n) do { (cb)->len += n; } while(0) 113static void cbuf_add(struct cbuf *cb, int n)
114#define CBUF_EMPTY(cb) ((cb)->len == 0) 114{
115#define CBUF_MAY_ADD(cb, n) (((cb)->len + (n)) < ((cb)->mask + 1)) 115 cb->len += n;
116#define CBUF_DATA(cb) (((cb)->base + (cb)->len) & (cb)->mask) 116}
117 117
118#define CBUF_INIT(cb, size) \ 118static int cbuf_data(struct cbuf *cb)
119do { \ 119{
120 (cb)->base = (cb)->len = 0; \ 120 return ((cb->base + cb->len) & cb->mask);
121 (cb)->mask = ((size)-1); \ 121}
122} while(0)
123 122
124#define CBUF_EAT(cb, n) \ 123static void cbuf_init(struct cbuf *cb, int size)
125do { \ 124{
126 (cb)->len -= (n); \ 125 cb->base = cb->len = 0;
127 (cb)->base += (n); \ 126 cb->mask = size-1;
128 (cb)->base &= (cb)->mask; \ 127}
129} while(0)
130 128
129static void cbuf_eat(struct cbuf *cb, int n)
130{
131 cb->len -= n;
132 cb->base += n;
133 cb->base &= cb->mask;
134}
131 135
132/* List of nodes which have writes pending */ 136/* List of nodes which have writes pending */
133static struct list_head write_nodes; 137static LIST_HEAD(write_nodes);
134static spinlock_t write_nodes_lock; 138static DEFINE_SPINLOCK(write_nodes_lock);
135 139
136/* Maximum number of incoming messages to process before 140/* Maximum number of incoming messages to process before
137 * doing a schedule() 141 * doing a schedule()
@@ -141,8 +145,7 @@ static spinlock_t write_nodes_lock;
141/* Manage daemons */ 145/* Manage daemons */
142static struct task_struct *recv_task; 146static struct task_struct *recv_task;
143static struct task_struct *send_task; 147static struct task_struct *send_task;
144static wait_queue_head_t lowcomms_recv_wait; 148static DECLARE_WAIT_QUEUE_HEAD(lowcomms_recv_wait);
145static atomic_t accepting;
146 149
147/* The SCTP connection */ 150/* The SCTP connection */
148static struct connection sctp_con; 151static struct connection sctp_con;
@@ -161,11 +164,11 @@ static int nodeid_to_addr(int nodeid, struct sockaddr *retaddr)
161 return error; 164 return error;
162 165
163 if (dlm_local_addr[0]->ss_family == AF_INET) { 166 if (dlm_local_addr[0]->ss_family == AF_INET) {
164 struct sockaddr_in *in4 = (struct sockaddr_in *) &addr; 167 struct sockaddr_in *in4 = (struct sockaddr_in *) &addr;
165 struct sockaddr_in *ret4 = (struct sockaddr_in *) retaddr; 168 struct sockaddr_in *ret4 = (struct sockaddr_in *) retaddr;
166 ret4->sin_addr.s_addr = in4->sin_addr.s_addr; 169 ret4->sin_addr.s_addr = in4->sin_addr.s_addr;
167 } else { 170 } else {
168 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &addr; 171 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &addr;
169 struct sockaddr_in6 *ret6 = (struct sockaddr_in6 *) retaddr; 172 struct sockaddr_in6 *ret6 = (struct sockaddr_in6 *) retaddr;
170 memcpy(&ret6->sin6_addr, &in6->sin6_addr, 173 memcpy(&ret6->sin6_addr, &in6->sin6_addr,
171 sizeof(in6->sin6_addr)); 174 sizeof(in6->sin6_addr));
@@ -174,6 +177,8 @@ static int nodeid_to_addr(int nodeid, struct sockaddr *retaddr)
174 return 0; 177 return 0;
175} 178}
176 179
180/* If alloc is 0 here we will not attempt to allocate a new
181 nodeinfo struct */
177static struct nodeinfo *nodeid2nodeinfo(int nodeid, gfp_t alloc) 182static struct nodeinfo *nodeid2nodeinfo(int nodeid, gfp_t alloc)
178{ 183{
179 struct nodeinfo *ni; 184 struct nodeinfo *ni;
@@ -184,44 +189,45 @@ static struct nodeinfo *nodeid2nodeinfo(int nodeid, gfp_t alloc)
184 ni = idr_find(&nodeinfo_idr, nodeid); 189 ni = idr_find(&nodeinfo_idr, nodeid);
185 up_read(&nodeinfo_lock); 190 up_read(&nodeinfo_lock);
186 191
187 if (!ni && alloc) { 192 if (ni || !alloc)
188 down_write(&nodeinfo_lock); 193 return ni;
189 194
190 ni = idr_find(&nodeinfo_idr, nodeid); 195 down_write(&nodeinfo_lock);
191 if (ni)
192 goto out_up;
193 196
194 r = idr_pre_get(&nodeinfo_idr, alloc); 197 ni = idr_find(&nodeinfo_idr, nodeid);
195 if (!r) 198 if (ni)
196 goto out_up; 199 goto out_up;
197 200
198 ni = kmalloc(sizeof(struct nodeinfo), alloc); 201 r = idr_pre_get(&nodeinfo_idr, alloc);
199 if (!ni) 202 if (!r)
200 goto out_up; 203 goto out_up;
201 204
202 r = idr_get_new_above(&nodeinfo_idr, ni, nodeid, &n); 205 ni = kmalloc(sizeof(struct nodeinfo), alloc);
203 if (r) { 206 if (!ni)
204 kfree(ni); 207 goto out_up;
205 ni = NULL; 208
206 goto out_up; 209 r = idr_get_new_above(&nodeinfo_idr, ni, nodeid, &n);
207 } 210 if (r) {
208 if (n != nodeid) { 211 kfree(ni);
209 idr_remove(&nodeinfo_idr, n); 212 ni = NULL;
210 kfree(ni); 213 goto out_up;
211 ni = NULL;
212 goto out_up;
213 }
214 memset(ni, 0, sizeof(struct nodeinfo));
215 spin_lock_init(&ni->lock);
216 INIT_LIST_HEAD(&ni->writequeue);
217 spin_lock_init(&ni->writequeue_lock);
218 ni->nodeid = nodeid;
219
220 if (nodeid > max_nodeid)
221 max_nodeid = nodeid;
222 out_up:
223 up_write(&nodeinfo_lock);
224 } 214 }
215 if (n != nodeid) {
216 idr_remove(&nodeinfo_idr, n);
217 kfree(ni);
218 ni = NULL;
219 goto out_up;
220 }
221 memset(ni, 0, sizeof(struct nodeinfo));
222 spin_lock_init(&ni->lock);
223 INIT_LIST_HEAD(&ni->writequeue);
224 spin_lock_init(&ni->writequeue_lock);
225 ni->nodeid = nodeid;
226
227 if (nodeid > max_nodeid)
228 max_nodeid = nodeid;
229out_up:
230 up_write(&nodeinfo_lock);
225 231
226 return ni; 232 return ni;
227} 233}
@@ -279,13 +285,13 @@ static void make_sockaddr(struct sockaddr_storage *saddr, uint16_t port,
279 in4_addr->sin_port = cpu_to_be16(port); 285 in4_addr->sin_port = cpu_to_be16(port);
280 memset(&in4_addr->sin_zero, 0, sizeof(in4_addr->sin_zero)); 286 memset(&in4_addr->sin_zero, 0, sizeof(in4_addr->sin_zero));
281 memset(in4_addr+1, 0, sizeof(struct sockaddr_storage) - 287 memset(in4_addr+1, 0, sizeof(struct sockaddr_storage) -
282 sizeof(struct sockaddr_in)); 288 sizeof(struct sockaddr_in));
283 *addr_len = sizeof(struct sockaddr_in); 289 *addr_len = sizeof(struct sockaddr_in);
284 } else { 290 } else {
285 struct sockaddr_in6 *in6_addr = (struct sockaddr_in6 *)saddr; 291 struct sockaddr_in6 *in6_addr = (struct sockaddr_in6 *)saddr;
286 in6_addr->sin6_port = cpu_to_be16(port); 292 in6_addr->sin6_port = cpu_to_be16(port);
287 memset(in6_addr+1, 0, sizeof(struct sockaddr_storage) - 293 memset(in6_addr+1, 0, sizeof(struct sockaddr_storage) -
288 sizeof(struct sockaddr_in6)); 294 sizeof(struct sockaddr_in6));
289 *addr_len = sizeof(struct sockaddr_in6); 295 *addr_len = sizeof(struct sockaddr_in6);
290 } 296 }
291} 297}
@@ -324,7 +330,7 @@ static void send_shutdown(sctp_assoc_t associd)
324 cmsg->cmsg_type = SCTP_SNDRCV; 330 cmsg->cmsg_type = SCTP_SNDRCV;
325 cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo)); 331 cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
326 outmessage.msg_controllen = cmsg->cmsg_len; 332 outmessage.msg_controllen = cmsg->cmsg_len;
327 sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); 333 sinfo = CMSG_DATA(cmsg);
328 memset(sinfo, 0x00, sizeof(struct sctp_sndrcvinfo)); 334 memset(sinfo, 0x00, sizeof(struct sctp_sndrcvinfo));
329 335
330 sinfo->sinfo_flags |= MSG_EOF; 336 sinfo->sinfo_flags |= MSG_EOF;
@@ -387,7 +393,7 @@ static void process_sctp_notification(struct msghdr *msg, char *buf)
387 393
388 if ((int)sn->sn_assoc_change.sac_assoc_id <= 0) { 394 if ((int)sn->sn_assoc_change.sac_assoc_id <= 0) {
389 log_print("COMM_UP for invalid assoc ID %d", 395 log_print("COMM_UP for invalid assoc ID %d",
390 (int)sn->sn_assoc_change.sac_assoc_id); 396 (int)sn->sn_assoc_change.sac_assoc_id);
391 init_failed(); 397 init_failed();
392 return; 398 return;
393 } 399 }
@@ -398,15 +404,18 @@ static void process_sctp_notification(struct msghdr *msg, char *buf)
398 fs = get_fs(); 404 fs = get_fs();
399 set_fs(get_ds()); 405 set_fs(get_ds());
400 ret = sctp_con.sock->ops->getsockopt(sctp_con.sock, 406 ret = sctp_con.sock->ops->getsockopt(sctp_con.sock,
401 IPPROTO_SCTP, SCTP_PRIMARY_ADDR, 407 IPPROTO_SCTP,
402 (char*)&prim, &prim_len); 408 SCTP_PRIMARY_ADDR,
409 (char*)&prim,
410 &prim_len);
403 set_fs(fs); 411 set_fs(fs);
404 if (ret < 0) { 412 if (ret < 0) {
405 struct nodeinfo *ni; 413 struct nodeinfo *ni;
406 414
407 log_print("getsockopt/sctp_primary_addr on " 415 log_print("getsockopt/sctp_primary_addr on "
408 "new assoc %d failed : %d", 416 "new assoc %d failed : %d",
409 (int)sn->sn_assoc_change.sac_assoc_id, ret); 417 (int)sn->sn_assoc_change.sac_assoc_id,
418 ret);
410 419
411 /* Retry INIT later */ 420 /* Retry INIT later */
412 ni = assoc2nodeinfo(sn->sn_assoc_change.sac_assoc_id); 421 ni = assoc2nodeinfo(sn->sn_assoc_change.sac_assoc_id);
@@ -426,12 +435,10 @@ static void process_sctp_notification(struct msghdr *msg, char *buf)
426 return; 435 return;
427 436
428 /* Save the assoc ID */ 437 /* Save the assoc ID */
429 spin_lock(&ni->lock);
430 ni->assoc_id = sn->sn_assoc_change.sac_assoc_id; 438 ni->assoc_id = sn->sn_assoc_change.sac_assoc_id;
431 spin_unlock(&ni->lock);
432 439
433 log_print("got new/restarted association %d nodeid %d", 440 log_print("got new/restarted association %d nodeid %d",
434 (int)sn->sn_assoc_change.sac_assoc_id, nodeid); 441 (int)sn->sn_assoc_change.sac_assoc_id, nodeid);
435 442
436 /* Send any pending writes */ 443 /* Send any pending writes */
437 clear_bit(NI_INIT_PENDING, &ni->flags); 444 clear_bit(NI_INIT_PENDING, &ni->flags);
@@ -507,13 +514,12 @@ static int receive_from_sock(void)
507 sctp_con.rx_page = alloc_page(GFP_ATOMIC); 514 sctp_con.rx_page = alloc_page(GFP_ATOMIC);
508 if (sctp_con.rx_page == NULL) 515 if (sctp_con.rx_page == NULL)
509 goto out_resched; 516 goto out_resched;
510 CBUF_INIT(&sctp_con.cb, PAGE_CACHE_SIZE); 517 cbuf_init(&sctp_con.cb, PAGE_CACHE_SIZE);
511 } 518 }
512 519
513 memset(&incmsg, 0, sizeof(incmsg)); 520 memset(&incmsg, 0, sizeof(incmsg));
514 memset(&msgname, 0, sizeof(msgname)); 521 memset(&msgname, 0, sizeof(msgname));
515 522
516 memset(incmsg, 0, sizeof(incmsg));
517 msg.msg_name = &msgname; 523 msg.msg_name = &msgname;
518 msg.msg_namelen = sizeof(msgname); 524 msg.msg_namelen = sizeof(msgname);
519 msg.msg_flags = 0; 525 msg.msg_flags = 0;
@@ -532,17 +538,17 @@ static int receive_from_sock(void)
532 * iov[0] is the bit of the circular buffer between the current end 538 * iov[0] is the bit of the circular buffer between the current end
533 * point (cb.base + cb.len) and the end of the buffer. 539 * point (cb.base + cb.len) and the end of the buffer.
534 */ 540 */
535 iov[0].iov_len = sctp_con.cb.base - CBUF_DATA(&sctp_con.cb); 541 iov[0].iov_len = sctp_con.cb.base - cbuf_data(&sctp_con.cb);
536 iov[0].iov_base = page_address(sctp_con.rx_page) + 542 iov[0].iov_base = page_address(sctp_con.rx_page) +
537 CBUF_DATA(&sctp_con.cb); 543 cbuf_data(&sctp_con.cb);
538 iov[1].iov_len = 0; 544 iov[1].iov_len = 0;
539 545
540 /* 546 /*
541 * iov[1] is the bit of the circular buffer between the start of the 547 * iov[1] is the bit of the circular buffer between the start of the
542 * buffer and the start of the currently used section (cb.base) 548 * buffer and the start of the currently used section (cb.base)
543 */ 549 */
544 if (CBUF_DATA(&sctp_con.cb) >= sctp_con.cb.base) { 550 if (cbuf_data(&sctp_con.cb) >= sctp_con.cb.base) {
545 iov[0].iov_len = PAGE_CACHE_SIZE - CBUF_DATA(&sctp_con.cb); 551 iov[0].iov_len = PAGE_CACHE_SIZE - cbuf_data(&sctp_con.cb);
546 iov[1].iov_len = sctp_con.cb.base; 552 iov[1].iov_len = sctp_con.cb.base;
547 iov[1].iov_base = page_address(sctp_con.rx_page); 553 iov[1].iov_base = page_address(sctp_con.rx_page);
548 msg.msg_iovlen = 2; 554 msg.msg_iovlen = 2;
@@ -557,7 +563,7 @@ static int receive_from_sock(void)
557 msg.msg_control = incmsg; 563 msg.msg_control = incmsg;
558 msg.msg_controllen = sizeof(incmsg); 564 msg.msg_controllen = sizeof(incmsg);
559 cmsg = CMSG_FIRSTHDR(&msg); 565 cmsg = CMSG_FIRSTHDR(&msg);
560 sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); 566 sinfo = CMSG_DATA(cmsg);
561 567
562 if (msg.msg_flags & MSG_NOTIFICATION) { 568 if (msg.msg_flags & MSG_NOTIFICATION) {
563 process_sctp_notification(&msg, page_address(sctp_con.rx_page)); 569 process_sctp_notification(&msg, page_address(sctp_con.rx_page));
@@ -583,29 +589,29 @@ static int receive_from_sock(void)
583 if (r == 1) 589 if (r == 1)
584 return 0; 590 return 0;
585 591
586 CBUF_ADD(&sctp_con.cb, ret); 592 cbuf_add(&sctp_con.cb, ret);
587 ret = dlm_process_incoming_buffer(cpu_to_le32(sinfo->sinfo_ppid), 593 ret = dlm_process_incoming_buffer(cpu_to_le32(sinfo->sinfo_ppid),
588 page_address(sctp_con.rx_page), 594 page_address(sctp_con.rx_page),
589 sctp_con.cb.base, sctp_con.cb.len, 595 sctp_con.cb.base, sctp_con.cb.len,
590 PAGE_CACHE_SIZE); 596 PAGE_CACHE_SIZE);
591 if (ret < 0) 597 if (ret < 0)
592 goto out_close; 598 goto out_close;
593 CBUF_EAT(&sctp_con.cb, ret); 599 cbuf_eat(&sctp_con.cb, ret);
594 600
595 out: 601out:
596 ret = 0; 602 ret = 0;
597 goto out_ret; 603 goto out_ret;
598 604
599 out_resched: 605out_resched:
600 lowcomms_data_ready(sctp_con.sock->sk, 0); 606 lowcomms_data_ready(sctp_con.sock->sk, 0);
601 ret = 0; 607 ret = 0;
602 schedule(); 608 cond_resched();
603 goto out_ret; 609 goto out_ret;
604 610
605 out_close: 611out_close:
606 if (ret != -EAGAIN) 612 if (ret != -EAGAIN)
607 log_print("error reading from sctp socket: %d", ret); 613 log_print("error reading from sctp socket: %d", ret);
608 out_ret: 614out_ret:
609 return ret; 615 return ret;
610} 616}
611 617
@@ -619,10 +625,12 @@ static int add_bind_addr(struct sockaddr_storage *addr, int addr_len, int num)
619 set_fs(get_ds()); 625 set_fs(get_ds());
620 if (num == 1) 626 if (num == 1)
621 result = sctp_con.sock->ops->bind(sctp_con.sock, 627 result = sctp_con.sock->ops->bind(sctp_con.sock,
622 (struct sockaddr *) addr, addr_len); 628 (struct sockaddr *) addr,
629 addr_len);
623 else 630 else
624 result = sctp_con.sock->ops->setsockopt(sctp_con.sock, SOL_SCTP, 631 result = sctp_con.sock->ops->setsockopt(sctp_con.sock, SOL_SCTP,
625 SCTP_SOCKOPT_BINDX_ADD, (char *)addr, addr_len); 632 SCTP_SOCKOPT_BINDX_ADD,
633 (char *)addr, addr_len);
626 set_fs(fs); 634 set_fs(fs);
627 635
628 if (result < 0) 636 if (result < 0)
@@ -719,10 +727,10 @@ static int init_sock(void)
719 727
720 return 0; 728 return 0;
721 729
722 create_delsock: 730create_delsock:
723 sock_release(sock); 731 sock_release(sock);
724 sctp_con.sock = NULL; 732 sctp_con.sock = NULL;
725 out: 733out:
726 return result; 734 return result;
727} 735}
728 736
@@ -756,16 +764,13 @@ void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc)
756 int users = 0; 764 int users = 0;
757 struct nodeinfo *ni; 765 struct nodeinfo *ni;
758 766
759 if (!atomic_read(&accepting))
760 return NULL;
761
762 ni = nodeid2nodeinfo(nodeid, allocation); 767 ni = nodeid2nodeinfo(nodeid, allocation);
763 if (!ni) 768 if (!ni)
764 return NULL; 769 return NULL;
765 770
766 spin_lock(&ni->writequeue_lock); 771 spin_lock(&ni->writequeue_lock);
767 e = list_entry(ni->writequeue.prev, struct writequeue_entry, list); 772 e = list_entry(ni->writequeue.prev, struct writequeue_entry, list);
768 if (((struct list_head *) e == &ni->writequeue) || 773 if ((&e->list == &ni->writequeue) ||
769 (PAGE_CACHE_SIZE - e->end < len)) { 774 (PAGE_CACHE_SIZE - e->end < len)) {
770 e = NULL; 775 e = NULL;
771 } else { 776 } else {
@@ -776,7 +781,7 @@ void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc)
776 spin_unlock(&ni->writequeue_lock); 781 spin_unlock(&ni->writequeue_lock);
777 782
778 if (e) { 783 if (e) {
779 got_one: 784 got_one:
780 if (users == 0) 785 if (users == 0)
781 kmap(e->page); 786 kmap(e->page);
782 *ppc = page_address(e->page) + offset; 787 *ppc = page_address(e->page) + offset;
@@ -803,9 +808,6 @@ void dlm_lowcomms_commit_buffer(void *arg)
803 int users; 808 int users;
804 struct nodeinfo *ni = e->ni; 809 struct nodeinfo *ni = e->ni;
805 810
806 if (!atomic_read(&accepting))
807 return;
808
809 spin_lock(&ni->writequeue_lock); 811 spin_lock(&ni->writequeue_lock);
810 users = --e->users; 812 users = --e->users;
811 if (users) 813 if (users)
@@ -822,7 +824,7 @@ void dlm_lowcomms_commit_buffer(void *arg)
822 } 824 }
823 return; 825 return;
824 826
825 out: 827out:
826 spin_unlock(&ni->writequeue_lock); 828 spin_unlock(&ni->writequeue_lock);
827 return; 829 return;
828} 830}
@@ -878,7 +880,7 @@ static void initiate_association(int nodeid)
878 cmsg->cmsg_level = IPPROTO_SCTP; 880 cmsg->cmsg_level = IPPROTO_SCTP;
879 cmsg->cmsg_type = SCTP_SNDRCV; 881 cmsg->cmsg_type = SCTP_SNDRCV;
880 cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo)); 882 cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
881 sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); 883 sinfo = CMSG_DATA(cmsg);
882 memset(sinfo, 0x00, sizeof(struct sctp_sndrcvinfo)); 884 memset(sinfo, 0x00, sizeof(struct sctp_sndrcvinfo));
883 sinfo->sinfo_ppid = cpu_to_le32(dlm_local_nodeid); 885 sinfo->sinfo_ppid = cpu_to_le32(dlm_local_nodeid);
884 886
@@ -892,7 +894,7 @@ static void initiate_association(int nodeid)
892} 894}
893 895
894/* Send a message */ 896/* Send a message */
895static int send_to_sock(struct nodeinfo *ni) 897static void send_to_sock(struct nodeinfo *ni)
896{ 898{
897 int ret = 0; 899 int ret = 0;
898 struct writequeue_entry *e; 900 struct writequeue_entry *e;
@@ -903,13 +905,13 @@ static int send_to_sock(struct nodeinfo *ni)
903 struct sctp_sndrcvinfo *sinfo; 905 struct sctp_sndrcvinfo *sinfo;
904 struct kvec iov; 906 struct kvec iov;
905 907
906 /* See if we need to init an association before we start 908 /* See if we need to init an association before we start
907 sending precious messages */ 909 sending precious messages */
908 spin_lock(&ni->lock); 910 spin_lock(&ni->lock);
909 if (!ni->assoc_id && !test_and_set_bit(NI_INIT_PENDING, &ni->flags)) { 911 if (!ni->assoc_id && !test_and_set_bit(NI_INIT_PENDING, &ni->flags)) {
910 spin_unlock(&ni->lock); 912 spin_unlock(&ni->lock);
911 initiate_association(ni->nodeid); 913 initiate_association(ni->nodeid);
912 return 0; 914 return;
913 } 915 }
914 spin_unlock(&ni->lock); 916 spin_unlock(&ni->lock);
915 917
@@ -923,7 +925,7 @@ static int send_to_sock(struct nodeinfo *ni)
923 cmsg->cmsg_level = IPPROTO_SCTP; 925 cmsg->cmsg_level = IPPROTO_SCTP;
924 cmsg->cmsg_type = SCTP_SNDRCV; 926 cmsg->cmsg_type = SCTP_SNDRCV;
925 cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo)); 927 cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
926 sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg); 928 sinfo = CMSG_DATA(cmsg);
927 memset(sinfo, 0x00, sizeof(struct sctp_sndrcvinfo)); 929 memset(sinfo, 0x00, sizeof(struct sctp_sndrcvinfo));
928 sinfo->sinfo_ppid = cpu_to_le32(dlm_local_nodeid); 930 sinfo->sinfo_ppid = cpu_to_le32(dlm_local_nodeid);
929 sinfo->sinfo_assoc_id = ni->assoc_id; 931 sinfo->sinfo_assoc_id = ni->assoc_id;
@@ -955,7 +957,7 @@ static int send_to_sock(struct nodeinfo *ni)
955 goto send_error; 957 goto send_error;
956 } else { 958 } else {
957 /* Don't starve people filling buffers */ 959 /* Don't starve people filling buffers */
958 schedule(); 960 cond_resched();
959 } 961 }
960 962
961 spin_lock(&ni->writequeue_lock); 963 spin_lock(&ni->writequeue_lock);
@@ -964,15 +966,16 @@ static int send_to_sock(struct nodeinfo *ni)
964 966
965 if (e->len == 0 && e->users == 0) { 967 if (e->len == 0 && e->users == 0) {
966 list_del(&e->list); 968 list_del(&e->list);
969 kunmap(e->page);
967 free_entry(e); 970 free_entry(e);
968 continue; 971 continue;
969 } 972 }
970 } 973 }
971 spin_unlock(&ni->writequeue_lock); 974 spin_unlock(&ni->writequeue_lock);
972 out: 975out:
973 return ret; 976 return;
974 977
975 send_error: 978send_error:
976 log_print("Error sending to node %d %d", ni->nodeid, ret); 979 log_print("Error sending to node %d %d", ni->nodeid, ret);
977 spin_lock(&ni->lock); 980 spin_lock(&ni->lock);
978 if (!test_and_set_bit(NI_INIT_PENDING, &ni->flags)) { 981 if (!test_and_set_bit(NI_INIT_PENDING, &ni->flags)) {
@@ -982,7 +985,7 @@ static int send_to_sock(struct nodeinfo *ni)
982 } else 985 } else
983 spin_unlock(&ni->lock); 986 spin_unlock(&ni->lock);
984 987
985 return ret; 988 return;
986} 989}
987 990
988/* Try to send any messages that are pending */ 991/* Try to send any messages that are pending */
@@ -994,7 +997,7 @@ static void process_output_queue(void)
994 spin_lock_bh(&write_nodes_lock); 997 spin_lock_bh(&write_nodes_lock);
995 list_for_each_safe(list, temp, &write_nodes) { 998 list_for_each_safe(list, temp, &write_nodes) {
996 struct nodeinfo *ni = 999 struct nodeinfo *ni =
997 list_entry(list, struct nodeinfo, write_list); 1000 list_entry(list, struct nodeinfo, write_list);
998 clear_bit(NI_WRITE_PENDING, &ni->flags); 1001 clear_bit(NI_WRITE_PENDING, &ni->flags);
999 list_del(&ni->write_list); 1002 list_del(&ni->write_list);
1000 1003
@@ -1106,7 +1109,7 @@ static int dlm_recvd(void *data)
1106 set_current_state(TASK_INTERRUPTIBLE); 1109 set_current_state(TASK_INTERRUPTIBLE);
1107 add_wait_queue(&lowcomms_recv_wait, &wait); 1110 add_wait_queue(&lowcomms_recv_wait, &wait);
1108 if (!test_bit(CF_READ_PENDING, &sctp_con.flags)) 1111 if (!test_bit(CF_READ_PENDING, &sctp_con.flags))
1109 schedule(); 1112 cond_resched();
1110 remove_wait_queue(&lowcomms_recv_wait, &wait); 1113 remove_wait_queue(&lowcomms_recv_wait, &wait);
1111 set_current_state(TASK_RUNNING); 1114 set_current_state(TASK_RUNNING);
1112 1115
@@ -1118,12 +1121,12 @@ static int dlm_recvd(void *data)
1118 1121
1119 /* Don't starve out everyone else */ 1122 /* Don't starve out everyone else */
1120 if (++count >= MAX_RX_MSG_COUNT) { 1123 if (++count >= MAX_RX_MSG_COUNT) {
1121 schedule(); 1124 cond_resched();
1122 count = 0; 1125 count = 0;
1123 } 1126 }
1124 } while (!kthread_should_stop() && ret >=0); 1127 } while (!kthread_should_stop() && ret >=0);
1125 } 1128 }
1126 schedule(); 1129 cond_resched();
1127 } 1130 }
1128 1131
1129 return 0; 1132 return 0;
@@ -1138,7 +1141,7 @@ static int dlm_sendd(void *data)
1138 while (!kthread_should_stop()) { 1141 while (!kthread_should_stop()) {
1139 set_current_state(TASK_INTERRUPTIBLE); 1142 set_current_state(TASK_INTERRUPTIBLE);
1140 if (write_list_empty()) 1143 if (write_list_empty())
1141 schedule(); 1144 cond_resched();
1142 set_current_state(TASK_RUNNING); 1145 set_current_state(TASK_RUNNING);
1143 1146
1144 if (sctp_con.eagain_flag) { 1147 if (sctp_con.eagain_flag) {
@@ -1166,7 +1169,7 @@ static int daemons_start(void)
1166 1169
1167 p = kthread_run(dlm_recvd, NULL, "dlm_recvd"); 1170 p = kthread_run(dlm_recvd, NULL, "dlm_recvd");
1168 error = IS_ERR(p); 1171 error = IS_ERR(p);
1169 if (error) { 1172 if (error) {
1170 log_print("can't start dlm_recvd %d", error); 1173 log_print("can't start dlm_recvd %d", error);
1171 return error; 1174 return error;
1172 } 1175 }
@@ -1174,7 +1177,7 @@ static int daemons_start(void)
1174 1177
1175 p = kthread_run(dlm_sendd, NULL, "dlm_sendd"); 1178 p = kthread_run(dlm_sendd, NULL, "dlm_sendd");
1176 error = IS_ERR(p); 1179 error = IS_ERR(p);
1177 if (error) { 1180 if (error) {
1178 log_print("can't start dlm_sendd %d", error); 1181 log_print("can't start dlm_sendd %d", error);
1179 kthread_stop(recv_task); 1182 kthread_stop(recv_task);
1180 return error; 1183 return error;
@@ -1197,43 +1200,28 @@ int dlm_lowcomms_start(void)
1197 error = daemons_start(); 1200 error = daemons_start();
1198 if (error) 1201 if (error)
1199 goto fail_sock; 1202 goto fail_sock;
1200 atomic_set(&accepting, 1);
1201 return 0; 1203 return 0;
1202 1204
1203 fail_sock: 1205fail_sock:
1204 close_connection(); 1206 close_connection();
1205 return error; 1207 return error;
1206} 1208}
1207 1209
1208/* Set all the activity flags to prevent any socket activity. */
1209
1210void dlm_lowcomms_stop(void) 1210void dlm_lowcomms_stop(void)
1211{ 1211{
1212 atomic_set(&accepting, 0); 1212 int i;
1213
1213 sctp_con.flags = 0x7; 1214 sctp_con.flags = 0x7;
1214 daemons_stop(); 1215 daemons_stop();
1215 clean_writequeues(); 1216 clean_writequeues();
1216 close_connection(); 1217 close_connection();
1217 dealloc_nodeinfo(); 1218 dealloc_nodeinfo();
1218 max_nodeid = 0; 1219 max_nodeid = 0;
1219}
1220 1220
1221int dlm_lowcomms_init(void) 1221 dlm_local_count = 0;
1222{ 1222 dlm_local_nodeid = 0;
1223 init_waitqueue_head(&lowcomms_recv_wait);
1224 spin_lock_init(&write_nodes_lock);
1225 INIT_LIST_HEAD(&write_nodes);
1226 init_rwsem(&nodeinfo_lock);
1227 return 0;
1228}
1229
1230void dlm_lowcomms_exit(void)
1231{
1232 int i;
1233 1223
1234 for (i = 0; i < dlm_local_count; i++) 1224 for (i = 0; i < dlm_local_count; i++)
1235 kfree(dlm_local_addr[i]); 1225 kfree(dlm_local_addr[i]);
1236 dlm_local_count = 0;
1237 dlm_local_nodeid = 0;
1238} 1226}
1239 1227
diff --git a/fs/dlm/lowcomms-tcp.c b/fs/dlm/lowcomms-tcp.c
new file mode 100644
index 000000000000..8f2791fc8447
--- /dev/null
+++ b/fs/dlm/lowcomms-tcp.c
@@ -0,0 +1,1189 @@
1/******************************************************************************
2*******************************************************************************
3**
4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5** Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
6**
7** This copyrighted material is made available to anyone wishing to use,
8** modify, copy, or redistribute it subject to the terms and conditions
9** of the GNU General Public License v.2.
10**
11*******************************************************************************
12******************************************************************************/
13
14/*
15 * lowcomms.c
16 *
17 * This is the "low-level" comms layer.
18 *
19 * It is responsible for sending/receiving messages
20 * from other nodes in the cluster.
21 *
22 * Cluster nodes are referred to by their nodeids. nodeids are
23 * simply 32 bit numbers to the locking module - if they need to
24 * be expanded for the cluster infrastructure then that is it's
25 * responsibility. It is this layer's
26 * responsibility to resolve these into IP address or
27 * whatever it needs for inter-node communication.
28 *
29 * The comms level is two kernel threads that deal mainly with
30 * the receiving of messages from other nodes and passing them
31 * up to the mid-level comms layer (which understands the
32 * message format) for execution by the locking core, and
33 * a send thread which does all the setting up of connections
34 * to remote nodes and the sending of data. Threads are not allowed
35 * to send their own data because it may cause them to wait in times
36 * of high load. Also, this way, the sending thread can collect together
37 * messages bound for one node and send them in one block.
38 *
39 * I don't see any problem with the recv thread executing the locking
40 * code on behalf of remote processes as the locking code is
41 * short, efficient and never waits.
42 *
43 */
44
45
46#include <asm/ioctls.h>
47#include <net/sock.h>
48#include <net/tcp.h>
49#include <linux/pagemap.h>
50
51#include "dlm_internal.h"
52#include "lowcomms.h"
53#include "midcomms.h"
54#include "config.h"
55
56struct cbuf {
57 unsigned int base;
58 unsigned int len;
59 unsigned int mask;
60};
61
62#define NODE_INCREMENT 32
63static void cbuf_add(struct cbuf *cb, int n)
64{
65 cb->len += n;
66}
67
68static int cbuf_data(struct cbuf *cb)
69{
70 return ((cb->base + cb->len) & cb->mask);
71}
72
73static void cbuf_init(struct cbuf *cb, int size)
74{
75 cb->base = cb->len = 0;
76 cb->mask = size-1;
77}
78
79static void cbuf_eat(struct cbuf *cb, int n)
80{
81 cb->len -= n;
82 cb->base += n;
83 cb->base &= cb->mask;
84}
85
86static bool cbuf_empty(struct cbuf *cb)
87{
88 return cb->len == 0;
89}
90
91/* Maximum number of incoming messages to process before
92 doing a cond_resched()
93*/
94#define MAX_RX_MSG_COUNT 25
95
96struct connection {
97 struct socket *sock; /* NULL if not connected */
98 uint32_t nodeid; /* So we know who we are in the list */
99 struct rw_semaphore sock_sem; /* Stop connect races */
100 struct list_head read_list; /* On this list when ready for reading */
101 struct list_head write_list; /* On this list when ready for writing */
102 struct list_head state_list; /* On this list when ready to connect */
103 unsigned long flags; /* bit 1,2 = We are on the read/write lists */
104#define CF_READ_PENDING 1
105#define CF_WRITE_PENDING 2
106#define CF_CONNECT_PENDING 3
107#define CF_IS_OTHERCON 4
108 struct list_head writequeue; /* List of outgoing writequeue_entries */
109 struct list_head listenlist; /* List of allocated listening sockets */
110 spinlock_t writequeue_lock;
111 int (*rx_action) (struct connection *); /* What to do when active */
112 struct page *rx_page;
113 struct cbuf cb;
114 int retries;
115 atomic_t waiting_requests;
116#define MAX_CONNECT_RETRIES 3
117 struct connection *othercon;
118};
119#define sock2con(x) ((struct connection *)(x)->sk_user_data)
120
121/* An entry waiting to be sent */
122struct writequeue_entry {
123 struct list_head list;
124 struct page *page;
125 int offset;
126 int len;
127 int end;
128 int users;
129 struct connection *con;
130};
131
132static struct sockaddr_storage dlm_local_addr;
133
134/* Manage daemons */
135static struct task_struct *recv_task;
136static struct task_struct *send_task;
137
138static wait_queue_t lowcomms_send_waitq_head;
139static DECLARE_WAIT_QUEUE_HEAD(lowcomms_send_waitq);
140static wait_queue_t lowcomms_recv_waitq_head;
141static DECLARE_WAIT_QUEUE_HEAD(lowcomms_recv_waitq);
142
143/* An array of pointers to connections, indexed by NODEID */
144static struct connection **connections;
145static DECLARE_MUTEX(connections_lock);
146static kmem_cache_t *con_cache;
147static int conn_array_size;
148
149/* List of sockets that have reads pending */
150static LIST_HEAD(read_sockets);
151static DEFINE_SPINLOCK(read_sockets_lock);
152
153/* List of sockets which have writes pending */
154static LIST_HEAD(write_sockets);
155static DEFINE_SPINLOCK(write_sockets_lock);
156
157/* List of sockets which have connects pending */
158static LIST_HEAD(state_sockets);
159static DEFINE_SPINLOCK(state_sockets_lock);
160
161static struct connection *nodeid2con(int nodeid, gfp_t allocation)
162{
163 struct connection *con = NULL;
164
165 down(&connections_lock);
166 if (nodeid >= conn_array_size) {
167 int new_size = nodeid + NODE_INCREMENT;
168 struct connection **new_conns;
169
170 new_conns = kzalloc(sizeof(struct connection *) *
171 new_size, allocation);
172 if (!new_conns)
173 goto finish;
174
175 memcpy(new_conns, connections, sizeof(struct connection *) * conn_array_size);
176 conn_array_size = new_size;
177 kfree(connections);
178 connections = new_conns;
179
180 }
181
182 con = connections[nodeid];
183 if (con == NULL && allocation) {
184 con = kmem_cache_zalloc(con_cache, allocation);
185 if (!con)
186 goto finish;
187
188 con->nodeid = nodeid;
189 init_rwsem(&con->sock_sem);
190 INIT_LIST_HEAD(&con->writequeue);
191 spin_lock_init(&con->writequeue_lock);
192
193 connections[nodeid] = con;
194 }
195
196finish:
197 up(&connections_lock);
198 return con;
199}
200
201/* Data available on socket or listen socket received a connect */
202static void lowcomms_data_ready(struct sock *sk, int count_unused)
203{
204 struct connection *con = sock2con(sk);
205
206 atomic_inc(&con->waiting_requests);
207 if (test_and_set_bit(CF_READ_PENDING, &con->flags))
208 return;
209
210 spin_lock_bh(&read_sockets_lock);
211 list_add_tail(&con->read_list, &read_sockets);
212 spin_unlock_bh(&read_sockets_lock);
213
214 wake_up_interruptible(&lowcomms_recv_waitq);
215}
216
217static void lowcomms_write_space(struct sock *sk)
218{
219 struct connection *con = sock2con(sk);
220
221 if (test_and_set_bit(CF_WRITE_PENDING, &con->flags))
222 return;
223
224 spin_lock_bh(&write_sockets_lock);
225 list_add_tail(&con->write_list, &write_sockets);
226 spin_unlock_bh(&write_sockets_lock);
227
228 wake_up_interruptible(&lowcomms_send_waitq);
229}
230
231static inline void lowcomms_connect_sock(struct connection *con)
232{
233 if (test_and_set_bit(CF_CONNECT_PENDING, &con->flags))
234 return;
235
236 spin_lock_bh(&state_sockets_lock);
237 list_add_tail(&con->state_list, &state_sockets);
238 spin_unlock_bh(&state_sockets_lock);
239
240 wake_up_interruptible(&lowcomms_send_waitq);
241}
242
243static void lowcomms_state_change(struct sock *sk)
244{
245 if (sk->sk_state == TCP_ESTABLISHED)
246 lowcomms_write_space(sk);
247}
248
249/* Make a socket active */
250static int add_sock(struct socket *sock, struct connection *con)
251{
252 con->sock = sock;
253
254 /* Install a data_ready callback */
255 con->sock->sk->sk_data_ready = lowcomms_data_ready;
256 con->sock->sk->sk_write_space = lowcomms_write_space;
257 con->sock->sk->sk_state_change = lowcomms_state_change;
258
259 return 0;
260}
261
262/* Add the port number to an IP6 or 4 sockaddr and return the address
263 length */
264static void make_sockaddr(struct sockaddr_storage *saddr, uint16_t port,
265 int *addr_len)
266{
267 saddr->ss_family = dlm_local_addr.ss_family;
268 if (saddr->ss_family == AF_INET) {
269 struct sockaddr_in *in4_addr = (struct sockaddr_in *)saddr;
270 in4_addr->sin_port = cpu_to_be16(port);
271 *addr_len = sizeof(struct sockaddr_in);
272 } else {
273 struct sockaddr_in6 *in6_addr = (struct sockaddr_in6 *)saddr;
274 in6_addr->sin6_port = cpu_to_be16(port);
275 *addr_len = sizeof(struct sockaddr_in6);
276 }
277}
278
279/* Close a remote connection and tidy up */
280static void close_connection(struct connection *con, bool and_other)
281{
282 down_write(&con->sock_sem);
283
284 if (con->sock) {
285 sock_release(con->sock);
286 con->sock = NULL;
287 }
288 if (con->othercon && and_other) {
289 /* Will only re-enter once. */
290 close_connection(con->othercon, false);
291 }
292 if (con->rx_page) {
293 __free_page(con->rx_page);
294 con->rx_page = NULL;
295 }
296 con->retries = 0;
297 up_write(&con->sock_sem);
298}
299
300/* Data received from remote end */
301static int receive_from_sock(struct connection *con)
302{
303 int ret = 0;
304 struct msghdr msg;
305 struct iovec iov[2];
306 mm_segment_t fs;
307 unsigned len;
308 int r;
309 int call_again_soon = 0;
310
311 down_read(&con->sock_sem);
312
313 if (con->sock == NULL)
314 goto out;
315 if (con->rx_page == NULL) {
316 /*
317 * This doesn't need to be atomic, but I think it should
318 * improve performance if it is.
319 */
320 con->rx_page = alloc_page(GFP_ATOMIC);
321 if (con->rx_page == NULL)
322 goto out_resched;
323 cbuf_init(&con->cb, PAGE_CACHE_SIZE);
324 }
325
326 msg.msg_control = NULL;
327 msg.msg_controllen = 0;
328 msg.msg_iovlen = 1;
329 msg.msg_iov = iov;
330 msg.msg_name = NULL;
331 msg.msg_namelen = 0;
332 msg.msg_flags = 0;
333
334 /*
335 * iov[0] is the bit of the circular buffer between the current end
336 * point (cb.base + cb.len) and the end of the buffer.
337 */
338 iov[0].iov_len = con->cb.base - cbuf_data(&con->cb);
339 iov[0].iov_base = page_address(con->rx_page) + cbuf_data(&con->cb);
340 iov[1].iov_len = 0;
341
342 /*
343 * iov[1] is the bit of the circular buffer between the start of the
344 * buffer and the start of the currently used section (cb.base)
345 */
346 if (cbuf_data(&con->cb) >= con->cb.base) {
347 iov[0].iov_len = PAGE_CACHE_SIZE - cbuf_data(&con->cb);
348 iov[1].iov_len = con->cb.base;
349 iov[1].iov_base = page_address(con->rx_page);
350 msg.msg_iovlen = 2;
351 }
352 len = iov[0].iov_len + iov[1].iov_len;
353
354 fs = get_fs();
355 set_fs(get_ds());
356 r = ret = sock_recvmsg(con->sock, &msg, len,
357 MSG_DONTWAIT | MSG_NOSIGNAL);
358 set_fs(fs);
359
360 if (ret <= 0)
361 goto out_close;
362 if (ret == len)
363 call_again_soon = 1;
364 cbuf_add(&con->cb, ret);
365 ret = dlm_process_incoming_buffer(con->nodeid,
366 page_address(con->rx_page),
367 con->cb.base, con->cb.len,
368 PAGE_CACHE_SIZE);
369 if (ret == -EBADMSG) {
370 printk(KERN_INFO "dlm: lowcomms: addr=%p, base=%u, len=%u, "
371 "iov_len=%u, iov_base[0]=%p, read=%d\n",
372 page_address(con->rx_page), con->cb.base, con->cb.len,
373 len, iov[0].iov_base, r);
374 }
375 if (ret < 0)
376 goto out_close;
377 cbuf_eat(&con->cb, ret);
378
379 if (cbuf_empty(&con->cb) && !call_again_soon) {
380 __free_page(con->rx_page);
381 con->rx_page = NULL;
382 }
383
384out:
385 if (call_again_soon)
386 goto out_resched;
387 up_read(&con->sock_sem);
388 return 0;
389
390out_resched:
391 lowcomms_data_ready(con->sock->sk, 0);
392 up_read(&con->sock_sem);
393 cond_resched();
394 return 0;
395
396out_close:
397 up_read(&con->sock_sem);
398 if (ret != -EAGAIN && !test_bit(CF_IS_OTHERCON, &con->flags)) {
399 close_connection(con, false);
400 /* Reconnect when there is something to send */
401 }
402
403 return ret;
404}
405
406/* Listening socket is busy, accept a connection */
407static int accept_from_sock(struct connection *con)
408{
409 int result;
410 struct sockaddr_storage peeraddr;
411 struct socket *newsock;
412 int len;
413 int nodeid;
414 struct connection *newcon;
415
416 memset(&peeraddr, 0, sizeof(peeraddr));
417 result = sock_create_kern(dlm_local_addr.ss_family, SOCK_STREAM,
418 IPPROTO_TCP, &newsock);
419 if (result < 0)
420 return -ENOMEM;
421
422 down_read(&con->sock_sem);
423
424 result = -ENOTCONN;
425 if (con->sock == NULL)
426 goto accept_err;
427
428 newsock->type = con->sock->type;
429 newsock->ops = con->sock->ops;
430
431 result = con->sock->ops->accept(con->sock, newsock, O_NONBLOCK);
432 if (result < 0)
433 goto accept_err;
434
435 /* Get the connected socket's peer */
436 memset(&peeraddr, 0, sizeof(peeraddr));
437 if (newsock->ops->getname(newsock, (struct sockaddr *)&peeraddr,
438 &len, 2)) {
439 result = -ECONNABORTED;
440 goto accept_err;
441 }
442
443 /* Get the new node's NODEID */
444 make_sockaddr(&peeraddr, 0, &len);
445 if (dlm_addr_to_nodeid(&peeraddr, &nodeid)) {
446 printk("dlm: connect from non cluster node\n");
447 sock_release(newsock);
448 up_read(&con->sock_sem);
449 return -1;
450 }
451
452 log_print("got connection from %d", nodeid);
453
454 /* Check to see if we already have a connection to this node. This
455 * could happen if the two nodes initiate a connection at roughly
456 * the same time and the connections cross on the wire.
457 * TEMPORARY FIX:
458 * In this case we store the incoming one in "othercon"
459 */
460 newcon = nodeid2con(nodeid, GFP_KERNEL);
461 if (!newcon) {
462 result = -ENOMEM;
463 goto accept_err;
464 }
465 down_write(&newcon->sock_sem);
466 if (newcon->sock) {
467 struct connection *othercon = newcon->othercon;
468
469 if (!othercon) {
470 othercon = kmem_cache_zalloc(con_cache, GFP_KERNEL);
471 if (!othercon) {
472 printk("dlm: failed to allocate incoming socket\n");
473 up_write(&newcon->sock_sem);
474 result = -ENOMEM;
475 goto accept_err;
476 }
477 othercon->nodeid = nodeid;
478 othercon->rx_action = receive_from_sock;
479 init_rwsem(&othercon->sock_sem);
480 set_bit(CF_IS_OTHERCON, &othercon->flags);
481 newcon->othercon = othercon;
482 }
483 othercon->sock = newsock;
484 newsock->sk->sk_user_data = othercon;
485 add_sock(newsock, othercon);
486 }
487 else {
488 newsock->sk->sk_user_data = newcon;
489 newcon->rx_action = receive_from_sock;
490 add_sock(newsock, newcon);
491
492 }
493
494 up_write(&newcon->sock_sem);
495
496 /*
497 * Add it to the active queue in case we got data
498 * beween processing the accept adding the socket
499 * to the read_sockets list
500 */
501 lowcomms_data_ready(newsock->sk, 0);
502 up_read(&con->sock_sem);
503
504 return 0;
505
506accept_err:
507 up_read(&con->sock_sem);
508 sock_release(newsock);
509
510 if (result != -EAGAIN)
511 printk("dlm: error accepting connection from node: %d\n", result);
512 return result;
513}
514
515/* Connect a new socket to its peer */
516static void connect_to_sock(struct connection *con)
517{
518 int result = -EHOSTUNREACH;
519 struct sockaddr_storage saddr;
520 int addr_len;
521 struct socket *sock;
522
523 if (con->nodeid == 0) {
524 log_print("attempt to connect sock 0 foiled");
525 return;
526 }
527
528 down_write(&con->sock_sem);
529 if (con->retries++ > MAX_CONNECT_RETRIES)
530 goto out;
531
532 /* Some odd races can cause double-connects, ignore them */
533 if (con->sock) {
534 result = 0;
535 goto out;
536 }
537
538 /* Create a socket to communicate with */
539 result = sock_create_kern(dlm_local_addr.ss_family, SOCK_STREAM,
540 IPPROTO_TCP, &sock);
541 if (result < 0)
542 goto out_err;
543
544 memset(&saddr, 0, sizeof(saddr));
545 if (dlm_nodeid_to_addr(con->nodeid, &saddr))
546 goto out_err;
547
548 sock->sk->sk_user_data = con;
549 con->rx_action = receive_from_sock;
550
551 make_sockaddr(&saddr, dlm_config.tcp_port, &addr_len);
552
553 add_sock(sock, con);
554
555 log_print("connecting to %d", con->nodeid);
556 result =
557 sock->ops->connect(sock, (struct sockaddr *)&saddr, addr_len,
558 O_NONBLOCK);
559 if (result == -EINPROGRESS)
560 result = 0;
561 if (result == 0)
562 goto out;
563
564out_err:
565 if (con->sock) {
566 sock_release(con->sock);
567 con->sock = NULL;
568 }
569 /*
570 * Some errors are fatal and this list might need adjusting. For other
571 * errors we try again until the max number of retries is reached.
572 */
573 if (result != -EHOSTUNREACH && result != -ENETUNREACH &&
574 result != -ENETDOWN && result != EINVAL
575 && result != -EPROTONOSUPPORT) {
576 lowcomms_connect_sock(con);
577 result = 0;
578 }
579out:
580 up_write(&con->sock_sem);
581 return;
582}
583
584static struct socket *create_listen_sock(struct connection *con,
585 struct sockaddr_storage *saddr)
586{
587 struct socket *sock = NULL;
588 mm_segment_t fs;
589 int result = 0;
590 int one = 1;
591 int addr_len;
592
593 if (dlm_local_addr.ss_family == AF_INET)
594 addr_len = sizeof(struct sockaddr_in);
595 else
596 addr_len = sizeof(struct sockaddr_in6);
597
598 /* Create a socket to communicate with */
599 result = sock_create_kern(dlm_local_addr.ss_family, SOCK_STREAM, IPPROTO_TCP, &sock);
600 if (result < 0) {
601 printk("dlm: Can't create listening comms socket\n");
602 goto create_out;
603 }
604
605 fs = get_fs();
606 set_fs(get_ds());
607 result = sock_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
608 (char *)&one, sizeof(one));
609 set_fs(fs);
610 if (result < 0) {
611 printk("dlm: Failed to set SO_REUSEADDR on socket: result=%d\n",
612 result);
613 }
614 sock->sk->sk_user_data = con;
615 con->rx_action = accept_from_sock;
616 con->sock = sock;
617
618 /* Bind to our port */
619 make_sockaddr(saddr, dlm_config.tcp_port, &addr_len);
620 result = sock->ops->bind(sock, (struct sockaddr *) saddr, addr_len);
621 if (result < 0) {
622 printk("dlm: Can't bind to port %d\n", dlm_config.tcp_port);
623 sock_release(sock);
624 sock = NULL;
625 con->sock = NULL;
626 goto create_out;
627 }
628
629 fs = get_fs();
630 set_fs(get_ds());
631
632 result = sock_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
633 (char *)&one, sizeof(one));
634 set_fs(fs);
635 if (result < 0) {
636 printk("dlm: Set keepalive failed: %d\n", result);
637 }
638
639 result = sock->ops->listen(sock, 5);
640 if (result < 0) {
641 printk("dlm: Can't listen on port %d\n", dlm_config.tcp_port);
642 sock_release(sock);
643 sock = NULL;
644 goto create_out;
645 }
646
647create_out:
648 return sock;
649}
650
651
652/* Listen on all interfaces */
653static int listen_for_all(void)
654{
655 struct socket *sock = NULL;
656 struct connection *con = nodeid2con(0, GFP_KERNEL);
657 int result = -EINVAL;
658
659 /* We don't support multi-homed hosts */
660 set_bit(CF_IS_OTHERCON, &con->flags);
661
662 sock = create_listen_sock(con, &dlm_local_addr);
663 if (sock) {
664 add_sock(sock, con);
665 result = 0;
666 }
667 else {
668 result = -EADDRINUSE;
669 }
670
671 return result;
672}
673
674
675
676static struct writequeue_entry *new_writequeue_entry(struct connection *con,
677 gfp_t allocation)
678{
679 struct writequeue_entry *entry;
680
681 entry = kmalloc(sizeof(struct writequeue_entry), allocation);
682 if (!entry)
683 return NULL;
684
685 entry->page = alloc_page(allocation);
686 if (!entry->page) {
687 kfree(entry);
688 return NULL;
689 }
690
691 entry->offset = 0;
692 entry->len = 0;
693 entry->end = 0;
694 entry->users = 0;
695 entry->con = con;
696
697 return entry;
698}
699
700void *dlm_lowcomms_get_buffer(int nodeid, int len,
701 gfp_t allocation, char **ppc)
702{
703 struct connection *con;
704 struct writequeue_entry *e;
705 int offset = 0;
706 int users = 0;
707
708 con = nodeid2con(nodeid, allocation);
709 if (!con)
710 return NULL;
711
712 e = list_entry(con->writequeue.prev, struct writequeue_entry, list);
713 if ((&e->list == &con->writequeue) ||
714 (PAGE_CACHE_SIZE - e->end < len)) {
715 e = NULL;
716 } else {
717 offset = e->end;
718 e->end += len;
719 users = e->users++;
720 }
721 spin_unlock(&con->writequeue_lock);
722
723 if (e) {
724 got_one:
725 if (users == 0)
726 kmap(e->page);
727 *ppc = page_address(e->page) + offset;
728 return e;
729 }
730
731 e = new_writequeue_entry(con, allocation);
732 if (e) {
733 spin_lock(&con->writequeue_lock);
734 offset = e->end;
735 e->end += len;
736 users = e->users++;
737 list_add_tail(&e->list, &con->writequeue);
738 spin_unlock(&con->writequeue_lock);
739 goto got_one;
740 }
741 return NULL;
742}
743
744void dlm_lowcomms_commit_buffer(void *mh)
745{
746 struct writequeue_entry *e = (struct writequeue_entry *)mh;
747 struct connection *con = e->con;
748 int users;
749
750 users = --e->users;
751 if (users)
752 goto out;
753 e->len = e->end - e->offset;
754 kunmap(e->page);
755 spin_unlock(&con->writequeue_lock);
756
757 if (test_and_set_bit(CF_WRITE_PENDING, &con->flags) == 0) {
758 spin_lock_bh(&write_sockets_lock);
759 list_add_tail(&con->write_list, &write_sockets);
760 spin_unlock_bh(&write_sockets_lock);
761
762 wake_up_interruptible(&lowcomms_send_waitq);
763 }
764 return;
765
766out:
767 spin_unlock(&con->writequeue_lock);
768 return;
769}
770
771static void free_entry(struct writequeue_entry *e)
772{
773 __free_page(e->page);
774 kfree(e);
775}
776
777/* Send a message */
778static void send_to_sock(struct connection *con)
779{
780 int ret = 0;
781 ssize_t(*sendpage) (struct socket *, struct page *, int, size_t, int);
782 const int msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL;
783 struct writequeue_entry *e;
784 int len, offset;
785
786 down_read(&con->sock_sem);
787 if (con->sock == NULL)
788 goto out_connect;
789
790 sendpage = con->sock->ops->sendpage;
791
792 spin_lock(&con->writequeue_lock);
793 for (;;) {
794 e = list_entry(con->writequeue.next, struct writequeue_entry,
795 list);
796 if ((struct list_head *) e == &con->writequeue)
797 break;
798
799 len = e->len;
800 offset = e->offset;
801 BUG_ON(len == 0 && e->users == 0);
802 spin_unlock(&con->writequeue_lock);
803
804 ret = 0;
805 if (len) {
806 ret = sendpage(con->sock, e->page, offset, len,
807 msg_flags);
808 if (ret == -EAGAIN || ret == 0)
809 goto out;
810 if (ret <= 0)
811 goto send_error;
812 }
813 else {
814 /* Don't starve people filling buffers */
815 cond_resched();
816 }
817
818 spin_lock(&con->writequeue_lock);
819 e->offset += ret;
820 e->len -= ret;
821
822 if (e->len == 0 && e->users == 0) {
823 list_del(&e->list);
824 kunmap(e->page);
825 free_entry(e);
826 continue;
827 }
828 }
829 spin_unlock(&con->writequeue_lock);
830out:
831 up_read(&con->sock_sem);
832 return;
833
834send_error:
835 up_read(&con->sock_sem);
836 close_connection(con, false);
837 lowcomms_connect_sock(con);
838 return;
839
840out_connect:
841 up_read(&con->sock_sem);
842 lowcomms_connect_sock(con);
843 return;
844}
845
846static void clean_one_writequeue(struct connection *con)
847{
848 struct list_head *list;
849 struct list_head *temp;
850
851 spin_lock(&con->writequeue_lock);
852 list_for_each_safe(list, temp, &con->writequeue) {
853 struct writequeue_entry *e =
854 list_entry(list, struct writequeue_entry, list);
855 list_del(&e->list);
856 free_entry(e);
857 }
858 spin_unlock(&con->writequeue_lock);
859}
860
861/* Called from recovery when it knows that a node has
862 left the cluster */
863int dlm_lowcomms_close(int nodeid)
864{
865 struct connection *con;
866
867 if (!connections)
868 goto out;
869
870 log_print("closing connection to node %d", nodeid);
871 con = nodeid2con(nodeid, 0);
872 if (con) {
873 clean_one_writequeue(con);
874 close_connection(con, true);
875 atomic_set(&con->waiting_requests, 0);
876 }
877 return 0;
878
879out:
880 return -1;
881}
882
883/* API send message call, may queue the request */
884/* N.B. This is the old interface - use the new one for new calls */
885int lowcomms_send_message(int nodeid, char *buf, int len, gfp_t allocation)
886{
887 struct writequeue_entry *e;
888 char *b;
889
890 e = dlm_lowcomms_get_buffer(nodeid, len, allocation, &b);
891 if (e) {
892 memcpy(b, buf, len);
893 dlm_lowcomms_commit_buffer(e);
894 return 0;
895 }
896 return -ENOBUFS;
897}
898
899/* Look for activity on active sockets */
900static void process_sockets(void)
901{
902 struct list_head *list;
903 struct list_head *temp;
904 int count = 0;
905
906 spin_lock_bh(&read_sockets_lock);
907 list_for_each_safe(list, temp, &read_sockets) {
908
909 struct connection *con =
910 list_entry(list, struct connection, read_list);
911 list_del(&con->read_list);
912 clear_bit(CF_READ_PENDING, &con->flags);
913
914 spin_unlock_bh(&read_sockets_lock);
915
916 /* This can reach zero if we are processing requests
917 * as they come in.
918 */
919 if (atomic_read(&con->waiting_requests) == 0) {
920 spin_lock_bh(&read_sockets_lock);
921 continue;
922 }
923
924 do {
925 con->rx_action(con);
926
927 /* Don't starve out everyone else */
928 if (++count >= MAX_RX_MSG_COUNT) {
929 cond_resched();
930 count = 0;
931 }
932
933 } while (!atomic_dec_and_test(&con->waiting_requests) &&
934 !kthread_should_stop());
935
936 spin_lock_bh(&read_sockets_lock);
937 }
938 spin_unlock_bh(&read_sockets_lock);
939}
940
941/* Try to send any messages that are pending
942 */
943static void process_output_queue(void)
944{
945 struct list_head *list;
946 struct list_head *temp;
947
948 spin_lock_bh(&write_sockets_lock);
949 list_for_each_safe(list, temp, &write_sockets) {
950 struct connection *con =
951 list_entry(list, struct connection, write_list);
952 clear_bit(CF_WRITE_PENDING, &con->flags);
953 list_del(&con->write_list);
954
955 spin_unlock_bh(&write_sockets_lock);
956 send_to_sock(con);
957 spin_lock_bh(&write_sockets_lock);
958 }
959 spin_unlock_bh(&write_sockets_lock);
960}
961
962static void process_state_queue(void)
963{
964 struct list_head *list;
965 struct list_head *temp;
966
967 spin_lock_bh(&state_sockets_lock);
968 list_for_each_safe(list, temp, &state_sockets) {
969 struct connection *con =
970 list_entry(list, struct connection, state_list);
971 list_del(&con->state_list);
972 clear_bit(CF_CONNECT_PENDING, &con->flags);
973 spin_unlock_bh(&state_sockets_lock);
974
975 connect_to_sock(con);
976 spin_lock_bh(&state_sockets_lock);
977 }
978 spin_unlock_bh(&state_sockets_lock);
979}
980
981
982/* Discard all entries on the write queues */
983static void clean_writequeues(void)
984{
985 int nodeid;
986
987 for (nodeid = 1; nodeid < conn_array_size; nodeid++) {
988 struct connection *con = nodeid2con(nodeid, 0);
989
990 if (con)
991 clean_one_writequeue(con);
992 }
993}
994
995static int read_list_empty(void)
996{
997 int status;
998
999 spin_lock_bh(&read_sockets_lock);
1000 status = list_empty(&read_sockets);
1001 spin_unlock_bh(&read_sockets_lock);
1002
1003 return status;
1004}
1005
1006/* DLM Transport comms receive daemon */
1007static int dlm_recvd(void *data)
1008{
1009 init_waitqueue_entry(&lowcomms_recv_waitq_head, current);
1010 add_wait_queue(&lowcomms_recv_waitq, &lowcomms_recv_waitq_head);
1011
1012 while (!kthread_should_stop()) {
1013 set_current_state(TASK_INTERRUPTIBLE);
1014 if (read_list_empty())
1015 cond_resched();
1016 set_current_state(TASK_RUNNING);
1017
1018 process_sockets();
1019 }
1020
1021 return 0;
1022}
1023
1024static int write_and_state_lists_empty(void)
1025{
1026 int status;
1027
1028 spin_lock_bh(&write_sockets_lock);
1029 status = list_empty(&write_sockets);
1030 spin_unlock_bh(&write_sockets_lock);
1031
1032 spin_lock_bh(&state_sockets_lock);
1033 if (list_empty(&state_sockets) == 0)
1034 status = 0;
1035 spin_unlock_bh(&state_sockets_lock);
1036
1037 return status;
1038}
1039
1040/* DLM Transport send daemon */
1041static int dlm_sendd(void *data)
1042{
1043 init_waitqueue_entry(&lowcomms_send_waitq_head, current);
1044 add_wait_queue(&lowcomms_send_waitq, &lowcomms_send_waitq_head);
1045
1046 while (!kthread_should_stop()) {
1047 set_current_state(TASK_INTERRUPTIBLE);
1048 if (write_and_state_lists_empty())
1049 cond_resched();
1050 set_current_state(TASK_RUNNING);
1051
1052 process_state_queue();
1053 process_output_queue();
1054 }
1055
1056 return 0;
1057}
1058
1059static void daemons_stop(void)
1060{
1061 kthread_stop(recv_task);
1062 kthread_stop(send_task);
1063}
1064
1065static int daemons_start(void)
1066{
1067 struct task_struct *p;
1068 int error;
1069
1070 p = kthread_run(dlm_recvd, NULL, "dlm_recvd");
1071 error = IS_ERR(p);
1072 if (error) {
1073 log_print("can't start dlm_recvd %d", error);
1074 return error;
1075 }
1076 recv_task = p;
1077
1078 p = kthread_run(dlm_sendd, NULL, "dlm_sendd");
1079 error = IS_ERR(p);
1080 if (error) {
1081 log_print("can't start dlm_sendd %d", error);
1082 kthread_stop(recv_task);
1083 return error;
1084 }
1085 send_task = p;
1086
1087 return 0;
1088}
1089
1090/*
1091 * Return the largest buffer size we can cope with.
1092 */
1093int lowcomms_max_buffer_size(void)
1094{
1095 return PAGE_CACHE_SIZE;
1096}
1097
1098void dlm_lowcomms_stop(void)
1099{
1100 int i;
1101
1102 /* Set all the flags to prevent any
1103 socket activity.
1104 */
1105 for (i = 0; i < conn_array_size; i++) {
1106 if (connections[i])
1107 connections[i]->flags |= 0xFF;
1108 }
1109
1110 daemons_stop();
1111 clean_writequeues();
1112
1113 for (i = 0; i < conn_array_size; i++) {
1114 if (connections[i]) {
1115 close_connection(connections[i], true);
1116 if (connections[i]->othercon)
1117 kmem_cache_free(con_cache, connections[i]->othercon);
1118 kmem_cache_free(con_cache, connections[i]);
1119 }
1120 }
1121
1122 kfree(connections);
1123 connections = NULL;
1124
1125 kmem_cache_destroy(con_cache);
1126}
1127
1128/* This is quite likely to sleep... */
1129int dlm_lowcomms_start(void)
1130{
1131 int error = 0;
1132
1133 error = -ENOMEM;
1134 connections = kzalloc(sizeof(struct connection *) *
1135 NODE_INCREMENT, GFP_KERNEL);
1136 if (!connections)
1137 goto out;
1138
1139 conn_array_size = NODE_INCREMENT;
1140
1141 if (dlm_our_addr(&dlm_local_addr, 0)) {
1142 log_print("no local IP address has been set");
1143 goto fail_free_conn;
1144 }
1145 if (!dlm_our_addr(&dlm_local_addr, 1)) {
1146 log_print("This dlm comms module does not support multi-homed clustering");
1147 goto fail_free_conn;
1148 }
1149
1150 con_cache = kmem_cache_create("dlm_conn", sizeof(struct connection),
1151 __alignof__(struct connection), 0,
1152 NULL, NULL);
1153 if (!con_cache)
1154 goto fail_free_conn;
1155
1156
1157 /* Start listening */
1158 error = listen_for_all();
1159 if (error)
1160 goto fail_unlisten;
1161
1162 error = daemons_start();
1163 if (error)
1164 goto fail_unlisten;
1165
1166 return 0;
1167
1168fail_unlisten:
1169 close_connection(connections[0], false);
1170 kmem_cache_free(con_cache, connections[0]);
1171 kmem_cache_destroy(con_cache);
1172
1173fail_free_conn:
1174 kfree(connections);
1175
1176out:
1177 return error;
1178}
1179
1180/*
1181 * Overrides for Emacs so that we follow Linus's tabbing style.
1182 * Emacs will notice this stuff at the end of the file and automatically
1183 * adjust the settings for this buffer only. This must remain at the end
1184 * of the file.
1185 * ---------------------------------------------------------------------------
1186 * Local variables:
1187 * c-file-style: "linux"
1188 * End:
1189 */
diff --git a/fs/dlm/lowcomms.h b/fs/dlm/lowcomms.h
index 2d045e0daae1..a9a9618c0d3f 100644
--- a/fs/dlm/lowcomms.h
+++ b/fs/dlm/lowcomms.h
@@ -14,8 +14,6 @@
14#ifndef __LOWCOMMS_DOT_H__ 14#ifndef __LOWCOMMS_DOT_H__
15#define __LOWCOMMS_DOT_H__ 15#define __LOWCOMMS_DOT_H__
16 16
17int dlm_lowcomms_init(void);
18void dlm_lowcomms_exit(void);
19int dlm_lowcomms_start(void); 17int dlm_lowcomms_start(void);
20void dlm_lowcomms_stop(void); 18void dlm_lowcomms_stop(void);
21int dlm_lowcomms_close(int nodeid); 19int dlm_lowcomms_close(int nodeid);
diff --git a/fs/dlm/main.c b/fs/dlm/main.c
index a8da8dc36b2e..162fbae58fe5 100644
--- a/fs/dlm/main.c
+++ b/fs/dlm/main.c
@@ -16,7 +16,6 @@
16#include "lock.h" 16#include "lock.h"
17#include "user.h" 17#include "user.h"
18#include "memory.h" 18#include "memory.h"
19#include "lowcomms.h"
20#include "config.h" 19#include "config.h"
21 20
22#ifdef CONFIG_DLM_DEBUG 21#ifdef CONFIG_DLM_DEBUG
@@ -47,20 +46,14 @@ static int __init init_dlm(void)
47 if (error) 46 if (error)
48 goto out_config; 47 goto out_config;
49 48
50 error = dlm_lowcomms_init();
51 if (error)
52 goto out_debug;
53
54 error = dlm_user_init(); 49 error = dlm_user_init();
55 if (error) 50 if (error)
56 goto out_lowcomms; 51 goto out_debug;
57 52
58 printk("DLM (built %s %s) installed\n", __DATE__, __TIME__); 53 printk("DLM (built %s %s) installed\n", __DATE__, __TIME__);
59 54
60 return 0; 55 return 0;
61 56
62 out_lowcomms:
63 dlm_lowcomms_exit();
64 out_debug: 57 out_debug:
65 dlm_unregister_debugfs(); 58 dlm_unregister_debugfs();
66 out_config: 59 out_config:
@@ -76,7 +69,6 @@ static int __init init_dlm(void)
76static void __exit exit_dlm(void) 69static void __exit exit_dlm(void)
77{ 70{
78 dlm_user_exit(); 71 dlm_user_exit();
79 dlm_lowcomms_exit();
80 dlm_config_exit(); 72 dlm_config_exit();
81 dlm_memory_exit(); 73 dlm_memory_exit();
82 dlm_lockspace_exit(); 74 dlm_lockspace_exit();
diff --git a/fs/dlm/member.c b/fs/dlm/member.c
index a3f7de7f3a8f..85e2897bd740 100644
--- a/fs/dlm/member.c
+++ b/fs/dlm/member.c
@@ -186,6 +186,14 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
186 struct dlm_member *memb, *safe; 186 struct dlm_member *memb, *safe;
187 int i, error, found, pos = 0, neg = 0, low = -1; 187 int i, error, found, pos = 0, neg = 0, low = -1;
188 188
189 /* previously removed members that we've not finished removing need to
190 count as a negative change so the "neg" recovery steps will happen */
191
192 list_for_each_entry(memb, &ls->ls_nodes_gone, list) {
193 log_debug(ls, "prev removed member %d", memb->nodeid);
194 neg++;
195 }
196
189 /* move departed members from ls_nodes to ls_nodes_gone */ 197 /* move departed members from ls_nodes to ls_nodes_gone */
190 198
191 list_for_each_entry_safe(memb, safe, &ls->ls_nodes, list) { 199 list_for_each_entry_safe(memb, safe, &ls->ls_nodes, list) {
diff --git a/fs/dlm/memory.c b/fs/dlm/memory.c
index 989b608fd836..5352b03ff5aa 100644
--- a/fs/dlm/memory.c
+++ b/fs/dlm/memory.c
@@ -15,7 +15,7 @@
15#include "config.h" 15#include "config.h"
16#include "memory.h" 16#include "memory.h"
17 17
18static kmem_cache_t *lkb_cache; 18static struct kmem_cache *lkb_cache;
19 19
20 20
21int dlm_memory_init(void) 21int dlm_memory_init(void)
diff --git a/fs/dlm/rcom.c b/fs/dlm/rcom.c
index 518239a8b1e9..4cc31be9cd9d 100644
--- a/fs/dlm/rcom.c
+++ b/fs/dlm/rcom.c
@@ -90,13 +90,28 @@ static int check_config(struct dlm_ls *ls, struct rcom_config *rf, int nodeid)
90 return 0; 90 return 0;
91} 91}
92 92
93static void allow_sync_reply(struct dlm_ls *ls, uint64_t *new_seq)
94{
95 spin_lock(&ls->ls_rcom_spin);
96 *new_seq = ++ls->ls_rcom_seq;
97 set_bit(LSFL_RCOM_WAIT, &ls->ls_flags);
98 spin_unlock(&ls->ls_rcom_spin);
99}
100
101static void disallow_sync_reply(struct dlm_ls *ls)
102{
103 spin_lock(&ls->ls_rcom_spin);
104 clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags);
105 clear_bit(LSFL_RCOM_READY, &ls->ls_flags);
106 spin_unlock(&ls->ls_rcom_spin);
107}
108
93int dlm_rcom_status(struct dlm_ls *ls, int nodeid) 109int dlm_rcom_status(struct dlm_ls *ls, int nodeid)
94{ 110{
95 struct dlm_rcom *rc; 111 struct dlm_rcom *rc;
96 struct dlm_mhandle *mh; 112 struct dlm_mhandle *mh;
97 int error = 0; 113 int error = 0;
98 114
99 memset(ls->ls_recover_buf, 0, dlm_config.buffer_size);
100 ls->ls_recover_nodeid = nodeid; 115 ls->ls_recover_nodeid = nodeid;
101 116
102 if (nodeid == dlm_our_nodeid()) { 117 if (nodeid == dlm_our_nodeid()) {
@@ -108,12 +123,14 @@ int dlm_rcom_status(struct dlm_ls *ls, int nodeid)
108 error = create_rcom(ls, nodeid, DLM_RCOM_STATUS, 0, &rc, &mh); 123 error = create_rcom(ls, nodeid, DLM_RCOM_STATUS, 0, &rc, &mh);
109 if (error) 124 if (error)
110 goto out; 125 goto out;
111 rc->rc_id = ++ls->ls_rcom_seq; 126
127 allow_sync_reply(ls, &rc->rc_id);
128 memset(ls->ls_recover_buf, 0, dlm_config.buffer_size);
112 129
113 send_rcom(ls, mh, rc); 130 send_rcom(ls, mh, rc);
114 131
115 error = dlm_wait_function(ls, &rcom_response); 132 error = dlm_wait_function(ls, &rcom_response);
116 clear_bit(LSFL_RCOM_READY, &ls->ls_flags); 133 disallow_sync_reply(ls);
117 if (error) 134 if (error)
118 goto out; 135 goto out;
119 136
@@ -150,14 +167,21 @@ static void receive_rcom_status(struct dlm_ls *ls, struct dlm_rcom *rc_in)
150 167
151static void receive_sync_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) 168static void receive_sync_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in)
152{ 169{
153 if (rc_in->rc_id != ls->ls_rcom_seq) { 170 spin_lock(&ls->ls_rcom_spin);
154 log_debug(ls, "reject old reply %d got %llx wanted %llx", 171 if (!test_bit(LSFL_RCOM_WAIT, &ls->ls_flags) ||
155 rc_in->rc_type, rc_in->rc_id, ls->ls_rcom_seq); 172 rc_in->rc_id != ls->ls_rcom_seq) {
156 return; 173 log_debug(ls, "reject reply %d from %d seq %llx expect %llx",
174 rc_in->rc_type, rc_in->rc_header.h_nodeid,
175 (unsigned long long)rc_in->rc_id,
176 (unsigned long long)ls->ls_rcom_seq);
177 goto out;
157 } 178 }
158 memcpy(ls->ls_recover_buf, rc_in, rc_in->rc_header.h_length); 179 memcpy(ls->ls_recover_buf, rc_in, rc_in->rc_header.h_length);
159 set_bit(LSFL_RCOM_READY, &ls->ls_flags); 180 set_bit(LSFL_RCOM_READY, &ls->ls_flags);
181 clear_bit(LSFL_RCOM_WAIT, &ls->ls_flags);
160 wake_up(&ls->ls_wait_general); 182 wake_up(&ls->ls_wait_general);
183 out:
184 spin_unlock(&ls->ls_rcom_spin);
161} 185}
162 186
163static void receive_rcom_status_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in) 187static void receive_rcom_status_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in)
@@ -171,7 +195,6 @@ int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len)
171 struct dlm_mhandle *mh; 195 struct dlm_mhandle *mh;
172 int error = 0, len = sizeof(struct dlm_rcom); 196 int error = 0, len = sizeof(struct dlm_rcom);
173 197
174 memset(ls->ls_recover_buf, 0, dlm_config.buffer_size);
175 ls->ls_recover_nodeid = nodeid; 198 ls->ls_recover_nodeid = nodeid;
176 199
177 if (nodeid == dlm_our_nodeid()) { 200 if (nodeid == dlm_our_nodeid()) {
@@ -185,12 +208,14 @@ int dlm_rcom_names(struct dlm_ls *ls, int nodeid, char *last_name, int last_len)
185 if (error) 208 if (error)
186 goto out; 209 goto out;
187 memcpy(rc->rc_buf, last_name, last_len); 210 memcpy(rc->rc_buf, last_name, last_len);
188 rc->rc_id = ++ls->ls_rcom_seq; 211
212 allow_sync_reply(ls, &rc->rc_id);
213 memset(ls->ls_recover_buf, 0, dlm_config.buffer_size);
189 214
190 send_rcom(ls, mh, rc); 215 send_rcom(ls, mh, rc);
191 216
192 error = dlm_wait_function(ls, &rcom_response); 217 error = dlm_wait_function(ls, &rcom_response);
193 clear_bit(LSFL_RCOM_READY, &ls->ls_flags); 218 disallow_sync_reply(ls);
194 out: 219 out:
195 return error; 220 return error;
196} 221}
@@ -370,9 +395,10 @@ static void receive_rcom_lock_reply(struct dlm_ls *ls, struct dlm_rcom *rc_in)
370static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in) 395static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
371{ 396{
372 struct dlm_rcom *rc; 397 struct dlm_rcom *rc;
398 struct rcom_config *rf;
373 struct dlm_mhandle *mh; 399 struct dlm_mhandle *mh;
374 char *mb; 400 char *mb;
375 int mb_len = sizeof(struct dlm_rcom); 401 int mb_len = sizeof(struct dlm_rcom) + sizeof(struct rcom_config);
376 402
377 mh = dlm_lowcomms_get_buffer(nodeid, mb_len, GFP_KERNEL, &mb); 403 mh = dlm_lowcomms_get_buffer(nodeid, mb_len, GFP_KERNEL, &mb);
378 if (!mh) 404 if (!mh)
@@ -391,6 +417,9 @@ static int send_ls_not_ready(int nodeid, struct dlm_rcom *rc_in)
391 rc->rc_id = rc_in->rc_id; 417 rc->rc_id = rc_in->rc_id;
392 rc->rc_result = -ESRCH; 418 rc->rc_result = -ESRCH;
393 419
420 rf = (struct rcom_config *) rc->rc_buf;
421 rf->rf_lvblen = -1;
422
394 dlm_rcom_out(rc); 423 dlm_rcom_out(rc);
395 dlm_lowcomms_commit_buffer(mh); 424 dlm_lowcomms_commit_buffer(mh);
396 425
@@ -412,9 +441,10 @@ void dlm_receive_rcom(struct dlm_header *hd, int nodeid)
412 441
413 ls = dlm_find_lockspace_global(hd->h_lockspace); 442 ls = dlm_find_lockspace_global(hd->h_lockspace);
414 if (!ls) { 443 if (!ls) {
415 log_print("lockspace %x from %d not found", 444 log_print("lockspace %x from %d type %x not found",
416 hd->h_lockspace, nodeid); 445 hd->h_lockspace, nodeid, rc->rc_type);
417 send_ls_not_ready(nodeid, rc); 446 if (rc->rc_type == DLM_RCOM_STATUS)
447 send_ls_not_ready(nodeid, rc);
418 return; 448 return;
419 } 449 }
420 450
diff --git a/fs/dlm/recover.c b/fs/dlm/recover.c
index a5e6d184872e..cf9f6831bab5 100644
--- a/fs/dlm/recover.c
+++ b/fs/dlm/recover.c
@@ -252,6 +252,7 @@ static void recover_list_clear(struct dlm_ls *ls)
252 spin_lock(&ls->ls_recover_list_lock); 252 spin_lock(&ls->ls_recover_list_lock);
253 list_for_each_entry_safe(r, s, &ls->ls_recover_list, res_recover_list) { 253 list_for_each_entry_safe(r, s, &ls->ls_recover_list, res_recover_list) {
254 list_del_init(&r->res_recover_list); 254 list_del_init(&r->res_recover_list);
255 r->res_recover_locks_count = 0;
255 dlm_put_rsb(r); 256 dlm_put_rsb(r);
256 ls->ls_recover_list_count--; 257 ls->ls_recover_list_count--;
257 } 258 }
diff --git a/fs/dlm/recoverd.c b/fs/dlm/recoverd.c
index 362e3eff4dc9..650536aa5139 100644
--- a/fs/dlm/recoverd.c
+++ b/fs/dlm/recoverd.c
@@ -45,7 +45,7 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
45 unsigned long start; 45 unsigned long start;
46 int error, neg = 0; 46 int error, neg = 0;
47 47
48 log_debug(ls, "recover %llx", rv->seq); 48 log_debug(ls, "recover %llx", (unsigned long long)rv->seq);
49 49
50 mutex_lock(&ls->ls_recoverd_active); 50 mutex_lock(&ls->ls_recoverd_active);
51 51
@@ -94,14 +94,6 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
94 } 94 }
95 95
96 /* 96 /*
97 * Purge directory-related requests that are saved in requestqueue.
98 * All dir requests from before recovery are invalid now due to the dir
99 * rebuild and will be resent by the requesting nodes.
100 */
101
102 dlm_purge_requestqueue(ls);
103
104 /*
105 * Wait for all nodes to complete directory rebuild. 97 * Wait for all nodes to complete directory rebuild.
106 */ 98 */
107 99
@@ -164,10 +156,31 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
164 */ 156 */
165 157
166 dlm_recover_rsbs(ls); 158 dlm_recover_rsbs(ls);
159 } else {
160 /*
161 * Other lockspace members may be going through the "neg" steps
162 * while also adding us to the lockspace, in which case they'll
163 * be doing the recover_locks (RS_LOCKS) barrier.
164 */
165 dlm_set_recover_status(ls, DLM_RS_LOCKS);
166
167 error = dlm_recover_locks_wait(ls);
168 if (error) {
169 log_error(ls, "recover_locks_wait failed %d", error);
170 goto fail;
171 }
167 } 172 }
168 173
169 dlm_release_root_list(ls); 174 dlm_release_root_list(ls);
170 175
176 /*
177 * Purge directory-related requests that are saved in requestqueue.
178 * All dir requests from before recovery are invalid now due to the dir
179 * rebuild and will be resent by the requesting nodes.
180 */
181
182 dlm_purge_requestqueue(ls);
183
171 dlm_set_recover_status(ls, DLM_RS_DONE); 184 dlm_set_recover_status(ls, DLM_RS_DONE);
172 error = dlm_recover_done_wait(ls); 185 error = dlm_recover_done_wait(ls);
173 if (error) { 186 if (error) {
@@ -199,7 +212,8 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
199 212
200 dlm_astd_wake(); 213 dlm_astd_wake();
201 214
202 log_debug(ls, "recover %llx done: %u ms", rv->seq, 215 log_debug(ls, "recover %llx done: %u ms",
216 (unsigned long long)rv->seq,
203 jiffies_to_msecs(jiffies - start)); 217 jiffies_to_msecs(jiffies - start));
204 mutex_unlock(&ls->ls_recoverd_active); 218 mutex_unlock(&ls->ls_recoverd_active);
205 219
@@ -207,11 +221,16 @@ static int ls_recover(struct dlm_ls *ls, struct dlm_recover *rv)
207 221
208 fail: 222 fail:
209 dlm_release_root_list(ls); 223 dlm_release_root_list(ls);
210 log_debug(ls, "recover %llx error %d", rv->seq, error); 224 log_debug(ls, "recover %llx error %d",
225 (unsigned long long)rv->seq, error);
211 mutex_unlock(&ls->ls_recoverd_active); 226 mutex_unlock(&ls->ls_recoverd_active);
212 return error; 227 return error;
213} 228}
214 229
230/* The dlm_ls_start() that created the rv we take here may already have been
231 stopped via dlm_ls_stop(); in that case we need to leave the RECOVERY_STOP
232 flag set. */
233
215static void do_ls_recovery(struct dlm_ls *ls) 234static void do_ls_recovery(struct dlm_ls *ls)
216{ 235{
217 struct dlm_recover *rv = NULL; 236 struct dlm_recover *rv = NULL;
@@ -219,7 +238,8 @@ static void do_ls_recovery(struct dlm_ls *ls)
219 spin_lock(&ls->ls_recover_lock); 238 spin_lock(&ls->ls_recover_lock);
220 rv = ls->ls_recover_args; 239 rv = ls->ls_recover_args;
221 ls->ls_recover_args = NULL; 240 ls->ls_recover_args = NULL;
222 clear_bit(LSFL_RECOVERY_STOP, &ls->ls_flags); 241 if (rv && ls->ls_recover_seq == rv->seq)
242 clear_bit(LSFL_RECOVERY_STOP, &ls->ls_flags);
223 spin_unlock(&ls->ls_recover_lock); 243 spin_unlock(&ls->ls_recover_lock);
224 244
225 if (rv) { 245 if (rv) {
diff --git a/fs/dlm/requestqueue.c b/fs/dlm/requestqueue.c
index 7b2b089634a2..65008d79c96d 100644
--- a/fs/dlm/requestqueue.c
+++ b/fs/dlm/requestqueue.c
@@ -30,26 +30,36 @@ struct rq_entry {
30 * lockspace is enabled on some while still suspended on others. 30 * lockspace is enabled on some while still suspended on others.
31 */ 31 */
32 32
33void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd) 33int dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd)
34{ 34{
35 struct rq_entry *e; 35 struct rq_entry *e;
36 int length = hd->h_length; 36 int length = hd->h_length;
37 37 int rv = 0;
38 if (dlm_is_removed(ls, nodeid))
39 return;
40 38
41 e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL); 39 e = kmalloc(sizeof(struct rq_entry) + length, GFP_KERNEL);
42 if (!e) { 40 if (!e) {
43 log_print("dlm_add_requestqueue: out of memory\n"); 41 log_print("dlm_add_requestqueue: out of memory\n");
44 return; 42 return 0;
45 } 43 }
46 44
47 e->nodeid = nodeid; 45 e->nodeid = nodeid;
48 memcpy(e->request, hd, length); 46 memcpy(e->request, hd, length);
49 47
48 /* We need to check dlm_locking_stopped() after taking the mutex to
49 avoid a race where dlm_recoverd enables locking and runs
50 process_requestqueue between our earlier dlm_locking_stopped check
51 and this addition to the requestqueue. */
52
50 mutex_lock(&ls->ls_requestqueue_mutex); 53 mutex_lock(&ls->ls_requestqueue_mutex);
51 list_add_tail(&e->list, &ls->ls_requestqueue); 54 if (dlm_locking_stopped(ls))
55 list_add_tail(&e->list, &ls->ls_requestqueue);
56 else {
57 log_debug(ls, "dlm_add_requestqueue skip from %d", nodeid);
58 kfree(e);
59 rv = -EAGAIN;
60 }
52 mutex_unlock(&ls->ls_requestqueue_mutex); 61 mutex_unlock(&ls->ls_requestqueue_mutex);
62 return rv;
53} 63}
54 64
55int dlm_process_requestqueue(struct dlm_ls *ls) 65int dlm_process_requestqueue(struct dlm_ls *ls)
@@ -120,6 +130,10 @@ static int purge_request(struct dlm_ls *ls, struct dlm_message *ms, int nodeid)
120{ 130{
121 uint32_t type = ms->m_type; 131 uint32_t type = ms->m_type;
122 132
133 /* the ls is being cleaned up and freed by release_lockspace */
134 if (!ls->ls_count)
135 return 1;
136
123 if (dlm_is_removed(ls, nodeid)) 137 if (dlm_is_removed(ls, nodeid))
124 return 1; 138 return 1;
125 139
diff --git a/fs/dlm/requestqueue.h b/fs/dlm/requestqueue.h
index 349f0d292d95..6a53ea03335d 100644
--- a/fs/dlm/requestqueue.h
+++ b/fs/dlm/requestqueue.h
@@ -13,7 +13,7 @@
13#ifndef __REQUESTQUEUE_DOT_H__ 13#ifndef __REQUESTQUEUE_DOT_H__
14#define __REQUESTQUEUE_DOT_H__ 14#define __REQUESTQUEUE_DOT_H__
15 15
16void dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd); 16int dlm_add_requestqueue(struct dlm_ls *ls, int nodeid, struct dlm_header *hd);
17int dlm_process_requestqueue(struct dlm_ls *ls); 17int dlm_process_requestqueue(struct dlm_ls *ls);
18void dlm_wait_requestqueue(struct dlm_ls *ls); 18void dlm_wait_requestqueue(struct dlm_ls *ls);
19void dlm_purge_requestqueue(struct dlm_ls *ls); 19void dlm_purge_requestqueue(struct dlm_ls *ls);
diff --git a/fs/dnotify.c b/fs/dnotify.c
index 2b0442db67e0..1f26a2b9eee1 100644
--- a/fs/dnotify.c
+++ b/fs/dnotify.c
@@ -23,7 +23,7 @@
23 23
24int dir_notify_enable __read_mostly = 1; 24int dir_notify_enable __read_mostly = 1;
25 25
26static kmem_cache_t *dn_cache __read_mostly; 26static struct kmem_cache *dn_cache __read_mostly;
27 27
28static void redo_inode_mask(struct inode *inode) 28static void redo_inode_mask(struct inode *inode)
29{ 29{
@@ -77,7 +77,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
77 inode = filp->f_dentry->d_inode; 77 inode = filp->f_dentry->d_inode;
78 if (!S_ISDIR(inode->i_mode)) 78 if (!S_ISDIR(inode->i_mode))
79 return -ENOTDIR; 79 return -ENOTDIR;
80 dn = kmem_cache_alloc(dn_cache, SLAB_KERNEL); 80 dn = kmem_cache_alloc(dn_cache, GFP_KERNEL);
81 if (dn == NULL) 81 if (dn == NULL)
82 return -ENOMEM; 82 return -ENOMEM;
83 spin_lock(&inode->i_lock); 83 spin_lock(&inode->i_lock);
diff --git a/fs/dquot.c b/fs/dquot.c
index 9af789567e51..f9cd5e23ebdf 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -131,7 +131,7 @@ static struct quota_format_type *quota_formats; /* List of registered formats */
131static struct quota_module_name module_names[] = INIT_QUOTA_MODULE_NAMES; 131static struct quota_module_name module_names[] = INIT_QUOTA_MODULE_NAMES;
132 132
133/* SLAB cache for dquot structures */ 133/* SLAB cache for dquot structures */
134static kmem_cache_t *dquot_cachep; 134static struct kmem_cache *dquot_cachep;
135 135
136int register_quota_format(struct quota_format_type *fmt) 136int register_quota_format(struct quota_format_type *fmt)
137{ 137{
@@ -600,7 +600,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
600{ 600{
601 struct dquot *dquot; 601 struct dquot *dquot;
602 602
603 dquot = kmem_cache_alloc(dquot_cachep, SLAB_NOFS); 603 dquot = kmem_cache_alloc(dquot_cachep, GFP_NOFS);
604 if(!dquot) 604 if(!dquot)
605 return NODQUOT; 605 return NODQUOT;
606 606
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index f63a7755fe86..7196f50fe152 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -628,7 +628,7 @@ int ecryptfs_decrypt_page(struct file *file, struct page *page)
628 num_extents_per_page = PAGE_CACHE_SIZE / crypt_stat->extent_size; 628 num_extents_per_page = PAGE_CACHE_SIZE / crypt_stat->extent_size;
629 base_extent = (page->index * num_extents_per_page); 629 base_extent = (page->index * num_extents_per_page);
630 lower_page_virt = kmem_cache_alloc(ecryptfs_lower_page_cache, 630 lower_page_virt = kmem_cache_alloc(ecryptfs_lower_page_cache,
631 SLAB_KERNEL); 631 GFP_KERNEL);
632 if (!lower_page_virt) { 632 if (!lower_page_virt) {
633 rc = -ENOMEM; 633 rc = -ENOMEM;
634 ecryptfs_printk(KERN_ERR, "Error getting page for encrypted " 634 ecryptfs_printk(KERN_ERR, "Error getting page for encrypted "
@@ -1334,7 +1334,7 @@ int ecryptfs_write_headers(struct dentry *ecryptfs_dentry,
1334 goto out; 1334 goto out;
1335 } 1335 }
1336 /* Released in this function */ 1336 /* Released in this function */
1337 page_virt = kmem_cache_alloc(ecryptfs_header_cache_0, SLAB_USER); 1337 page_virt = kmem_cache_alloc(ecryptfs_header_cache_0, GFP_USER);
1338 if (!page_virt) { 1338 if (!page_virt) {
1339 ecryptfs_printk(KERN_ERR, "Out of memory\n"); 1339 ecryptfs_printk(KERN_ERR, "Out of memory\n");
1340 rc = -ENOMEM; 1340 rc = -ENOMEM;
@@ -1493,7 +1493,7 @@ int ecryptfs_read_headers(struct dentry *ecryptfs_dentry,
1493 &ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->crypt_stat; 1493 &ecryptfs_inode_to_private(ecryptfs_dentry->d_inode)->crypt_stat;
1494 1494
1495 /* Read the first page from the underlying file */ 1495 /* Read the first page from the underlying file */
1496 page_virt = kmem_cache_alloc(ecryptfs_header_cache_1, SLAB_USER); 1496 page_virt = kmem_cache_alloc(ecryptfs_header_cache_1, GFP_USER);
1497 if (!page_virt) { 1497 if (!page_virt) {
1498 rc = -ENOMEM; 1498 rc = -ENOMEM;
1499 ecryptfs_printk(KERN_ERR, "Unable to allocate page_virt\n"); 1499 ecryptfs_printk(KERN_ERR, "Unable to allocate page_virt\n");
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index a92ef05eff8f..42099e779a56 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -250,7 +250,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
250 int lower_flags; 250 int lower_flags;
251 251
252 /* Released in ecryptfs_release or end of function if failure */ 252 /* Released in ecryptfs_release or end of function if failure */
253 file_info = kmem_cache_alloc(ecryptfs_file_info_cache, SLAB_KERNEL); 253 file_info = kmem_cache_alloc(ecryptfs_file_info_cache, GFP_KERNEL);
254 ecryptfs_set_file_private(file, file_info); 254 ecryptfs_set_file_private(file, file_info);
255 if (!file_info) { 255 if (!file_info) {
256 ecryptfs_printk(KERN_ERR, 256 ecryptfs_printk(KERN_ERR,
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index dfcc68484f47..8a1945a84c36 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -369,7 +369,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
369 BUG_ON(!atomic_read(&lower_dentry->d_count)); 369 BUG_ON(!atomic_read(&lower_dentry->d_count));
370 ecryptfs_set_dentry_private(dentry, 370 ecryptfs_set_dentry_private(dentry,
371 kmem_cache_alloc(ecryptfs_dentry_info_cache, 371 kmem_cache_alloc(ecryptfs_dentry_info_cache,
372 SLAB_KERNEL)); 372 GFP_KERNEL));
373 if (!ecryptfs_dentry_to_private(dentry)) { 373 if (!ecryptfs_dentry_to_private(dentry)) {
374 rc = -ENOMEM; 374 rc = -ENOMEM;
375 ecryptfs_printk(KERN_ERR, "Out of memory whilst attempting " 375 ecryptfs_printk(KERN_ERR, "Out of memory whilst attempting "
@@ -404,7 +404,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
404 /* Released in this function */ 404 /* Released in this function */
405 page_virt = 405 page_virt =
406 (char *)kmem_cache_alloc(ecryptfs_header_cache_2, 406 (char *)kmem_cache_alloc(ecryptfs_header_cache_2,
407 SLAB_USER); 407 GFP_USER);
408 if (!page_virt) { 408 if (!page_virt) {
409 rc = -ENOMEM; 409 rc = -ENOMEM;
410 ecryptfs_printk(KERN_ERR, 410 ecryptfs_printk(KERN_ERR,
@@ -795,7 +795,7 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
795 /* Released at out_free: label */ 795 /* Released at out_free: label */
796 ecryptfs_set_file_private(&fake_ecryptfs_file, 796 ecryptfs_set_file_private(&fake_ecryptfs_file,
797 kmem_cache_alloc(ecryptfs_file_info_cache, 797 kmem_cache_alloc(ecryptfs_file_info_cache,
798 SLAB_KERNEL)); 798 GFP_KERNEL));
799 if (unlikely(!ecryptfs_file_to_private(&fake_ecryptfs_file))) { 799 if (unlikely(!ecryptfs_file_to_private(&fake_ecryptfs_file))) {
800 rc = -ENOMEM; 800 rc = -ENOMEM;
801 goto out; 801 goto out;
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index c3746f56d162..745c0f1bfbbd 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -207,7 +207,7 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat,
207 /* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or 207 /* Released: wipe_auth_tok_list called in ecryptfs_parse_packet_set or
208 * at end of function upon failure */ 208 * at end of function upon failure */
209 auth_tok_list_item = 209 auth_tok_list_item =
210 kmem_cache_alloc(ecryptfs_auth_tok_list_item_cache, SLAB_KERNEL); 210 kmem_cache_alloc(ecryptfs_auth_tok_list_item_cache, GFP_KERNEL);
211 if (!auth_tok_list_item) { 211 if (!auth_tok_list_item) {
212 ecryptfs_printk(KERN_ERR, "Unable to allocate memory\n"); 212 ecryptfs_printk(KERN_ERR, "Unable to allocate memory\n");
213 rc = -ENOMEM; 213 rc = -ENOMEM;
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index a78d87d14baf..3ede12b25933 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -378,7 +378,7 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
378 /* Released in ecryptfs_put_super() */ 378 /* Released in ecryptfs_put_super() */
379 ecryptfs_set_superblock_private(sb, 379 ecryptfs_set_superblock_private(sb,
380 kmem_cache_alloc(ecryptfs_sb_info_cache, 380 kmem_cache_alloc(ecryptfs_sb_info_cache,
381 SLAB_KERNEL)); 381 GFP_KERNEL));
382 if (!ecryptfs_superblock_to_private(sb)) { 382 if (!ecryptfs_superblock_to_private(sb)) {
383 ecryptfs_printk(KERN_WARNING, "Out of memory\n"); 383 ecryptfs_printk(KERN_WARNING, "Out of memory\n");
384 rc = -ENOMEM; 384 rc = -ENOMEM;
@@ -402,7 +402,7 @@ ecryptfs_fill_super(struct super_block *sb, void *raw_data, int silent)
402 /* through deactivate_super(sb) from get_sb_nodev() */ 402 /* through deactivate_super(sb) from get_sb_nodev() */
403 ecryptfs_set_dentry_private(sb->s_root, 403 ecryptfs_set_dentry_private(sb->s_root,
404 kmem_cache_alloc(ecryptfs_dentry_info_cache, 404 kmem_cache_alloc(ecryptfs_dentry_info_cache,
405 SLAB_KERNEL)); 405 GFP_KERNEL));
406 if (!ecryptfs_dentry_to_private(sb->s_root)) { 406 if (!ecryptfs_dentry_to_private(sb->s_root)) {
407 ecryptfs_printk(KERN_ERR, 407 ecryptfs_printk(KERN_ERR,
408 "dentry_info_cache alloc failed\n"); 408 "dentry_info_cache alloc failed\n");
@@ -546,7 +546,7 @@ inode_info_init_once(void *vptr, struct kmem_cache *cachep, unsigned long flags)
546} 546}
547 547
548static struct ecryptfs_cache_info { 548static struct ecryptfs_cache_info {
549 kmem_cache_t **cache; 549 struct kmem_cache **cache;
550 const char *name; 550 const char *name;
551 size_t size; 551 size_t size;
552 void (*ctor)(void*, struct kmem_cache *, unsigned long); 552 void (*ctor)(void*, struct kmem_cache *, unsigned long);
@@ -691,7 +691,7 @@ static ssize_t version_show(struct ecryptfs_obj *obj, char *buff)
691 691
692static struct ecryptfs_attribute sysfs_attr_version = __ATTR_RO(version); 692static struct ecryptfs_attribute sysfs_attr_version = __ATTR_RO(version);
693 693
694struct ecryptfs_version_str_map_elem { 694static struct ecryptfs_version_str_map_elem {
695 u32 flag; 695 u32 flag;
696 char *str; 696 char *str;
697} ecryptfs_version_str_map[] = { 697} ecryptfs_version_str_map[] = {
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c
index 825757ae4867..eaa5daaf106e 100644
--- a/fs/ecryptfs/super.c
+++ b/fs/ecryptfs/super.c
@@ -50,7 +50,7 @@ static struct inode *ecryptfs_alloc_inode(struct super_block *sb)
50 struct inode *inode = NULL; 50 struct inode *inode = NULL;
51 51
52 ecryptfs_inode = kmem_cache_alloc(ecryptfs_inode_info_cache, 52 ecryptfs_inode = kmem_cache_alloc(ecryptfs_inode_info_cache,
53 SLAB_KERNEL); 53 GFP_KERNEL);
54 if (unlikely(!ecryptfs_inode)) 54 if (unlikely(!ecryptfs_inode))
55 goto out; 55 goto out;
56 ecryptfs_init_crypt_stat(&ecryptfs_inode->crypt_stat); 56 ecryptfs_init_crypt_stat(&ecryptfs_inode->crypt_stat);
diff --git a/fs/efs/super.c b/fs/efs/super.c
index b3f50651eb6b..dfebf21289f4 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -52,12 +52,12 @@ static struct pt_types sgi_pt_types[] = {
52}; 52};
53 53
54 54
55static kmem_cache_t * efs_inode_cachep; 55static struct kmem_cache * efs_inode_cachep;
56 56
57static struct inode *efs_alloc_inode(struct super_block *sb) 57static struct inode *efs_alloc_inode(struct super_block *sb)
58{ 58{
59 struct efs_inode_info *ei; 59 struct efs_inode_info *ei;
60 ei = (struct efs_inode_info *)kmem_cache_alloc(efs_inode_cachep, SLAB_KERNEL); 60 ei = (struct efs_inode_info *)kmem_cache_alloc(efs_inode_cachep, GFP_KERNEL);
61 if (!ei) 61 if (!ei)
62 return NULL; 62 return NULL;
63 return &ei->vfs_inode; 63 return &ei->vfs_inode;
@@ -68,7 +68,7 @@ static void efs_destroy_inode(struct inode *inode)
68 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); 68 kmem_cache_free(efs_inode_cachep, INODE_INFO(inode));
69} 69}
70 70
71static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 71static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
72{ 72{
73 struct efs_inode_info *ei = (struct efs_inode_info *) foo; 73 struct efs_inode_info *ei = (struct efs_inode_info *) foo;
74 74
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index ae228ec54e94..88a6f8d0b88e 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -283,10 +283,10 @@ static struct mutex epmutex;
283static struct poll_safewake psw; 283static struct poll_safewake psw;
284 284
285/* Slab cache used to allocate "struct epitem" */ 285/* Slab cache used to allocate "struct epitem" */
286static kmem_cache_t *epi_cache __read_mostly; 286static struct kmem_cache *epi_cache __read_mostly;
287 287
288/* Slab cache used to allocate "struct eppoll_entry" */ 288/* Slab cache used to allocate "struct eppoll_entry" */
289static kmem_cache_t *pwq_cache __read_mostly; 289static struct kmem_cache *pwq_cache __read_mostly;
290 290
291/* Virtual fs used to allocate inodes for eventpoll files */ 291/* Virtual fs used to allocate inodes for eventpoll files */
292static struct vfsmount *eventpoll_mnt __read_mostly; 292static struct vfsmount *eventpoll_mnt __read_mostly;
@@ -961,7 +961,7 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
961 struct epitem *epi = ep_item_from_epqueue(pt); 961 struct epitem *epi = ep_item_from_epqueue(pt);
962 struct eppoll_entry *pwq; 962 struct eppoll_entry *pwq;
963 963
964 if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, SLAB_KERNEL))) { 964 if (epi->nwait >= 0 && (pwq = kmem_cache_alloc(pwq_cache, GFP_KERNEL))) {
965 init_waitqueue_func_entry(&pwq->wait, ep_poll_callback); 965 init_waitqueue_func_entry(&pwq->wait, ep_poll_callback);
966 pwq->whead = whead; 966 pwq->whead = whead;
967 pwq->base = epi; 967 pwq->base = epi;
@@ -1004,7 +1004,7 @@ static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
1004 struct ep_pqueue epq; 1004 struct ep_pqueue epq;
1005 1005
1006 error = -ENOMEM; 1006 error = -ENOMEM;
1007 if (!(epi = kmem_cache_alloc(epi_cache, SLAB_KERNEL))) 1007 if (!(epi = kmem_cache_alloc(epi_cache, GFP_KERNEL)))
1008 goto eexit_1; 1008 goto eexit_1;
1009 1009
1010 /* Item initialization follow here ... */ 1010 /* Item initialization follow here ... */
diff --git a/fs/exec.c b/fs/exec.c
index d993ea1a81ae..add0e03c3ea9 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -404,7 +404,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
404 bprm->loader += stack_base; 404 bprm->loader += stack_base;
405 bprm->exec += stack_base; 405 bprm->exec += stack_base;
406 406
407 mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 407 mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
408 if (!mpnt) 408 if (!mpnt)
409 return -ENOMEM; 409 return -ENOMEM;
410 410
@@ -1515,7 +1515,8 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1515 ispipe = 1; 1515 ispipe = 1;
1516 } else 1516 } else
1517 file = filp_open(corename, 1517 file = filp_open(corename,
1518 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE, 0600); 1518 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
1519 0600);
1519 if (IS_ERR(file)) 1520 if (IS_ERR(file))
1520 goto fail_unlock; 1521 goto fail_unlock;
1521 inode = file->f_dentry->d_inode; 1522 inode = file->f_dentry->d_inode;
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index 1dfba77eab10..e3cf8c81507f 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -44,6 +44,7 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
44 if (!S_ISDIR(inode->i_mode)) 44 if (!S_ISDIR(inode->i_mode))
45 flags &= ~EXT2_DIRSYNC_FL; 45 flags &= ~EXT2_DIRSYNC_FL;
46 46
47 mutex_lock(&inode->i_mutex);
47 oldflags = ei->i_flags; 48 oldflags = ei->i_flags;
48 49
49 /* 50 /*
@@ -53,13 +54,16 @@ int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
53 * This test looks nicer. Thanks to Pauline Middelink 54 * This test looks nicer. Thanks to Pauline Middelink
54 */ 55 */
55 if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) { 56 if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
56 if (!capable(CAP_LINUX_IMMUTABLE)) 57 if (!capable(CAP_LINUX_IMMUTABLE)) {
58 mutex_unlock(&inode->i_mutex);
57 return -EPERM; 59 return -EPERM;
60 }
58 } 61 }
59 62
60 flags = flags & EXT2_FL_USER_MODIFIABLE; 63 flags = flags & EXT2_FL_USER_MODIFIABLE;
61 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE; 64 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
62 ei->i_flags = flags; 65 ei->i_flags = flags;
66 mutex_unlock(&inode->i_mutex);
63 67
64 ext2_set_inode_flags(inode); 68 ext2_set_inode_flags(inode);
65 inode->i_ctime = CURRENT_TIME_SEC; 69 inode->i_ctime = CURRENT_TIME_SEC;
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index d8b9abd95d07..255cef5f7420 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -135,12 +135,12 @@ static void ext2_put_super (struct super_block * sb)
135 return; 135 return;
136} 136}
137 137
138static kmem_cache_t * ext2_inode_cachep; 138static struct kmem_cache * ext2_inode_cachep;
139 139
140static struct inode *ext2_alloc_inode(struct super_block *sb) 140static struct inode *ext2_alloc_inode(struct super_block *sb)
141{ 141{
142 struct ext2_inode_info *ei; 142 struct ext2_inode_info *ei;
143 ei = (struct ext2_inode_info *)kmem_cache_alloc(ext2_inode_cachep, SLAB_KERNEL); 143 ei = (struct ext2_inode_info *)kmem_cache_alloc(ext2_inode_cachep, GFP_KERNEL);
144 if (!ei) 144 if (!ei)
145 return NULL; 145 return NULL;
146#ifdef CONFIG_EXT2_FS_POSIX_ACL 146#ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -156,7 +156,7 @@ static void ext2_destroy_inode(struct inode *inode)
156 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); 156 kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
157} 157}
158 158
159static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 159static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
160{ 160{
161 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo; 161 struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
162 162
@@ -1090,8 +1090,10 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1090{ 1090{
1091 struct super_block *sb = dentry->d_sb; 1091 struct super_block *sb = dentry->d_sb;
1092 struct ext2_sb_info *sbi = EXT2_SB(sb); 1092 struct ext2_sb_info *sbi = EXT2_SB(sb);
1093 struct ext2_super_block *es = sbi->s_es;
1093 unsigned long overhead; 1094 unsigned long overhead;
1094 int i; 1095 int i;
1096 u64 fsid;
1095 1097
1096 if (test_opt (sb, MINIX_DF)) 1098 if (test_opt (sb, MINIX_DF))
1097 overhead = 0; 1099 overhead = 0;
@@ -1104,7 +1106,7 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1104 * All of the blocks before first_data_block are 1106 * All of the blocks before first_data_block are
1105 * overhead 1107 * overhead
1106 */ 1108 */
1107 overhead = le32_to_cpu(sbi->s_es->s_first_data_block); 1109 overhead = le32_to_cpu(es->s_first_data_block);
1108 1110
1109 /* 1111 /*
1110 * Add the overhead attributed to the superblock and 1112 * Add the overhead attributed to the superblock and
@@ -1125,14 +1127,18 @@ static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
1125 1127
1126 buf->f_type = EXT2_SUPER_MAGIC; 1128 buf->f_type = EXT2_SUPER_MAGIC;
1127 buf->f_bsize = sb->s_blocksize; 1129 buf->f_bsize = sb->s_blocksize;
1128 buf->f_blocks = le32_to_cpu(sbi->s_es->s_blocks_count) - overhead; 1130 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
1129 buf->f_bfree = ext2_count_free_blocks(sb); 1131 buf->f_bfree = ext2_count_free_blocks(sb);
1130 buf->f_bavail = buf->f_bfree - le32_to_cpu(sbi->s_es->s_r_blocks_count); 1132 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
1131 if (buf->f_bfree < le32_to_cpu(sbi->s_es->s_r_blocks_count)) 1133 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
1132 buf->f_bavail = 0; 1134 buf->f_bavail = 0;
1133 buf->f_files = le32_to_cpu(sbi->s_es->s_inodes_count); 1135 buf->f_files = le32_to_cpu(es->s_inodes_count);
1134 buf->f_ffree = ext2_count_free_inodes (sb); 1136 buf->f_ffree = ext2_count_free_inodes(sb);
1135 buf->f_namelen = EXT2_NAME_LEN; 1137 buf->f_namelen = EXT2_NAME_LEN;
1138 fsid = le64_to_cpup((void *)es->s_uuid) ^
1139 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
1140 buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
1141 buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
1136 return 0; 1142 return 0;
1137} 1143}
1138 1144
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index af52a7f8b291..247efd0b51d6 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -342,12 +342,9 @@ static void ext2_xattr_update_super_block(struct super_block *sb)
342 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR)) 342 if (EXT2_HAS_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR))
343 return; 343 return;
344 344
345 lock_super(sb); 345 EXT2_SET_COMPAT_FEATURE(sb, EXT2_FEATURE_COMPAT_EXT_ATTR);
346 EXT2_SB(sb)->s_es->s_feature_compat |=
347 cpu_to_le32(EXT2_FEATURE_COMPAT_EXT_ATTR);
348 sb->s_dirt = 1; 346 sb->s_dirt = 1;
349 mark_buffer_dirty(EXT2_SB(sb)->s_sbh); 347 mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
350 unlock_super(sb);
351} 348}
352 349
353/* 350/*
diff --git a/fs/ext3/Makefile b/fs/ext3/Makefile
index 704cd44a40c2..e77766a8b3f0 100644
--- a/fs/ext3/Makefile
+++ b/fs/ext3/Makefile
@@ -5,7 +5,7 @@
5obj-$(CONFIG_EXT3_FS) += ext3.o 5obj-$(CONFIG_EXT3_FS) += ext3.o
6 6
7ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ 7ext3-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
8 ioctl.o namei.o super.o symlink.o hash.o resize.o 8 ioctl.o namei.o super.o symlink.o hash.o resize.o ext3_jbd.o
9 9
10ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o 10ext3-$(CONFIG_EXT3_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
11ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o 11ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index b41a7d7e20f0..22161740ba29 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -144,7 +144,7 @@ restart:
144 144
145 printk("Block Allocation Reservation Windows Map (%s):\n", fn); 145 printk("Block Allocation Reservation Windows Map (%s):\n", fn);
146 while (n) { 146 while (n) {
147 rsv = list_entry(n, struct ext3_reserve_window_node, rsv_node); 147 rsv = rb_entry(n, struct ext3_reserve_window_node, rsv_node);
148 if (verbose) 148 if (verbose)
149 printk("reservation window 0x%p " 149 printk("reservation window 0x%p "
150 "start: %lu, end: %lu\n", 150 "start: %lu, end: %lu\n",
@@ -730,7 +730,7 @@ find_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
730 here = 0; 730 here = 0;
731 731
732 p = ((char *)bh->b_data) + (here >> 3); 732 p = ((char *)bh->b_data) + (here >> 3);
733 r = memscan(p, 0, (maxblocks - here + 7) >> 3); 733 r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3));
734 next = (r - ((char *)bh->b_data)) << 3; 734 next = (r - ((char *)bh->b_data)) << 3;
735 735
736 if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh)) 736 if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh))
@@ -949,7 +949,7 @@ static int find_next_reservable_window(
949 949
950 prev = rsv; 950 prev = rsv;
951 next = rb_next(&rsv->rsv_node); 951 next = rb_next(&rsv->rsv_node);
952 rsv = list_entry(next,struct ext3_reserve_window_node,rsv_node); 952 rsv = rb_entry(next,struct ext3_reserve_window_node,rsv_node);
953 953
954 /* 954 /*
955 * Reached the last reservation, we can just append to the 955 * Reached the last reservation, we can just append to the
@@ -1148,7 +1148,7 @@ retry:
1148 * check if the first free block is within the 1148 * check if the first free block is within the
1149 * free space we just reserved 1149 * free space we just reserved
1150 */ 1150 */
1151 if (start_block >= my_rsv->rsv_start && start_block < my_rsv->rsv_end) 1151 if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end)
1152 return 0; /* success */ 1152 return 0; /* success */
1153 /* 1153 /*
1154 * if the first free bit we found is out of the reservable space 1154 * if the first free bit we found is out of the reservable space
@@ -1193,7 +1193,7 @@ static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv,
1193 if (!next) 1193 if (!next)
1194 my_rsv->rsv_end += size; 1194 my_rsv->rsv_end += size;
1195 else { 1195 else {
1196 next_rsv = list_entry(next, struct ext3_reserve_window_node, rsv_node); 1196 next_rsv = rb_entry(next, struct ext3_reserve_window_node, rsv_node);
1197 1197
1198 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size) 1198 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
1199 my_rsv->rsv_end += size; 1199 my_rsv->rsv_end += size;
@@ -1271,7 +1271,7 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1271 } 1271 }
1272 /* 1272 /*
1273 * grp_goal is a group relative block number (if there is a goal) 1273 * grp_goal is a group relative block number (if there is a goal)
1274 * 0 < grp_goal < EXT3_BLOCKS_PER_GROUP(sb) 1274 * 0 <= grp_goal < EXT3_BLOCKS_PER_GROUP(sb)
1275 * first block is a filesystem wide block number 1275 * first block is a filesystem wide block number
1276 * first block is the block number of the first block in this group 1276 * first block is the block number of the first block in this group
1277 */ 1277 */
@@ -1307,10 +1307,14 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1307 if (!goal_in_my_reservation(&my_rsv->rsv_window, 1307 if (!goal_in_my_reservation(&my_rsv->rsv_window,
1308 grp_goal, group, sb)) 1308 grp_goal, group, sb))
1309 grp_goal = -1; 1309 grp_goal = -1;
1310 } else if (grp_goal > 0 && 1310 } else if (grp_goal >= 0) {
1311 (my_rsv->rsv_end-grp_goal+1) < *count) 1311 int curr = my_rsv->rsv_end -
1312 try_to_extend_reservation(my_rsv, sb, 1312 (grp_goal + group_first_block) + 1;
1313 *count-my_rsv->rsv_end + grp_goal - 1); 1313
1314 if (curr < *count)
1315 try_to_extend_reservation(my_rsv, sb,
1316 *count - curr);
1317 }
1314 1318
1315 if ((my_rsv->rsv_start > group_last_block) || 1319 if ((my_rsv->rsv_start > group_last_block) ||
1316 (my_rsv->rsv_end < group_first_block)) { 1320 (my_rsv->rsv_end < group_first_block)) {
@@ -1511,10 +1515,8 @@ retry_alloc:
1511 if (group_no >= ngroups) 1515 if (group_no >= ngroups)
1512 group_no = 0; 1516 group_no = 0;
1513 gdp = ext3_get_group_desc(sb, group_no, &gdp_bh); 1517 gdp = ext3_get_group_desc(sb, group_no, &gdp_bh);
1514 if (!gdp) { 1518 if (!gdp)
1515 *errp = -EIO; 1519 goto io_error;
1516 goto out;
1517 }
1518 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count); 1520 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
1519 /* 1521 /*
1520 * skip this group if the number of 1522 * skip this group if the number of
@@ -1548,6 +1550,7 @@ retry_alloc:
1548 */ 1550 */
1549 if (my_rsv) { 1551 if (my_rsv) {
1550 my_rsv = NULL; 1552 my_rsv = NULL;
1553 windowsz = 0;
1551 group_no = goal_group; 1554 group_no = goal_group;
1552 goto retry_alloc; 1555 goto retry_alloc;
1553 } 1556 }
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index d0b54f30b914..5a9313ecd4ef 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -154,6 +154,9 @@ static int ext3_readdir(struct file * filp,
154 ext3_error (sb, "ext3_readdir", 154 ext3_error (sb, "ext3_readdir",
155 "directory #%lu contains a hole at offset %lu", 155 "directory #%lu contains a hole at offset %lu",
156 inode->i_ino, (unsigned long)filp->f_pos); 156 inode->i_ino, (unsigned long)filp->f_pos);
157 /* corrupt size? Maybe no more blocks to read */
158 if (filp->f_pos > inode->i_blocks << 9)
159 break;
157 filp->f_pos += sb->s_blocksize - offset; 160 filp->f_pos += sb->s_blocksize - offset;
158 continue; 161 continue;
159 } 162 }
diff --git a/fs/ext3/ext3_jbd.c b/fs/ext3/ext3_jbd.c
new file mode 100644
index 000000000000..e1f91fd26a93
--- /dev/null
+++ b/fs/ext3/ext3_jbd.c
@@ -0,0 +1,59 @@
1/*
2 * Interface between ext3 and JBD
3 */
4
5#include <linux/ext3_jbd.h>
6
7int __ext3_journal_get_undo_access(const char *where, handle_t *handle,
8 struct buffer_head *bh)
9{
10 int err = journal_get_undo_access(handle, bh);
11 if (err)
12 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
13 return err;
14}
15
16int __ext3_journal_get_write_access(const char *where, handle_t *handle,
17 struct buffer_head *bh)
18{
19 int err = journal_get_write_access(handle, bh);
20 if (err)
21 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
22 return err;
23}
24
25int __ext3_journal_forget(const char *where, handle_t *handle,
26 struct buffer_head *bh)
27{
28 int err = journal_forget(handle, bh);
29 if (err)
30 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
31 return err;
32}
33
34int __ext3_journal_revoke(const char *where, handle_t *handle,
35 unsigned long blocknr, struct buffer_head *bh)
36{
37 int err = journal_revoke(handle, blocknr, bh);
38 if (err)
39 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
40 return err;
41}
42
43int __ext3_journal_get_create_access(const char *where,
44 handle_t *handle, struct buffer_head *bh)
45{
46 int err = journal_get_create_access(handle, bh);
47 if (err)
48 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
49 return err;
50}
51
52int __ext3_journal_dirty_metadata(const char *where,
53 handle_t *handle, struct buffer_head *bh)
54{
55 int err = journal_dirty_metadata(handle, bh);
56 if (err)
57 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
58 return err;
59}
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 03ba5bcab186..beaf25f5112f 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1148,37 +1148,102 @@ 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
1151static int ext3_prepare_write(struct file *file, struct page *page, 1211static int ext3_prepare_write(struct file *file, struct page *page,
1152 unsigned from, unsigned to) 1212 unsigned from, unsigned to)
1153{ 1213{
1154 struct inode *inode = page->mapping->host; 1214 struct inode *inode = page->mapping->host;
1155 int ret, needed_blocks = ext3_writepage_trans_blocks(inode); 1215 int ret, ret2;
1216 int needed_blocks = ext3_writepage_trans_blocks(inode);
1156 handle_t *handle; 1217 handle_t *handle;
1157 int retries = 0; 1218 int retries = 0;
1158 1219
1159retry: 1220retry:
1160 handle = ext3_journal_start(inode, needed_blocks); 1221 handle = ext3_journal_start(inode, needed_blocks);
1161 if (IS_ERR(handle)) { 1222 if (IS_ERR(handle))
1162 ret = PTR_ERR(handle); 1223 return PTR_ERR(handle);
1163 goto out;
1164 }
1165 if (test_opt(inode->i_sb, NOBH) && ext3_should_writeback_data(inode)) 1224 if (test_opt(inode->i_sb, NOBH) && ext3_should_writeback_data(inode))
1166 ret = nobh_prepare_write(page, from, to, ext3_get_block); 1225 ret = nobh_prepare_write(page, from, to, ext3_get_block);
1167 else 1226 else
1168 ret = block_prepare_write(page, from, to, ext3_get_block); 1227 ret = block_prepare_write(page, from, to, ext3_get_block);
1169 if (ret) 1228 if (ret)
1170 goto prepare_write_failed; 1229 goto failure;
1171 1230
1172 if (ext3_should_journal_data(inode)) { 1231 if (ext3_should_journal_data(inode)) {
1173 ret = walk_page_buffers(handle, page_buffers(page), 1232 ret = walk_page_buffers(handle, page_buffers(page),
1174 from, to, NULL, do_journal_get_write_access); 1233 from, to, NULL, do_journal_get_write_access);
1234 if (ret)
1235 /* fatal error, just put the handle and return */
1236 journal_stop(handle);
1175 } 1237 }
1176prepare_write_failed: 1238 return ret;
1177 if (ret) 1239
1178 ext3_journal_stop(handle); 1240failure:
1241 ret2 = ext3_prepare_failure(file, page, from, to);
1242 if (ret2 < 0)
1243 return ret2;
1179 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries)) 1244 if (ret == -ENOSPC && ext3_should_retry_alloc(inode->i_sb, &retries))
1180 goto retry; 1245 goto retry;
1181out: 1246 /* retry number exceeded, or other error like -EDQUOT */
1182 return ret; 1247 return ret;
1183} 1248}
1184 1249
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 906731a20f1a..60d2f9dbdb00 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -552,6 +552,15 @@ static int htree_dirblock_to_tree(struct file *dir_file,
552 dir->i_sb->s_blocksize - 552 dir->i_sb->s_blocksize -
553 EXT3_DIR_REC_LEN(0)); 553 EXT3_DIR_REC_LEN(0));
554 for (; de < top; de = ext3_next_entry(de)) { 554 for (; de < top; de = ext3_next_entry(de)) {
555 if (!ext3_check_dir_entry("htree_dirblock_to_tree", dir, de, bh,
556 (block<<EXT3_BLOCK_SIZE_BITS(dir->i_sb))
557 +((char *)de - bh->b_data))) {
558 /* On error, skip the f_pos to the next block. */
559 dir_file->f_pos = (dir_file->f_pos |
560 (dir->i_sb->s_blocksize - 1)) + 1;
561 brelse (bh);
562 return count;
563 }
555 ext3fs_dirhash(de->name, de->name_len, hinfo); 564 ext3fs_dirhash(de->name, de->name_len, hinfo);
556 if ((hinfo->hash < start_hash) || 565 if ((hinfo->hash < start_hash) ||
557 ((hinfo->hash == start_hash) && 566 ((hinfo->hash == start_hash) &&
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index afc2d4f42d77..580b8a6ca979 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -436,7 +436,7 @@ static void ext3_put_super (struct super_block * sb)
436 return; 436 return;
437} 437}
438 438
439static kmem_cache_t *ext3_inode_cachep; 439static struct kmem_cache *ext3_inode_cachep;
440 440
441/* 441/*
442 * Called inside transaction, so use GFP_NOFS 442 * Called inside transaction, so use GFP_NOFS
@@ -445,7 +445,7 @@ static struct inode *ext3_alloc_inode(struct super_block *sb)
445{ 445{
446 struct ext3_inode_info *ei; 446 struct ext3_inode_info *ei;
447 447
448 ei = kmem_cache_alloc(ext3_inode_cachep, SLAB_NOFS); 448 ei = kmem_cache_alloc(ext3_inode_cachep, GFP_NOFS);
449 if (!ei) 449 if (!ei)
450 return NULL; 450 return NULL;
451#ifdef CONFIG_EXT3_FS_POSIX_ACL 451#ifdef CONFIG_EXT3_FS_POSIX_ACL
@@ -462,7 +462,7 @@ static void ext3_destroy_inode(struct inode *inode)
462 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); 462 kmem_cache_free(ext3_inode_cachep, EXT3_I(inode));
463} 463}
464 464
465static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 465static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
466{ 466{
467 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo; 467 struct ext3_inode_info *ei = (struct ext3_inode_info *) foo;
468 468
@@ -1264,6 +1264,12 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1264 return; 1264 return;
1265 } 1265 }
1266 1266
1267 if (bdev_read_only(sb->s_bdev)) {
1268 printk(KERN_ERR "EXT3-fs: write access "
1269 "unavailable, skipping orphan cleanup.\n");
1270 return;
1271 }
1272
1267 if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) { 1273 if (EXT3_SB(sb)->s_mount_state & EXT3_ERROR_FS) {
1268 if (es->s_last_orphan) 1274 if (es->s_last_orphan)
1269 jbd_debug(1, "Errors on filesystem, " 1275 jbd_debug(1, "Errors on filesystem, "
@@ -2387,6 +2393,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2387 struct ext3_super_block *es = sbi->s_es; 2393 struct ext3_super_block *es = sbi->s_es;
2388 ext3_fsblk_t overhead; 2394 ext3_fsblk_t overhead;
2389 int i; 2395 int i;
2396 u64 fsid;
2390 2397
2391 if (test_opt (sb, MINIX_DF)) 2398 if (test_opt (sb, MINIX_DF))
2392 overhead = 0; 2399 overhead = 0;
@@ -2433,6 +2440,10 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf)
2433 buf->f_files = le32_to_cpu(es->s_inodes_count); 2440 buf->f_files = le32_to_cpu(es->s_inodes_count);
2434 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter); 2441 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
2435 buf->f_namelen = EXT3_NAME_LEN; 2442 buf->f_namelen = EXT3_NAME_LEN;
2443 fsid = le64_to_cpup((void *)es->s_uuid) ^
2444 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
2445 buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
2446 buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
2436 return 0; 2447 return 0;
2437} 2448}
2438 2449
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index f86f2482f01d..99857a400f4b 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -459,14 +459,11 @@ static void ext3_xattr_update_super_block(handle_t *handle,
459 if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR)) 459 if (EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR))
460 return; 460 return;
461 461
462 lock_super(sb);
463 if (ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh) == 0) { 462 if (ext3_journal_get_write_access(handle, EXT3_SB(sb)->s_sbh) == 0) {
464 EXT3_SB(sb)->s_es->s_feature_compat |= 463 EXT3_SET_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_EXT_ATTR);
465 cpu_to_le32(EXT3_FEATURE_COMPAT_EXT_ATTR);
466 sb->s_dirt = 1; 464 sb->s_dirt = 1;
467 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); 465 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
468 } 466 }
469 unlock_super(sb);
470} 467}
471 468
472/* 469/*
diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile
index a6acb96ebeb9..ae6e7e502ac9 100644
--- a/fs/ext4/Makefile
+++ b/fs/ext4/Makefile
@@ -5,7 +5,8 @@
5obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o 5obj-$(CONFIG_EXT4DEV_FS) += ext4dev.o
6 6
7ext4dev-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ 7ext4dev-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \
8 ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o 8 ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
9 ext4_jbd2.o
9 10
10ext4dev-$(CONFIG_EXT4DEV_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o 11ext4dev-$(CONFIG_EXT4DEV_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o
11ext4dev-$(CONFIG_EXT4DEV_FS_POSIX_ACL) += acl.o 12ext4dev-$(CONFIG_EXT4DEV_FS_POSIX_ACL) += acl.o
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 5d45582f9517..c4dd1103ccf1 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -165,7 +165,7 @@ restart:
165 165
166 printk("Block Allocation Reservation Windows Map (%s):\n", fn); 166 printk("Block Allocation Reservation Windows Map (%s):\n", fn);
167 while (n) { 167 while (n) {
168 rsv = list_entry(n, struct ext4_reserve_window_node, rsv_node); 168 rsv = rb_entry(n, struct ext4_reserve_window_node, rsv_node);
169 if (verbose) 169 if (verbose)
170 printk("reservation window 0x%p " 170 printk("reservation window 0x%p "
171 "start: %llu, end: %llu\n", 171 "start: %llu, end: %llu\n",
@@ -747,7 +747,7 @@ find_next_usable_block(ext4_grpblk_t start, struct buffer_head *bh,
747 here = 0; 747 here = 0;
748 748
749 p = ((char *)bh->b_data) + (here >> 3); 749 p = ((char *)bh->b_data) + (here >> 3);
750 r = memscan(p, 0, (maxblocks - here + 7) >> 3); 750 r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3));
751 next = (r - ((char *)bh->b_data)) << 3; 751 next = (r - ((char *)bh->b_data)) << 3;
752 752
753 if (next < maxblocks && next >= start && ext4_test_allocatable(next, bh)) 753 if (next < maxblocks && next >= start && ext4_test_allocatable(next, bh))
@@ -966,7 +966,7 @@ static int find_next_reservable_window(
966 966
967 prev = rsv; 967 prev = rsv;
968 next = rb_next(&rsv->rsv_node); 968 next = rb_next(&rsv->rsv_node);
969 rsv = list_entry(next,struct ext4_reserve_window_node,rsv_node); 969 rsv = rb_entry(next,struct ext4_reserve_window_node,rsv_node);
970 970
971 /* 971 /*
972 * Reached the last reservation, we can just append to the 972 * Reached the last reservation, we can just append to the
@@ -1165,7 +1165,7 @@ retry:
1165 * check if the first free block is within the 1165 * check if the first free block is within the
1166 * free space we just reserved 1166 * free space we just reserved
1167 */ 1167 */
1168 if (start_block >= my_rsv->rsv_start && start_block < my_rsv->rsv_end) 1168 if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end)
1169 return 0; /* success */ 1169 return 0; /* success */
1170 /* 1170 /*
1171 * if the first free bit we found is out of the reservable space 1171 * if the first free bit we found is out of the reservable space
@@ -1210,7 +1210,7 @@ static void try_to_extend_reservation(struct ext4_reserve_window_node *my_rsv,
1210 if (!next) 1210 if (!next)
1211 my_rsv->rsv_end += size; 1211 my_rsv->rsv_end += size;
1212 else { 1212 else {
1213 next_rsv = list_entry(next, struct ext4_reserve_window_node, rsv_node); 1213 next_rsv = rb_entry(next, struct ext4_reserve_window_node, rsv_node);
1214 1214
1215 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size) 1215 if ((next_rsv->rsv_start - my_rsv->rsv_end - 1) >= size)
1216 my_rsv->rsv_end += size; 1216 my_rsv->rsv_end += size;
@@ -1288,7 +1288,7 @@ ext4_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1288 } 1288 }
1289 /* 1289 /*
1290 * grp_goal is a group relative block number (if there is a goal) 1290 * grp_goal is a group relative block number (if there is a goal)
1291 * 0 < grp_goal < EXT4_BLOCKS_PER_GROUP(sb) 1291 * 0 <= grp_goal < EXT4_BLOCKS_PER_GROUP(sb)
1292 * first block is a filesystem wide block number 1292 * first block is a filesystem wide block number
1293 * first block is the block number of the first block in this group 1293 * first block is the block number of the first block in this group
1294 */ 1294 */
@@ -1324,10 +1324,14 @@ ext4_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1324 if (!goal_in_my_reservation(&my_rsv->rsv_window, 1324 if (!goal_in_my_reservation(&my_rsv->rsv_window,
1325 grp_goal, group, sb)) 1325 grp_goal, group, sb))
1326 grp_goal = -1; 1326 grp_goal = -1;
1327 } else if (grp_goal > 0 && 1327 } else if (grp_goal >= 0) {
1328 (my_rsv->rsv_end-grp_goal+1) < *count) 1328 int curr = my_rsv->rsv_end -
1329 try_to_extend_reservation(my_rsv, sb, 1329 (grp_goal + group_first_block) + 1;
1330 *count-my_rsv->rsv_end + grp_goal - 1); 1330
1331 if (curr < *count)
1332 try_to_extend_reservation(my_rsv, sb,
1333 *count - curr);
1334 }
1331 1335
1332 if ((my_rsv->rsv_start > group_last_block) || 1336 if ((my_rsv->rsv_start > group_last_block) ||
1333 (my_rsv->rsv_end < group_first_block)) { 1337 (my_rsv->rsv_end < group_first_block)) {
@@ -1525,10 +1529,8 @@ retry_alloc:
1525 if (group_no >= ngroups) 1529 if (group_no >= ngroups)
1526 group_no = 0; 1530 group_no = 0;
1527 gdp = ext4_get_group_desc(sb, group_no, &gdp_bh); 1531 gdp = ext4_get_group_desc(sb, group_no, &gdp_bh);
1528 if (!gdp) { 1532 if (!gdp)
1529 *errp = -EIO; 1533 goto io_error;
1530 goto out;
1531 }
1532 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count); 1534 free_blocks = le16_to_cpu(gdp->bg_free_blocks_count);
1533 /* 1535 /*
1534 * skip this group if the number of 1536 * skip this group if the number of
@@ -1562,6 +1564,7 @@ retry_alloc:
1562 */ 1564 */
1563 if (my_rsv) { 1565 if (my_rsv) {
1564 my_rsv = NULL; 1566 my_rsv = NULL;
1567 windowsz = 0;
1565 group_no = goal_group; 1568 group_no = goal_group;
1566 goto retry_alloc; 1569 goto retry_alloc;
1567 } 1570 }
diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
index f8595787a70e..f2ed3e7fb9f5 100644
--- a/fs/ext4/dir.c
+++ b/fs/ext4/dir.c
@@ -153,6 +153,9 @@ static int ext4_readdir(struct file * filp,
153 ext4_error (sb, "ext4_readdir", 153 ext4_error (sb, "ext4_readdir",
154 "directory #%lu contains a hole at offset %lu", 154 "directory #%lu contains a hole at offset %lu",
155 inode->i_ino, (unsigned long)filp->f_pos); 155 inode->i_ino, (unsigned long)filp->f_pos);
156 /* corrupt size? Maybe no more blocks to read */
157 if (filp->f_pos > inode->i_blocks << 9)
158 break;
156 filp->f_pos += sb->s_blocksize - offset; 159 filp->f_pos += sb->s_blocksize - offset;
157 continue; 160 continue;
158 } 161 }
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
new file mode 100644
index 000000000000..d6afe4e27340
--- /dev/null
+++ b/fs/ext4/ext4_jbd2.c
@@ -0,0 +1,59 @@
1/*
2 * Interface between ext4 and JBD
3 */
4
5#include <linux/ext4_jbd2.h>
6
7int __ext4_journal_get_undo_access(const char *where, handle_t *handle,
8 struct buffer_head *bh)
9{
10 int err = jbd2_journal_get_undo_access(handle, bh);
11 if (err)
12 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
13 return err;
14}
15
16int __ext4_journal_get_write_access(const char *where, handle_t *handle,
17 struct buffer_head *bh)
18{
19 int err = jbd2_journal_get_write_access(handle, bh);
20 if (err)
21 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
22 return err;
23}
24
25int __ext4_journal_forget(const char *where, handle_t *handle,
26 struct buffer_head *bh)
27{
28 int err = jbd2_journal_forget(handle, bh);
29 if (err)
30 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
31 return err;
32}
33
34int __ext4_journal_revoke(const char *where, handle_t *handle,
35 ext4_fsblk_t blocknr, struct buffer_head *bh)
36{
37 int err = jbd2_journal_revoke(handle, blocknr, bh);
38 if (err)
39 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
40 return err;
41}
42
43int __ext4_journal_get_create_access(const char *where,
44 handle_t *handle, struct buffer_head *bh)
45{
46 int err = jbd2_journal_get_create_access(handle, bh);
47 if (err)
48 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
49 return err;
50}
51
52int __ext4_journal_dirty_metadata(const char *where,
53 handle_t *handle, struct buffer_head *bh)
54{
55 int err = jbd2_journal_dirty_metadata(handle, bh);
56 if (err)
57 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
58 return err;
59}
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 2608dce18f3e..dc2724fa7622 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -48,7 +48,7 @@
48 * ext_pblock: 48 * ext_pblock:
49 * combine low and high parts of physical block number into ext4_fsblk_t 49 * combine low and high parts of physical block number into ext4_fsblk_t
50 */ 50 */
51static inline ext4_fsblk_t ext_pblock(struct ext4_extent *ex) 51static ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
52{ 52{
53 ext4_fsblk_t block; 53 ext4_fsblk_t block;
54 54
@@ -61,7 +61,7 @@ static inline ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
61 * idx_pblock: 61 * idx_pblock:
62 * combine low and high parts of a leaf physical block number into ext4_fsblk_t 62 * combine low and high parts of a leaf physical block number into ext4_fsblk_t
63 */ 63 */
64static inline ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix) 64static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
65{ 65{
66 ext4_fsblk_t block; 66 ext4_fsblk_t block;
67 67
@@ -75,7 +75,7 @@ static inline ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
75 * stores a large physical block number into an extent struct, 75 * stores a large physical block number into an extent struct,
76 * breaking it into parts 76 * breaking it into parts
77 */ 77 */
78static inline void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb) 78static void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
79{ 79{
80 ex->ee_start = cpu_to_le32((unsigned long) (pb & 0xffffffff)); 80 ex->ee_start = cpu_to_le32((unsigned long) (pb & 0xffffffff));
81 ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff); 81 ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
@@ -86,7 +86,7 @@ static inline void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb
86 * stores a large physical block number into an index struct, 86 * stores a large physical block number into an index struct,
87 * breaking it into parts 87 * breaking it into parts
88 */ 88 */
89static inline void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb) 89static void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
90{ 90{
91 ix->ei_leaf = cpu_to_le32((unsigned long) (pb & 0xffffffff)); 91 ix->ei_leaf = cpu_to_le32((unsigned long) (pb & 0xffffffff));
92 ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff); 92 ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
@@ -186,7 +186,8 @@ static ext4_fsblk_t ext4_ext_find_goal(struct inode *inode,
186 depth = path->p_depth; 186 depth = path->p_depth;
187 187
188 /* try to predict block placement */ 188 /* try to predict block placement */
189 if ((ex = path[depth].p_ext)) 189 ex = path[depth].p_ext;
190 if (ex)
190 return ext_pblock(ex)+(block-le32_to_cpu(ex->ee_block)); 191 return ext_pblock(ex)+(block-le32_to_cpu(ex->ee_block));
191 192
192 /* it looks like index is empty; 193 /* it looks like index is empty;
@@ -215,7 +216,7 @@ ext4_ext_new_block(handle_t *handle, struct inode *inode,
215 return newblock; 216 return newblock;
216} 217}
217 218
218static inline int ext4_ext_space_block(struct inode *inode) 219static int ext4_ext_space_block(struct inode *inode)
219{ 220{
220 int size; 221 int size;
221 222
@@ -228,7 +229,7 @@ static inline int ext4_ext_space_block(struct inode *inode)
228 return size; 229 return size;
229} 230}
230 231
231static inline int ext4_ext_space_block_idx(struct inode *inode) 232static int ext4_ext_space_block_idx(struct inode *inode)
232{ 233{
233 int size; 234 int size;
234 235
@@ -241,7 +242,7 @@ static inline int ext4_ext_space_block_idx(struct inode *inode)
241 return size; 242 return size;
242} 243}
243 244
244static inline int ext4_ext_space_root(struct inode *inode) 245static int ext4_ext_space_root(struct inode *inode)
245{ 246{
246 int size; 247 int size;
247 248
@@ -255,7 +256,7 @@ static inline int ext4_ext_space_root(struct inode *inode)
255 return size; 256 return size;
256} 257}
257 258
258static inline int ext4_ext_space_root_idx(struct inode *inode) 259static int ext4_ext_space_root_idx(struct inode *inode)
259{ 260{
260 int size; 261 int size;
261 262
@@ -476,13 +477,12 @@ ext4_ext_find_extent(struct inode *inode, int block, struct ext4_ext_path *path)
476 477
477 /* account possible depth increase */ 478 /* account possible depth increase */
478 if (!path) { 479 if (!path) {
479 path = kmalloc(sizeof(struct ext4_ext_path) * (depth + 2), 480 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2),
480 GFP_NOFS); 481 GFP_NOFS);
481 if (!path) 482 if (!path)
482 return ERR_PTR(-ENOMEM); 483 return ERR_PTR(-ENOMEM);
483 alloc = 1; 484 alloc = 1;
484 } 485 }
485 memset(path, 0, sizeof(struct ext4_ext_path) * (depth + 1));
486 path[0].p_hdr = eh; 486 path[0].p_hdr = eh;
487 487
488 /* walk through the tree */ 488 /* walk through the tree */
@@ -543,7 +543,8 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
543 struct ext4_extent_idx *ix; 543 struct ext4_extent_idx *ix;
544 int len, err; 544 int len, err;
545 545
546 if ((err = ext4_ext_get_access(handle, inode, curp))) 546 err = ext4_ext_get_access(handle, inode, curp);
547 if (err)
547 return err; 548 return err;
548 549
549 BUG_ON(logical == le32_to_cpu(curp->p_idx->ei_block)); 550 BUG_ON(logical == le32_to_cpu(curp->p_idx->ei_block));
@@ -641,10 +642,9 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
641 * We need this to handle errors and free blocks 642 * We need this to handle errors and free blocks
642 * upon them. 643 * upon them.
643 */ 644 */
644 ablocks = kmalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS); 645 ablocks = kzalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS);
645 if (!ablocks) 646 if (!ablocks)
646 return -ENOMEM; 647 return -ENOMEM;
647 memset(ablocks, 0, sizeof(ext4_fsblk_t) * depth);
648 648
649 /* allocate all needed blocks */ 649 /* allocate all needed blocks */
650 ext_debug("allocate %d blocks for indexes/leaf\n", depth - at); 650 ext_debug("allocate %d blocks for indexes/leaf\n", depth - at);
@@ -665,7 +665,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
665 } 665 }
666 lock_buffer(bh); 666 lock_buffer(bh);
667 667
668 if ((err = ext4_journal_get_create_access(handle, bh))) 668 err = ext4_journal_get_create_access(handle, bh);
669 if (err)
669 goto cleanup; 670 goto cleanup;
670 671
671 neh = ext_block_hdr(bh); 672 neh = ext_block_hdr(bh);
@@ -702,18 +703,21 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
702 set_buffer_uptodate(bh); 703 set_buffer_uptodate(bh);
703 unlock_buffer(bh); 704 unlock_buffer(bh);
704 705
705 if ((err = ext4_journal_dirty_metadata(handle, bh))) 706 err = ext4_journal_dirty_metadata(handle, bh);
707 if (err)
706 goto cleanup; 708 goto cleanup;
707 brelse(bh); 709 brelse(bh);
708 bh = NULL; 710 bh = NULL;
709 711
710 /* correct old leaf */ 712 /* correct old leaf */
711 if (m) { 713 if (m) {
712 if ((err = ext4_ext_get_access(handle, inode, path + depth))) 714 err = ext4_ext_get_access(handle, inode, path + depth);
715 if (err)
713 goto cleanup; 716 goto cleanup;
714 path[depth].p_hdr->eh_entries = 717 path[depth].p_hdr->eh_entries =
715 cpu_to_le16(le16_to_cpu(path[depth].p_hdr->eh_entries)-m); 718 cpu_to_le16(le16_to_cpu(path[depth].p_hdr->eh_entries)-m);
716 if ((err = ext4_ext_dirty(handle, inode, path + depth))) 719 err = ext4_ext_dirty(handle, inode, path + depth);
720 if (err)
717 goto cleanup; 721 goto cleanup;
718 722
719 } 723 }
@@ -736,7 +740,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
736 } 740 }
737 lock_buffer(bh); 741 lock_buffer(bh);
738 742
739 if ((err = ext4_journal_get_create_access(handle, bh))) 743 err = ext4_journal_get_create_access(handle, bh);
744 if (err)
740 goto cleanup; 745 goto cleanup;
741 746
742 neh = ext_block_hdr(bh); 747 neh = ext_block_hdr(bh);
@@ -780,7 +785,8 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
780 set_buffer_uptodate(bh); 785 set_buffer_uptodate(bh);
781 unlock_buffer(bh); 786 unlock_buffer(bh);
782 787
783 if ((err = ext4_journal_dirty_metadata(handle, bh))) 788 err = ext4_journal_dirty_metadata(handle, bh);
789 if (err)
784 goto cleanup; 790 goto cleanup;
785 brelse(bh); 791 brelse(bh);
786 bh = NULL; 792 bh = NULL;
@@ -800,9 +806,6 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
800 } 806 }
801 807
802 /* insert new index */ 808 /* insert new index */
803 if (err)
804 goto cleanup;
805
806 err = ext4_ext_insert_index(handle, inode, path + at, 809 err = ext4_ext_insert_index(handle, inode, path + at,
807 le32_to_cpu(border), newblock); 810 le32_to_cpu(border), newblock);
808 811
@@ -857,7 +860,8 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
857 } 860 }
858 lock_buffer(bh); 861 lock_buffer(bh);
859 862
860 if ((err = ext4_journal_get_create_access(handle, bh))) { 863 err = ext4_journal_get_create_access(handle, bh);
864 if (err) {
861 unlock_buffer(bh); 865 unlock_buffer(bh);
862 goto out; 866 goto out;
863 } 867 }
@@ -877,11 +881,13 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
877 set_buffer_uptodate(bh); 881 set_buffer_uptodate(bh);
878 unlock_buffer(bh); 882 unlock_buffer(bh);
879 883
880 if ((err = ext4_journal_dirty_metadata(handle, bh))) 884 err = ext4_journal_dirty_metadata(handle, bh);
885 if (err)
881 goto out; 886 goto out;
882 887
883 /* create index in new top-level index: num,max,pointer */ 888 /* create index in new top-level index: num,max,pointer */
884 if ((err = ext4_ext_get_access(handle, inode, curp))) 889 err = ext4_ext_get_access(handle, inode, curp);
890 if (err)
885 goto out; 891 goto out;
886 892
887 curp->p_hdr->eh_magic = EXT4_EXT_MAGIC; 893 curp->p_hdr->eh_magic = EXT4_EXT_MAGIC;
@@ -1073,27 +1079,31 @@ int ext4_ext_correct_indexes(handle_t *handle, struct inode *inode,
1073 */ 1079 */
1074 k = depth - 1; 1080 k = depth - 1;
1075 border = path[depth].p_ext->ee_block; 1081 border = path[depth].p_ext->ee_block;
1076 if ((err = ext4_ext_get_access(handle, inode, path + k))) 1082 err = ext4_ext_get_access(handle, inode, path + k);
1083 if (err)
1077 return err; 1084 return err;
1078 path[k].p_idx->ei_block = border; 1085 path[k].p_idx->ei_block = border;
1079 if ((err = ext4_ext_dirty(handle, inode, path + k))) 1086 err = ext4_ext_dirty(handle, inode, path + k);
1087 if (err)
1080 return err; 1088 return err;
1081 1089
1082 while (k--) { 1090 while (k--) {
1083 /* change all left-side indexes */ 1091 /* change all left-side indexes */
1084 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr)) 1092 if (path[k+1].p_idx != EXT_FIRST_INDEX(path[k+1].p_hdr))
1085 break; 1093 break;
1086 if ((err = ext4_ext_get_access(handle, inode, path + k))) 1094 err = ext4_ext_get_access(handle, inode, path + k);
1095 if (err)
1087 break; 1096 break;
1088 path[k].p_idx->ei_block = border; 1097 path[k].p_idx->ei_block = border;
1089 if ((err = ext4_ext_dirty(handle, inode, path + k))) 1098 err = ext4_ext_dirty(handle, inode, path + k);
1099 if (err)
1090 break; 1100 break;
1091 } 1101 }
1092 1102
1093 return err; 1103 return err;
1094} 1104}
1095 1105
1096static int inline 1106static int
1097ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1, 1107ext4_can_extents_be_merged(struct inode *inode, struct ext4_extent *ex1,
1098 struct ext4_extent *ex2) 1108 struct ext4_extent *ex2)
1099{ 1109{
@@ -1145,7 +1155,8 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode,
1145 le16_to_cpu(newext->ee_len), 1155 le16_to_cpu(newext->ee_len),
1146 le32_to_cpu(ex->ee_block), 1156 le32_to_cpu(ex->ee_block),
1147 le16_to_cpu(ex->ee_len), ext_pblock(ex)); 1157 le16_to_cpu(ex->ee_len), ext_pblock(ex));
1148 if ((err = ext4_ext_get_access(handle, inode, path + depth))) 1158 err = ext4_ext_get_access(handle, inode, path + depth);
1159 if (err)
1149 return err; 1160 return err;
1150 ex->ee_len = cpu_to_le16(le16_to_cpu(ex->ee_len) 1161 ex->ee_len = cpu_to_le16(le16_to_cpu(ex->ee_len)
1151 + le16_to_cpu(newext->ee_len)); 1162 + le16_to_cpu(newext->ee_len));
@@ -1195,7 +1206,8 @@ repeat:
1195has_space: 1206has_space:
1196 nearex = path[depth].p_ext; 1207 nearex = path[depth].p_ext;
1197 1208
1198 if ((err = ext4_ext_get_access(handle, inode, path + depth))) 1209 err = ext4_ext_get_access(handle, inode, path + depth);
1210 if (err)
1199 goto cleanup; 1211 goto cleanup;
1200 1212
1201 if (!nearex) { 1213 if (!nearex) {
@@ -1383,7 +1395,7 @@ int ext4_ext_walk_space(struct inode *inode, unsigned long block,
1383 return err; 1395 return err;
1384} 1396}
1385 1397
1386static inline void 1398static void
1387ext4_ext_put_in_cache(struct inode *inode, __u32 block, 1399ext4_ext_put_in_cache(struct inode *inode, __u32 block,
1388 __u32 len, __u32 start, int type) 1400 __u32 len, __u32 start, int type)
1389{ 1401{
@@ -1401,7 +1413,7 @@ ext4_ext_put_in_cache(struct inode *inode, __u32 block,
1401 * calculate boundaries of the gap that the requested block fits into 1413 * calculate boundaries of the gap that the requested block fits into
1402 * and cache this gap 1414 * and cache this gap
1403 */ 1415 */
1404static inline void 1416static void
1405ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path, 1417ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
1406 unsigned long block) 1418 unsigned long block)
1407{ 1419{
@@ -1442,7 +1454,7 @@ ext4_ext_put_gap_in_cache(struct inode *inode, struct ext4_ext_path *path,
1442 ext4_ext_put_in_cache(inode, lblock, len, 0, EXT4_EXT_CACHE_GAP); 1454 ext4_ext_put_in_cache(inode, lblock, len, 0, EXT4_EXT_CACHE_GAP);
1443} 1455}
1444 1456
1445static inline int 1457static int
1446ext4_ext_in_cache(struct inode *inode, unsigned long block, 1458ext4_ext_in_cache(struct inode *inode, unsigned long block,
1447 struct ext4_extent *ex) 1459 struct ext4_extent *ex)
1448{ 1460{
@@ -1489,10 +1501,12 @@ int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
1489 path--; 1501 path--;
1490 leaf = idx_pblock(path->p_idx); 1502 leaf = idx_pblock(path->p_idx);
1491 BUG_ON(path->p_hdr->eh_entries == 0); 1503 BUG_ON(path->p_hdr->eh_entries == 0);
1492 if ((err = ext4_ext_get_access(handle, inode, path))) 1504 err = ext4_ext_get_access(handle, inode, path);
1505 if (err)
1493 return err; 1506 return err;
1494 path->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path->p_hdr->eh_entries)-1); 1507 path->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path->p_hdr->eh_entries)-1);
1495 if ((err = ext4_ext_dirty(handle, inode, path))) 1508 err = ext4_ext_dirty(handle, inode, path);
1509 if (err)
1496 return err; 1510 return err;
1497 ext_debug("index is empty, remove it, free block %llu\n", leaf); 1511 ext_debug("index is empty, remove it, free block %llu\n", leaf);
1498 bh = sb_find_get_block(inode->i_sb, leaf); 1512 bh = sb_find_get_block(inode->i_sb, leaf);
@@ -1509,7 +1523,7 @@ int ext4_ext_rm_idx(handle_t *handle, struct inode *inode,
1509 * the caller should calculate credits under truncate_mutex and 1523 * the caller should calculate credits under truncate_mutex and
1510 * pass the actual path. 1524 * pass the actual path.
1511 */ 1525 */
1512int inline ext4_ext_calc_credits_for_insert(struct inode *inode, 1526int ext4_ext_calc_credits_for_insert(struct inode *inode,
1513 struct ext4_ext_path *path) 1527 struct ext4_ext_path *path)
1514{ 1528{
1515 int depth, needed; 1529 int depth, needed;
@@ -1534,16 +1548,17 @@ int inline ext4_ext_calc_credits_for_insert(struct inode *inode,
1534 1548
1535 /* 1549 /*
1536 * tree can be full, so it would need to grow in depth: 1550 * tree can be full, so it would need to grow in depth:
1537 * allocation + old root + new root 1551 * we need one credit to modify old root, credits for
1552 * new root will be added in split accounting
1538 */ 1553 */
1539 needed += 2 + 1 + 1; 1554 needed += 1;
1540 1555
1541 /* 1556 /*
1542 * Index split can happen, we would need: 1557 * Index split can happen, we would need:
1543 * allocate intermediate indexes (bitmap + group) 1558 * allocate intermediate indexes (bitmap + group)
1544 * + change two blocks at each level, but root (already included) 1559 * + change two blocks at each level, but root (already included)
1545 */ 1560 */
1546 needed = (depth * 2) + (depth * 2); 1561 needed += (depth * 2) + (depth * 2);
1547 1562
1548 /* any allocation modifies superblock */ 1563 /* any allocation modifies superblock */
1549 needed += 1; 1564 needed += 1;
@@ -1718,7 +1733,7 @@ out:
1718 * ext4_ext_more_to_rm: 1733 * ext4_ext_more_to_rm:
1719 * returns 1 if current index has to be freed (even partial) 1734 * returns 1 if current index has to be freed (even partial)
1720 */ 1735 */
1721static int inline 1736static int
1722ext4_ext_more_to_rm(struct ext4_ext_path *path) 1737ext4_ext_more_to_rm(struct ext4_ext_path *path)
1723{ 1738{
1724 BUG_ON(path->p_idx == NULL); 1739 BUG_ON(path->p_idx == NULL);
@@ -1756,12 +1771,11 @@ int ext4_ext_remove_space(struct inode *inode, unsigned long start)
1756 * We start scanning from right side, freeing all the blocks 1771 * We start scanning from right side, freeing all the blocks
1757 * after i_size and walking into the tree depth-wise. 1772 * after i_size and walking into the tree depth-wise.
1758 */ 1773 */
1759 path = kmalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_KERNEL); 1774 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_KERNEL);
1760 if (path == NULL) { 1775 if (path == NULL) {
1761 ext4_journal_stop(handle); 1776 ext4_journal_stop(handle);
1762 return -ENOMEM; 1777 return -ENOMEM;
1763 } 1778 }
1764 memset(path, 0, sizeof(struct ext4_ext_path) * (depth + 1));
1765 path[0].p_hdr = ext_inode_hdr(inode); 1779 path[0].p_hdr = ext_inode_hdr(inode);
1766 if (ext4_ext_check_header(__FUNCTION__, inode, path[0].p_hdr)) { 1780 if (ext4_ext_check_header(__FUNCTION__, inode, path[0].p_hdr)) {
1767 err = -EIO; 1781 err = -EIO;
@@ -1932,7 +1946,8 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
1932 mutex_lock(&EXT4_I(inode)->truncate_mutex); 1946 mutex_lock(&EXT4_I(inode)->truncate_mutex);
1933 1947
1934 /* check in cache */ 1948 /* check in cache */
1935 if ((goal = ext4_ext_in_cache(inode, iblock, &newex))) { 1949 goal = ext4_ext_in_cache(inode, iblock, &newex);
1950 if (goal) {
1936 if (goal == EXT4_EXT_CACHE_GAP) { 1951 if (goal == EXT4_EXT_CACHE_GAP) {
1937 if (!create) { 1952 if (!create) {
1938 /* block isn't allocated yet and 1953 /* block isn't allocated yet and
@@ -1971,7 +1986,8 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
1971 */ 1986 */
1972 BUG_ON(path[depth].p_ext == NULL && depth != 0); 1987 BUG_ON(path[depth].p_ext == NULL && depth != 0);
1973 1988
1974 if ((ex = path[depth].p_ext)) { 1989 ex = path[depth].p_ext;
1990 if (ex) {
1975 unsigned long ee_block = le32_to_cpu(ex->ee_block); 1991 unsigned long ee_block = le32_to_cpu(ex->ee_block);
1976 ext4_fsblk_t ee_start = ext_pblock(ex); 1992 ext4_fsblk_t ee_start = ext_pblock(ex);
1977 unsigned short ee_len = le16_to_cpu(ex->ee_len); 1993 unsigned short ee_len = le16_to_cpu(ex->ee_len);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 0a60ec5a16db..1d85d4ec9598 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1147,37 +1147,102 @@ 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
1150static int ext4_prepare_write(struct file *file, struct page *page, 1210static int ext4_prepare_write(struct file *file, struct page *page,
1151 unsigned from, unsigned to) 1211 unsigned from, unsigned to)
1152{ 1212{
1153 struct inode *inode = page->mapping->host; 1213 struct inode *inode = page->mapping->host;
1154 int ret, needed_blocks = ext4_writepage_trans_blocks(inode); 1214 int ret, ret2;
1215 int needed_blocks = ext4_writepage_trans_blocks(inode);
1155 handle_t *handle; 1216 handle_t *handle;
1156 int retries = 0; 1217 int retries = 0;
1157 1218
1158retry: 1219retry:
1159 handle = ext4_journal_start(inode, needed_blocks); 1220 handle = ext4_journal_start(inode, needed_blocks);
1160 if (IS_ERR(handle)) { 1221 if (IS_ERR(handle))
1161 ret = PTR_ERR(handle); 1222 return PTR_ERR(handle);
1162 goto out;
1163 }
1164 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode)) 1223 if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
1165 ret = nobh_prepare_write(page, from, to, ext4_get_block); 1224 ret = nobh_prepare_write(page, from, to, ext4_get_block);
1166 else 1225 else
1167 ret = block_prepare_write(page, from, to, ext4_get_block); 1226 ret = block_prepare_write(page, from, to, ext4_get_block);
1168 if (ret) 1227 if (ret)
1169 goto prepare_write_failed; 1228 goto failure;
1170 1229
1171 if (ext4_should_journal_data(inode)) { 1230 if (ext4_should_journal_data(inode)) {
1172 ret = walk_page_buffers(handle, page_buffers(page), 1231 ret = walk_page_buffers(handle, page_buffers(page),
1173 from, to, NULL, do_journal_get_write_access); 1232 from, to, NULL, do_journal_get_write_access);
1233 if (ret)
1234 /* fatal error, just put the handle and return */
1235 journal_stop(handle);
1174 } 1236 }
1175prepare_write_failed: 1237 return ret;
1176 if (ret) 1238
1177 ext4_journal_stop(handle); 1239failure:
1240 ret2 = ext4_prepare_failure(file, page, from, to);
1241 if (ret2 < 0)
1242 return ret2;
1178 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) 1243 if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
1179 goto retry; 1244 goto retry;
1180out: 1245 /* retry number exceeded, or other error like -EDQUOT */
1181 return ret; 1246 return ret;
1182} 1247}
1183 1248
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 8b1bd03d20f5..859990eac504 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -552,6 +552,15 @@ static int htree_dirblock_to_tree(struct file *dir_file,
552 dir->i_sb->s_blocksize - 552 dir->i_sb->s_blocksize -
553 EXT4_DIR_REC_LEN(0)); 553 EXT4_DIR_REC_LEN(0));
554 for (; de < top; de = ext4_next_entry(de)) { 554 for (; de < top; de = ext4_next_entry(de)) {
555 if (!ext4_check_dir_entry("htree_dirblock_to_tree", dir, de, bh,
556 (block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb))
557 +((char *)de - bh->b_data))) {
558 /* On error, skip the f_pos to the next block. */
559 dir_file->f_pos = (dir_file->f_pos |
560 (dir->i_sb->s_blocksize - 1)) + 1;
561 brelse (bh);
562 return count;
563 }
555 ext4fs_dirhash(de->name, de->name_len, hinfo); 564 ext4fs_dirhash(de->name, de->name_len, hinfo);
556 if ((hinfo->hash < start_hash) || 565 if ((hinfo->hash < start_hash) ||
557 ((hinfo->hash == start_hash) && 566 ((hinfo->hash == start_hash) &&
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b4b022aa2bc2..486a641ca71b 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -486,7 +486,7 @@ static void ext4_put_super (struct super_block * sb)
486 return; 486 return;
487} 487}
488 488
489static kmem_cache_t *ext4_inode_cachep; 489static struct kmem_cache *ext4_inode_cachep;
490 490
491/* 491/*
492 * Called inside transaction, so use GFP_NOFS 492 * Called inside transaction, so use GFP_NOFS
@@ -495,7 +495,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
495{ 495{
496 struct ext4_inode_info *ei; 496 struct ext4_inode_info *ei;
497 497
498 ei = kmem_cache_alloc(ext4_inode_cachep, SLAB_NOFS); 498 ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS);
499 if (!ei) 499 if (!ei)
500 return NULL; 500 return NULL;
501#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL 501#ifdef CONFIG_EXT4DEV_FS_POSIX_ACL
@@ -513,7 +513,7 @@ static void ext4_destroy_inode(struct inode *inode)
513 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); 513 kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
514} 514}
515 515
516static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 516static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
517{ 517{
518 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo; 518 struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
519 519
@@ -1321,6 +1321,12 @@ static void ext4_orphan_cleanup (struct super_block * sb,
1321 return; 1321 return;
1322 } 1322 }
1323 1323
1324 if (bdev_read_only(sb->s_bdev)) {
1325 printk(KERN_ERR "EXT4-fs: write access "
1326 "unavailable, skipping orphan cleanup.\n");
1327 return;
1328 }
1329
1324 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) { 1330 if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
1325 if (es->s_last_orphan) 1331 if (es->s_last_orphan)
1326 jbd_debug(1, "Errors on filesystem, " 1332 jbd_debug(1, "Errors on filesystem, "
@@ -2460,6 +2466,7 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
2460 struct ext4_super_block *es = sbi->s_es; 2466 struct ext4_super_block *es = sbi->s_es;
2461 ext4_fsblk_t overhead; 2467 ext4_fsblk_t overhead;
2462 int i; 2468 int i;
2469 u64 fsid;
2463 2470
2464 if (test_opt (sb, MINIX_DF)) 2471 if (test_opt (sb, MINIX_DF))
2465 overhead = 0; 2472 overhead = 0;
@@ -2506,6 +2513,10 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
2506 buf->f_files = le32_to_cpu(es->s_inodes_count); 2513 buf->f_files = le32_to_cpu(es->s_inodes_count);
2507 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter); 2514 buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
2508 buf->f_namelen = EXT4_NAME_LEN; 2515 buf->f_namelen = EXT4_NAME_LEN;
2516 fsid = le64_to_cpup((void *)es->s_uuid) ^
2517 le64_to_cpup((void *)es->s_uuid + sizeof(u64));
2518 buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
2519 buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
2509 return 0; 2520 return 0;
2510} 2521}
2511 2522
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 63233cd946a7..dc969c357aa1 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -459,14 +459,11 @@ static void ext4_xattr_update_super_block(handle_t *handle,
459 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR)) 459 if (EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR))
460 return; 460 return;
461 461
462 lock_super(sb);
463 if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) { 462 if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
464 EXT4_SB(sb)->s_es->s_feature_compat |= 463 EXT4_SET_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_EXT_ATTR);
465 cpu_to_le32(EXT4_FEATURE_COMPAT_EXT_ATTR);
466 sb->s_dirt = 1; 464 sb->s_dirt = 1;
467 ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh); 465 ext4_journal_dirty_metadata(handle, EXT4_SB(sb)->s_sbh);
468 } 466 }
469 unlock_super(sb);
470} 467}
471 468
472/* 469/*
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 82cc4f59e3ba..05c2941c74f2 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -34,9 +34,9 @@ static inline int fat_max_cache(struct inode *inode)
34 return FAT_MAX_CACHE; 34 return FAT_MAX_CACHE;
35} 35}
36 36
37static kmem_cache_t *fat_cache_cachep; 37static struct kmem_cache *fat_cache_cachep;
38 38
39static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 39static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
40{ 40{
41 struct fat_cache *cache = (struct fat_cache *)foo; 41 struct fat_cache *cache = (struct fat_cache *)foo;
42 42
@@ -63,7 +63,7 @@ void fat_cache_destroy(void)
63 63
64static inline struct fat_cache *fat_cache_alloc(struct inode *inode) 64static inline struct fat_cache *fat_cache_alloc(struct inode *inode)
65{ 65{
66 return kmem_cache_alloc(fat_cache_cachep, SLAB_KERNEL); 66 return kmem_cache_alloc(fat_cache_cachep, GFP_KERNEL);
67} 67}
68 68
69static inline void fat_cache_free(struct fat_cache *cache) 69static inline void fat_cache_free(struct fat_cache *cache)
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 78945b53b0f8..a9e4688582a2 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -477,12 +477,12 @@ static void fat_put_super(struct super_block *sb)
477 kfree(sbi); 477 kfree(sbi);
478} 478}
479 479
480static kmem_cache_t *fat_inode_cachep; 480static struct kmem_cache *fat_inode_cachep;
481 481
482static struct inode *fat_alloc_inode(struct super_block *sb) 482static struct inode *fat_alloc_inode(struct super_block *sb)
483{ 483{
484 struct msdos_inode_info *ei; 484 struct msdos_inode_info *ei;
485 ei = kmem_cache_alloc(fat_inode_cachep, SLAB_KERNEL); 485 ei = kmem_cache_alloc(fat_inode_cachep, GFP_KERNEL);
486 if (!ei) 486 if (!ei)
487 return NULL; 487 return NULL;
488 return &ei->vfs_inode; 488 return &ei->vfs_inode;
@@ -493,7 +493,7 @@ static void fat_destroy_inode(struct inode *inode)
493 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); 493 kmem_cache_free(fat_inode_cachep, MSDOS_I(inode));
494} 494}
495 495
496static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 496static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
497{ 497{
498 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo; 498 struct msdos_inode_info *ei = (struct msdos_inode_info *)foo;
499 499
diff --git a/fs/fcntl.c b/fs/fcntl.c
index e4f26165f12a..4740d35e52cd 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -553,7 +553,7 @@ int send_sigurg(struct fown_struct *fown)
553} 553}
554 554
555static DEFINE_RWLOCK(fasync_lock); 555static DEFINE_RWLOCK(fasync_lock);
556static kmem_cache_t *fasync_cache __read_mostly; 556static struct kmem_cache *fasync_cache __read_mostly;
557 557
558/* 558/*
559 * fasync_helper() is used by some character device drivers (mainly mice) 559 * fasync_helper() is used by some character device drivers (mainly mice)
@@ -567,7 +567,7 @@ int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fap
567 int result = 0; 567 int result = 0;
568 568
569 if (on) { 569 if (on) {
570 new = kmem_cache_alloc(fasync_cache, SLAB_KERNEL); 570 new = kmem_cache_alloc(fasync_cache, GFP_KERNEL);
571 if (!new) 571 if (!new)
572 return -ENOMEM; 572 return -ENOMEM;
573 } 573 }
diff --git a/fs/file.c b/fs/file.c
index 3787e82f54c1..51aef675470f 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -21,7 +21,6 @@
21struct fdtable_defer { 21struct fdtable_defer {
22 spinlock_t lock; 22 spinlock_t lock;
23 struct work_struct wq; 23 struct work_struct wq;
24 struct timer_list timer;
25 struct fdtable *next; 24 struct fdtable *next;
26}; 25};
27 26
@@ -75,22 +74,6 @@ static void __free_fdtable(struct fdtable *fdt)
75 kfree(fdt); 74 kfree(fdt);
76} 75}
77 76
78static void fdtable_timer(unsigned long data)
79{
80 struct fdtable_defer *fddef = (struct fdtable_defer *)data;
81
82 spin_lock(&fddef->lock);
83 /*
84 * If someone already emptied the queue return.
85 */
86 if (!fddef->next)
87 goto out;
88 if (!schedule_work(&fddef->wq))
89 mod_timer(&fddef->timer, 5);
90out:
91 spin_unlock(&fddef->lock);
92}
93
94static void free_fdtable_work(struct work_struct *work) 77static void free_fdtable_work(struct work_struct *work)
95{ 78{
96 struct fdtable_defer *f = 79 struct fdtable_defer *f =
@@ -144,13 +127,8 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
144 spin_lock(&fddef->lock); 127 spin_lock(&fddef->lock);
145 fdt->next = fddef->next; 128 fdt->next = fddef->next;
146 fddef->next = fdt; 129 fddef->next = fdt;
147 /* 130 /* vmallocs are handled from the workqueue context */
148 * vmallocs are handled from the workqueue context. 131 schedule_work(&fddef->wq);
149 * If the per-cpu workqueue is running, then we
150 * defer work scheduling through a timer.
151 */
152 if (!schedule_work(&fddef->wq))
153 mod_timer(&fddef->timer, 5);
154 spin_unlock(&fddef->lock); 132 spin_unlock(&fddef->lock);
155 put_cpu_var(fdtable_defer_list); 133 put_cpu_var(fdtable_defer_list);
156 } 134 }
@@ -354,9 +332,6 @@ static void __devinit fdtable_defer_list_init(int cpu)
354 struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu); 332 struct fdtable_defer *fddef = &per_cpu(fdtable_defer_list, cpu);
355 spin_lock_init(&fddef->lock); 333 spin_lock_init(&fddef->lock);
356 INIT_WORK(&fddef->wq, free_fdtable_work); 334 INIT_WORK(&fddef->wq, free_fdtable_work);
357 init_timer(&fddef->timer);
358 fddef->timer.data = (unsigned long)fddef;
359 fddef->timer.function = fdtable_timer;
360 fddef->next = NULL; 335 fddef->next = NULL;
361} 336}
362 337
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index 4786d51ad3bd..0b7ae897cb78 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -46,7 +46,7 @@ extern const struct address_space_operations vxfs_immed_aops;
46 46
47extern struct inode_operations vxfs_immed_symlink_iops; 47extern struct inode_operations vxfs_immed_symlink_iops;
48 48
49kmem_cache_t *vxfs_inode_cachep; 49struct kmem_cache *vxfs_inode_cachep;
50 50
51 51
52#ifdef DIAGNOSTIC 52#ifdef DIAGNOSTIC
@@ -103,7 +103,7 @@ vxfs_blkiget(struct super_block *sbp, u_long extent, ino_t ino)
103 struct vxfs_inode_info *vip; 103 struct vxfs_inode_info *vip;
104 struct vxfs_dinode *dip; 104 struct vxfs_dinode *dip;
105 105
106 if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, SLAB_KERNEL))) 106 if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, GFP_KERNEL)))
107 goto fail; 107 goto fail;
108 dip = (struct vxfs_dinode *)(bp->b_data + offset); 108 dip = (struct vxfs_dinode *)(bp->b_data + offset);
109 memcpy(vip, dip, sizeof(*vip)); 109 memcpy(vip, dip, sizeof(*vip));
@@ -145,7 +145,7 @@ __vxfs_iget(ino_t ino, struct inode *ilistp)
145 struct vxfs_dinode *dip; 145 struct vxfs_dinode *dip;
146 caddr_t kaddr = (char *)page_address(pp); 146 caddr_t kaddr = (char *)page_address(pp);
147 147
148 if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, SLAB_KERNEL))) 148 if (!(vip = kmem_cache_alloc(vxfs_inode_cachep, GFP_KERNEL)))
149 goto fail; 149 goto fail;
150 dip = (struct vxfs_dinode *)(kaddr + offset); 150 dip = (struct vxfs_dinode *)(kaddr + offset);
151 memcpy(vip, dip, sizeof(*vip)); 151 memcpy(vip, dip, sizeof(*vip));
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 66571eafbb1e..357764d85ff1 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -19,7 +19,7 @@
19 19
20MODULE_ALIAS_MISCDEV(FUSE_MINOR); 20MODULE_ALIAS_MISCDEV(FUSE_MINOR);
21 21
22static kmem_cache_t *fuse_req_cachep; 22static struct kmem_cache *fuse_req_cachep;
23 23
24static struct fuse_conn *fuse_get_conn(struct file *file) 24static struct fuse_conn *fuse_get_conn(struct file *file)
25{ 25{
@@ -41,7 +41,7 @@ static void fuse_request_init(struct fuse_req *req)
41 41
42struct fuse_req *fuse_request_alloc(void) 42struct fuse_req *fuse_request_alloc(void)
43{ 43{
44 struct fuse_req *req = kmem_cache_alloc(fuse_req_cachep, SLAB_KERNEL); 44 struct fuse_req *req = kmem_cache_alloc(fuse_req_cachep, GFP_KERNEL);
45 if (req) 45 if (req)
46 fuse_request_init(req); 46 fuse_request_init(req);
47 return req; 47 return req;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index c71a6c092ad9..1cabdb229adb 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -141,9 +141,6 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd)
141 struct fuse_req *forget_req; 141 struct fuse_req *forget_req;
142 struct dentry *parent; 142 struct dentry *parent;
143 143
144 /* Doesn't hurt to "reset" the validity timeout */
145 fuse_invalidate_entry_cache(entry);
146
147 /* For negative dentries, always do a fresh lookup */ 144 /* For negative dentries, always do a fresh lookup */
148 if (!inode) 145 if (!inode)
149 return 0; 146 return 0;
@@ -1027,6 +1024,8 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)
1027 if (attr->ia_valid & ATTR_SIZE) { 1024 if (attr->ia_valid & ATTR_SIZE) {
1028 unsigned long limit; 1025 unsigned long limit;
1029 is_truncate = 1; 1026 is_truncate = 1;
1027 if (IS_SWAPFILE(inode))
1028 return -ETXTBSY;
1030 limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; 1029 limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
1031 if (limit != RLIM_INFINITY && attr->ia_size > (loff_t) limit) { 1030 if (limit != RLIM_INFINITY && attr->ia_size > (loff_t) limit) {
1032 send_sig(SIGXFSZ, current, 0); 1031 send_sig(SIGXFSZ, current, 0);
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 763a50daf1c0..128f79c40803 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -754,6 +754,42 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
754 return err; 754 return err;
755} 755}
756 756
757static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
758{
759 struct inode *inode = mapping->host;
760 struct fuse_conn *fc = get_fuse_conn(inode);
761 struct fuse_req *req;
762 struct fuse_bmap_in inarg;
763 struct fuse_bmap_out outarg;
764 int err;
765
766 if (!inode->i_sb->s_bdev || fc->no_bmap)
767 return 0;
768
769 req = fuse_get_req(fc);
770 if (IS_ERR(req))
771 return 0;
772
773 memset(&inarg, 0, sizeof(inarg));
774 inarg.block = block;
775 inarg.blocksize = inode->i_sb->s_blocksize;
776 req->in.h.opcode = FUSE_BMAP;
777 req->in.h.nodeid = get_node_id(inode);
778 req->in.numargs = 1;
779 req->in.args[0].size = sizeof(inarg);
780 req->in.args[0].value = &inarg;
781 req->out.numargs = 1;
782 req->out.args[0].size = sizeof(outarg);
783 req->out.args[0].value = &outarg;
784 request_send(fc, req);
785 err = req->out.h.error;
786 fuse_put_request(fc, req);
787 if (err == -ENOSYS)
788 fc->no_bmap = 1;
789
790 return err ? 0 : outarg.block;
791}
792
757static const struct file_operations fuse_file_operations = { 793static const struct file_operations fuse_file_operations = {
758 .llseek = generic_file_llseek, 794 .llseek = generic_file_llseek,
759 .read = do_sync_read, 795 .read = do_sync_read,
@@ -787,6 +823,7 @@ static const struct address_space_operations fuse_file_aops = {
787 .commit_write = fuse_commit_write, 823 .commit_write = fuse_commit_write,
788 .readpages = fuse_readpages, 824 .readpages = fuse_readpages,
789 .set_page_dirty = fuse_set_page_dirty, 825 .set_page_dirty = fuse_set_page_dirty,
826 .bmap = fuse_bmap,
790}; 827};
791 828
792void fuse_init_file_inode(struct inode *inode) 829void fuse_init_file_inode(struct inode *inode)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 91edb8932d90..b98b20de7405 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -298,6 +298,9 @@ struct fuse_conn {
298 reply, before any other request, and never cleared */ 298 reply, before any other request, and never cleared */
299 unsigned conn_error : 1; 299 unsigned conn_error : 1;
300 300
301 /** Connection successful. Only set in INIT */
302 unsigned conn_init : 1;
303
301 /** Do readpages asynchronously? Only set in INIT */ 304 /** Do readpages asynchronously? Only set in INIT */
302 unsigned async_read : 1; 305 unsigned async_read : 1;
303 306
@@ -339,6 +342,9 @@ struct fuse_conn {
339 /** Is interrupt not implemented by fs? */ 342 /** Is interrupt not implemented by fs? */
340 unsigned no_interrupt : 1; 343 unsigned no_interrupt : 1;
341 344
345 /** Is bmap not implemented by fs? */
346 unsigned no_bmap : 1;
347
342 /** The number of requests waiting for completion */ 348 /** The number of requests waiting for completion */
343 atomic_t num_waiting; 349 atomic_t num_waiting;
344 350
@@ -365,6 +371,9 @@ struct fuse_conn {
365 371
366 /** Key for lock owner ID scrambling */ 372 /** Key for lock owner ID scrambling */
367 u32 scramble_key[4]; 373 u32 scramble_key[4];
374
375 /** Reserved request for the DESTROY message */
376 struct fuse_req *destroy_req;
368}; 377};
369 378
370static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) 379static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index fc4203570370..12450d2b320e 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -22,7 +22,7 @@ MODULE_AUTHOR("Miklos Szeredi <miklos@szeredi.hu>");
22MODULE_DESCRIPTION("Filesystem in Userspace"); 22MODULE_DESCRIPTION("Filesystem in Userspace");
23MODULE_LICENSE("GPL"); 23MODULE_LICENSE("GPL");
24 24
25static kmem_cache_t *fuse_inode_cachep; 25static struct kmem_cache *fuse_inode_cachep;
26struct list_head fuse_conn_list; 26struct list_head fuse_conn_list;
27DEFINE_MUTEX(fuse_mutex); 27DEFINE_MUTEX(fuse_mutex);
28 28
@@ -39,6 +39,7 @@ struct fuse_mount_data {
39 unsigned group_id_present : 1; 39 unsigned group_id_present : 1;
40 unsigned flags; 40 unsigned flags;
41 unsigned max_read; 41 unsigned max_read;
42 unsigned blksize;
42}; 43};
43 44
44static struct inode *fuse_alloc_inode(struct super_block *sb) 45static struct inode *fuse_alloc_inode(struct super_block *sb)
@@ -46,7 +47,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb)
46 struct inode *inode; 47 struct inode *inode;
47 struct fuse_inode *fi; 48 struct fuse_inode *fi;
48 49
49 inode = kmem_cache_alloc(fuse_inode_cachep, SLAB_KERNEL); 50 inode = kmem_cache_alloc(fuse_inode_cachep, GFP_KERNEL);
50 if (!inode) 51 if (!inode)
51 return NULL; 52 return NULL;
52 53
@@ -205,10 +206,23 @@ static void fuse_umount_begin(struct vfsmount *vfsmnt, int flags)
205 fuse_abort_conn(get_fuse_conn_super(vfsmnt->mnt_sb)); 206 fuse_abort_conn(get_fuse_conn_super(vfsmnt->mnt_sb));
206} 207}
207 208
209static void fuse_send_destroy(struct fuse_conn *fc)
210{
211 struct fuse_req *req = fc->destroy_req;
212 if (req && fc->conn_init) {
213 fc->destroy_req = NULL;
214 req->in.h.opcode = FUSE_DESTROY;
215 req->force = 1;
216 request_send(fc, req);
217 fuse_put_request(fc, req);
218 }
219}
220
208static void fuse_put_super(struct super_block *sb) 221static void fuse_put_super(struct super_block *sb)
209{ 222{
210 struct fuse_conn *fc = get_fuse_conn_super(sb); 223 struct fuse_conn *fc = get_fuse_conn_super(sb);
211 224
225 fuse_send_destroy(fc);
212 spin_lock(&fc->lock); 226 spin_lock(&fc->lock);
213 fc->connected = 0; 227 fc->connected = 0;
214 fc->blocked = 0; 228 fc->blocked = 0;
@@ -274,6 +288,7 @@ enum {
274 OPT_DEFAULT_PERMISSIONS, 288 OPT_DEFAULT_PERMISSIONS,
275 OPT_ALLOW_OTHER, 289 OPT_ALLOW_OTHER,
276 OPT_MAX_READ, 290 OPT_MAX_READ,
291 OPT_BLKSIZE,
277 OPT_ERR 292 OPT_ERR
278}; 293};
279 294
@@ -285,14 +300,16 @@ static match_table_t tokens = {
285 {OPT_DEFAULT_PERMISSIONS, "default_permissions"}, 300 {OPT_DEFAULT_PERMISSIONS, "default_permissions"},
286 {OPT_ALLOW_OTHER, "allow_other"}, 301 {OPT_ALLOW_OTHER, "allow_other"},
287 {OPT_MAX_READ, "max_read=%u"}, 302 {OPT_MAX_READ, "max_read=%u"},
303 {OPT_BLKSIZE, "blksize=%u"},
288 {OPT_ERR, NULL} 304 {OPT_ERR, NULL}
289}; 305};
290 306
291static int parse_fuse_opt(char *opt, struct fuse_mount_data *d) 307static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev)
292{ 308{
293 char *p; 309 char *p;
294 memset(d, 0, sizeof(struct fuse_mount_data)); 310 memset(d, 0, sizeof(struct fuse_mount_data));
295 d->max_read = ~0; 311 d->max_read = ~0;
312 d->blksize = 512;
296 313
297 while ((p = strsep(&opt, ",")) != NULL) { 314 while ((p = strsep(&opt, ",")) != NULL) {
298 int token; 315 int token;
@@ -345,6 +362,12 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d)
345 d->max_read = value; 362 d->max_read = value;
346 break; 363 break;
347 364
365 case OPT_BLKSIZE:
366 if (!is_bdev || match_int(&args[0], &value))
367 return 0;
368 d->blksize = value;
369 break;
370
348 default: 371 default:
349 return 0; 372 return 0;
350 } 373 }
@@ -400,6 +423,8 @@ static struct fuse_conn *new_conn(void)
400void fuse_conn_put(struct fuse_conn *fc) 423void fuse_conn_put(struct fuse_conn *fc)
401{ 424{
402 if (atomic_dec_and_test(&fc->count)) { 425 if (atomic_dec_and_test(&fc->count)) {
426 if (fc->destroy_req)
427 fuse_request_free(fc->destroy_req);
403 mutex_destroy(&fc->inst_mutex); 428 mutex_destroy(&fc->inst_mutex);
404 kfree(fc); 429 kfree(fc);
405 } 430 }
@@ -456,6 +481,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
456 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages); 481 fc->bdi.ra_pages = min(fc->bdi.ra_pages, ra_pages);
457 fc->minor = arg->minor; 482 fc->minor = arg->minor;
458 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write; 483 fc->max_write = arg->minor < 5 ? 4096 : arg->max_write;
484 fc->conn_init = 1;
459 } 485 }
460 fuse_put_request(fc, req); 486 fuse_put_request(fc, req);
461 fc->blocked = 0; 487 fc->blocked = 0;
@@ -500,15 +526,23 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
500 struct dentry *root_dentry; 526 struct dentry *root_dentry;
501 struct fuse_req *init_req; 527 struct fuse_req *init_req;
502 int err; 528 int err;
529 int is_bdev = sb->s_bdev != NULL;
503 530
504 if (sb->s_flags & MS_MANDLOCK) 531 if (sb->s_flags & MS_MANDLOCK)
505 return -EINVAL; 532 return -EINVAL;
506 533
507 if (!parse_fuse_opt((char *) data, &d)) 534 if (!parse_fuse_opt((char *) data, &d, is_bdev))
508 return -EINVAL; 535 return -EINVAL;
509 536
510 sb->s_blocksize = PAGE_CACHE_SIZE; 537 if (is_bdev) {
511 sb->s_blocksize_bits = PAGE_CACHE_SHIFT; 538#ifdef CONFIG_BLOCK
539 if (!sb_set_blocksize(sb, d.blksize))
540 return -EINVAL;
541#endif
542 } else {
543 sb->s_blocksize = PAGE_CACHE_SIZE;
544 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
545 }
512 sb->s_magic = FUSE_SUPER_MAGIC; 546 sb->s_magic = FUSE_SUPER_MAGIC;
513 sb->s_op = &fuse_super_operations; 547 sb->s_op = &fuse_super_operations;
514 sb->s_maxbytes = MAX_LFS_FILESIZE; 548 sb->s_maxbytes = MAX_LFS_FILESIZE;
@@ -547,6 +581,12 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent)
547 if (!init_req) 581 if (!init_req)
548 goto err_put_root; 582 goto err_put_root;
549 583
584 if (is_bdev) {
585 fc->destroy_req = fuse_request_alloc();
586 if (!fc->destroy_req)
587 goto err_put_root;
588 }
589
550 mutex_lock(&fuse_mutex); 590 mutex_lock(&fuse_mutex);
551 err = -EINVAL; 591 err = -EINVAL;
552 if (file->private_data) 592 if (file->private_data)
@@ -598,10 +638,47 @@ static struct file_system_type fuse_fs_type = {
598 .kill_sb = kill_anon_super, 638 .kill_sb = kill_anon_super,
599}; 639};
600 640
641#ifdef CONFIG_BLOCK
642static int fuse_get_sb_blk(struct file_system_type *fs_type,
643 int flags, const char *dev_name,
644 void *raw_data, struct vfsmount *mnt)
645{
646 return get_sb_bdev(fs_type, flags, dev_name, raw_data, fuse_fill_super,
647 mnt);
648}
649
650static struct file_system_type fuseblk_fs_type = {
651 .owner = THIS_MODULE,
652 .name = "fuseblk",
653 .get_sb = fuse_get_sb_blk,
654 .kill_sb = kill_block_super,
655 .fs_flags = FS_REQUIRES_DEV,
656};
657
658static inline int register_fuseblk(void)
659{
660 return register_filesystem(&fuseblk_fs_type);
661}
662
663static inline void unregister_fuseblk(void)
664{
665 unregister_filesystem(&fuseblk_fs_type);
666}
667#else
668static inline int register_fuseblk(void)
669{
670 return 0;
671}
672
673static inline void unregister_fuseblk(void)
674{
675}
676#endif
677
601static decl_subsys(fuse, NULL, NULL); 678static decl_subsys(fuse, NULL, NULL);
602static decl_subsys(connections, NULL, NULL); 679static decl_subsys(connections, NULL, NULL);
603 680
604static void fuse_inode_init_once(void *foo, kmem_cache_t *cachep, 681static void fuse_inode_init_once(void *foo, struct kmem_cache *cachep,
605 unsigned long flags) 682 unsigned long flags)
606{ 683{
607 struct inode * inode = foo; 684 struct inode * inode = foo;
@@ -617,24 +694,34 @@ static int __init fuse_fs_init(void)
617 694
618 err = register_filesystem(&fuse_fs_type); 695 err = register_filesystem(&fuse_fs_type);
619 if (err) 696 if (err)
620 printk("fuse: failed to register filesystem\n"); 697 goto out;
621 else {
622 fuse_inode_cachep = kmem_cache_create("fuse_inode",
623 sizeof(struct fuse_inode),
624 0, SLAB_HWCACHE_ALIGN,
625 fuse_inode_init_once, NULL);
626 if (!fuse_inode_cachep) {
627 unregister_filesystem(&fuse_fs_type);
628 err = -ENOMEM;
629 }
630 }
631 698
699 err = register_fuseblk();
700 if (err)
701 goto out_unreg;
702
703 fuse_inode_cachep = kmem_cache_create("fuse_inode",
704 sizeof(struct fuse_inode),
705 0, SLAB_HWCACHE_ALIGN,
706 fuse_inode_init_once, NULL);
707 err = -ENOMEM;
708 if (!fuse_inode_cachep)
709 goto out_unreg2;
710
711 return 0;
712
713 out_unreg2:
714 unregister_fuseblk();
715 out_unreg:
716 unregister_filesystem(&fuse_fs_type);
717 out:
632 return err; 718 return err;
633} 719}
634 720
635static void fuse_fs_cleanup(void) 721static void fuse_fs_cleanup(void)
636{ 722{
637 unregister_filesystem(&fuse_fs_type); 723 unregister_filesystem(&fuse_fs_type);
724 unregister_fuseblk();
638 kmem_cache_destroy(fuse_inode_cachep); 725 kmem_cache_destroy(fuse_inode_cachep);
639} 726}
640 727
diff --git a/fs/gfs2/Kconfig b/fs/gfs2/Kconfig
index 8c27de8b9568..c0791cbacad9 100644
--- a/fs/gfs2/Kconfig
+++ b/fs/gfs2/Kconfig
@@ -2,6 +2,7 @@ config GFS2_FS
2 tristate "GFS2 file system support" 2 tristate "GFS2 file system support"
3 depends on EXPERIMENTAL 3 depends on EXPERIMENTAL
4 select FS_POSIX_ACL 4 select FS_POSIX_ACL
5 select CRC32
5 help 6 help
6 A cluster filesystem. 7 A cluster filesystem.
7 8
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index 5f959b8ce406..6e80844367ee 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -74,11 +74,11 @@ int gfs2_acl_validate_remove(struct gfs2_inode *ip, int access)
74{ 74{
75 if (!GFS2_SB(&ip->i_inode)->sd_args.ar_posix_acl) 75 if (!GFS2_SB(&ip->i_inode)->sd_args.ar_posix_acl)
76 return -EOPNOTSUPP; 76 return -EOPNOTSUPP;
77 if (current->fsuid != ip->i_di.di_uid && !capable(CAP_FOWNER)) 77 if (current->fsuid != ip->i_inode.i_uid && !capable(CAP_FOWNER))
78 return -EPERM; 78 return -EPERM;
79 if (S_ISLNK(ip->i_di.di_mode)) 79 if (S_ISLNK(ip->i_inode.i_mode))
80 return -EOPNOTSUPP; 80 return -EOPNOTSUPP;
81 if (!access && !S_ISDIR(ip->i_di.di_mode)) 81 if (!access && !S_ISDIR(ip->i_inode.i_mode))
82 return -EACCES; 82 return -EACCES;
83 83
84 return 0; 84 return 0;
@@ -145,14 +145,14 @@ out:
145} 145}
146 146
147/** 147/**
148 * gfs2_check_acl_locked - Check an ACL to see if we're allowed to do something 148 * gfs2_check_acl - Check an ACL to see if we're allowed to do something
149 * @inode: the file we want to do something to 149 * @inode: the file we want to do something to
150 * @mask: what we want to do 150 * @mask: what we want to do
151 * 151 *
152 * Returns: errno 152 * Returns: errno
153 */ 153 */
154 154
155int gfs2_check_acl_locked(struct inode *inode, int mask) 155int gfs2_check_acl(struct inode *inode, int mask)
156{ 156{
157 struct posix_acl *acl = NULL; 157 struct posix_acl *acl = NULL;
158 int error; 158 int error;
@@ -170,21 +170,6 @@ int gfs2_check_acl_locked(struct inode *inode, int mask)
170 return -EAGAIN; 170 return -EAGAIN;
171} 171}
172 172
173int gfs2_check_acl(struct inode *inode, int mask)
174{
175 struct gfs2_inode *ip = GFS2_I(inode);
176 struct gfs2_holder i_gh;
177 int error;
178
179 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
180 if (!error) {
181 error = gfs2_check_acl_locked(inode, mask);
182 gfs2_glock_dq_uninit(&i_gh);
183 }
184
185 return error;
186}
187
188static int munge_mode(struct gfs2_inode *ip, mode_t mode) 173static int munge_mode(struct gfs2_inode *ip, mode_t mode)
189{ 174{
190 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 175 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
@@ -198,10 +183,10 @@ static int munge_mode(struct gfs2_inode *ip, mode_t mode)
198 error = gfs2_meta_inode_buffer(ip, &dibh); 183 error = gfs2_meta_inode_buffer(ip, &dibh);
199 if (!error) { 184 if (!error) {
200 gfs2_assert_withdraw(sdp, 185 gfs2_assert_withdraw(sdp,
201 (ip->i_di.di_mode & S_IFMT) == (mode & S_IFMT)); 186 (ip->i_inode.i_mode & S_IFMT) == (mode & S_IFMT));
202 ip->i_di.di_mode = mode; 187 ip->i_inode.i_mode = mode;
203 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 188 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
204 gfs2_dinode_out(&ip->i_di, dibh->b_data); 189 gfs2_dinode_out(ip, dibh->b_data);
205 brelse(dibh); 190 brelse(dibh);
206 } 191 }
207 192
@@ -215,12 +200,12 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
215 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 200 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
216 struct posix_acl *acl = NULL, *clone; 201 struct posix_acl *acl = NULL, *clone;
217 struct gfs2_ea_request er; 202 struct gfs2_ea_request er;
218 mode_t mode = ip->i_di.di_mode; 203 mode_t mode = ip->i_inode.i_mode;
219 int error; 204 int error;
220 205
221 if (!sdp->sd_args.ar_posix_acl) 206 if (!sdp->sd_args.ar_posix_acl)
222 return 0; 207 return 0;
223 if (S_ISLNK(ip->i_di.di_mode)) 208 if (S_ISLNK(ip->i_inode.i_mode))
224 return 0; 209 return 0;
225 210
226 memset(&er, 0, sizeof(struct gfs2_ea_request)); 211 memset(&er, 0, sizeof(struct gfs2_ea_request));
@@ -232,7 +217,7 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
232 return error; 217 return error;
233 if (!acl) { 218 if (!acl) {
234 mode &= ~current->fs->umask; 219 mode &= ~current->fs->umask;
235 if (mode != ip->i_di.di_mode) 220 if (mode != ip->i_inode.i_mode)
236 error = munge_mode(ip, mode); 221 error = munge_mode(ip, mode);
237 return error; 222 return error;
238 } 223 }
@@ -244,7 +229,7 @@ int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip)
244 posix_acl_release(acl); 229 posix_acl_release(acl);
245 acl = clone; 230 acl = clone;
246 231
247 if (S_ISDIR(ip->i_di.di_mode)) { 232 if (S_ISDIR(ip->i_inode.i_mode)) {
248 er.er_name = GFS2_POSIX_ACL_DEFAULT; 233 er.er_name = GFS2_POSIX_ACL_DEFAULT;
249 er.er_name_len = GFS2_POSIX_ACL_DEFAULT_LEN; 234 er.er_name_len = GFS2_POSIX_ACL_DEFAULT_LEN;
250 error = gfs2_system_eaops.eo_set(ip, &er); 235 error = gfs2_system_eaops.eo_set(ip, &er);
diff --git a/fs/gfs2/acl.h b/fs/gfs2/acl.h
index 05c294fe0d78..6751930bfb64 100644
--- a/fs/gfs2/acl.h
+++ b/fs/gfs2/acl.h
@@ -31,7 +31,6 @@ int gfs2_acl_validate_set(struct gfs2_inode *ip, int access,
31 struct gfs2_ea_request *er, 31 struct gfs2_ea_request *er,
32 int *remove, mode_t *mode); 32 int *remove, mode_t *mode);
33int gfs2_acl_validate_remove(struct gfs2_inode *ip, int access); 33int gfs2_acl_validate_remove(struct gfs2_inode *ip, int access);
34int gfs2_check_acl_locked(struct inode *inode, int mask);
35int gfs2_check_acl(struct inode *inode, int mask); 34int gfs2_check_acl(struct inode *inode, int mask);
36int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip); 35int gfs2_acl_create(struct gfs2_inode *dip, struct gfs2_inode *ip);
37int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr); 36int gfs2_acl_chmod(struct gfs2_inode *ip, struct iattr *attr);
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 06e9a8cb45e9..8240c1ff94f4 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -38,8 +38,8 @@ struct metapath {
38}; 38};
39 39
40typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh, 40typedef int (*block_call_t) (struct gfs2_inode *ip, struct buffer_head *dibh,
41 struct buffer_head *bh, u64 *top, 41 struct buffer_head *bh, __be64 *top,
42 u64 *bottom, unsigned int height, 42 __be64 *bottom, unsigned int height,
43 void *data); 43 void *data);
44 44
45struct strip_mine { 45struct strip_mine {
@@ -163,6 +163,7 @@ int gfs2_unstuff_dinode(struct gfs2_inode *ip, struct page *page)
163 if (ip->i_di.di_size) { 163 if (ip->i_di.di_size) {
164 *(__be64 *)(di + 1) = cpu_to_be64(block); 164 *(__be64 *)(di + 1) = cpu_to_be64(block);
165 ip->i_di.di_blocks++; 165 ip->i_di.di_blocks++;
166 gfs2_set_inode_blocks(&ip->i_inode);
166 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); 167 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
167 } 168 }
168 169
@@ -230,7 +231,7 @@ static int build_height(struct inode *inode, unsigned height)
230 struct buffer_head *blocks[GFS2_MAX_META_HEIGHT]; 231 struct buffer_head *blocks[GFS2_MAX_META_HEIGHT];
231 struct gfs2_dinode *di; 232 struct gfs2_dinode *di;
232 int error; 233 int error;
233 u64 *bp; 234 __be64 *bp;
234 u64 bn; 235 u64 bn;
235 unsigned n; 236 unsigned n;
236 237
@@ -255,7 +256,7 @@ static int build_height(struct inode *inode, unsigned height)
255 GFS2_FORMAT_IN); 256 GFS2_FORMAT_IN);
256 gfs2_buffer_clear_tail(blocks[n], 257 gfs2_buffer_clear_tail(blocks[n],
257 sizeof(struct gfs2_meta_header)); 258 sizeof(struct gfs2_meta_header));
258 bp = (u64 *)(blocks[n]->b_data + 259 bp = (__be64 *)(blocks[n]->b_data +
259 sizeof(struct gfs2_meta_header)); 260 sizeof(struct gfs2_meta_header));
260 *bp = cpu_to_be64(blocks[n+1]->b_blocknr); 261 *bp = cpu_to_be64(blocks[n+1]->b_blocknr);
261 brelse(blocks[n]); 262 brelse(blocks[n]);
@@ -272,6 +273,7 @@ static int build_height(struct inode *inode, unsigned height)
272 *(__be64 *)(di + 1) = cpu_to_be64(bn); 273 *(__be64 *)(di + 1) = cpu_to_be64(bn);
273 ip->i_di.di_height += new_height; 274 ip->i_di.di_height += new_height;
274 ip->i_di.di_blocks += new_height; 275 ip->i_di.di_blocks += new_height;
276 gfs2_set_inode_blocks(&ip->i_inode);
275 di->di_height = cpu_to_be16(ip->i_di.di_height); 277 di->di_height = cpu_to_be16(ip->i_di.di_height);
276 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks); 278 di->di_blocks = cpu_to_be64(ip->i_di.di_blocks);
277 brelse(dibh); 279 brelse(dibh);
@@ -360,15 +362,15 @@ static void find_metapath(struct gfs2_inode *ip, u64 block,
360 * metadata tree. 362 * metadata tree.
361 */ 363 */
362 364
363static inline u64 *metapointer(struct buffer_head *bh, int *boundary, 365static inline __be64 *metapointer(struct buffer_head *bh, int *boundary,
364 unsigned int height, const struct metapath *mp) 366 unsigned int height, const struct metapath *mp)
365{ 367{
366 unsigned int head_size = (height > 0) ? 368 unsigned int head_size = (height > 0) ?
367 sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode); 369 sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_dinode);
368 u64 *ptr; 370 __be64 *ptr;
369 *boundary = 0; 371 *boundary = 0;
370 ptr = ((u64 *)(bh->b_data + head_size)) + mp->mp_list[height]; 372 ptr = ((__be64 *)(bh->b_data + head_size)) + mp->mp_list[height];
371 if (ptr + 1 == (u64 *)(bh->b_data + bh->b_size)) 373 if (ptr + 1 == (__be64 *)(bh->b_data + bh->b_size))
372 *boundary = 1; 374 *boundary = 1;
373 return ptr; 375 return ptr;
374} 376}
@@ -394,7 +396,7 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
394 int *new, u64 *block) 396 int *new, u64 *block)
395{ 397{
396 int boundary; 398 int boundary;
397 u64 *ptr = metapointer(bh, &boundary, height, mp); 399 __be64 *ptr = metapointer(bh, &boundary, height, mp);
398 400
399 if (*ptr) { 401 if (*ptr) {
400 *block = be64_to_cpu(*ptr); 402 *block = be64_to_cpu(*ptr);
@@ -415,17 +417,35 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
415 417
416 *ptr = cpu_to_be64(*block); 418 *ptr = cpu_to_be64(*block);
417 ip->i_di.di_blocks++; 419 ip->i_di.di_blocks++;
420 gfs2_set_inode_blocks(&ip->i_inode);
418 421
419 *new = 1; 422 *new = 1;
420 return 0; 423 return 0;
421} 424}
422 425
426static inline void bmap_lock(struct inode *inode, int create)
427{
428 struct gfs2_inode *ip = GFS2_I(inode);
429 if (create)
430 down_write(&ip->i_rw_mutex);
431 else
432 down_read(&ip->i_rw_mutex);
433}
434
435static inline void bmap_unlock(struct inode *inode, int create)
436{
437 struct gfs2_inode *ip = GFS2_I(inode);
438 if (create)
439 up_write(&ip->i_rw_mutex);
440 else
441 up_read(&ip->i_rw_mutex);
442}
443
423/** 444/**
424 * gfs2_block_pointers - Map a block from an inode to a disk block 445 * gfs2_block_map - Map a block from an inode to a disk block
425 * @inode: The inode 446 * @inode: The inode
426 * @lblock: The logical block number 447 * @lblock: The logical block number
427 * @map_bh: The bh to be mapped 448 * @bh_map: The bh to be mapped
428 * @mp: metapath to use
429 * 449 *
430 * Find the block number on the current device which corresponds to an 450 * Find the block number on the current device which corresponds to an
431 * inode's block. If the block had to be created, "new" will be set. 451 * inode's block. If the block had to be created, "new" will be set.
@@ -433,8 +453,8 @@ static int lookup_block(struct gfs2_inode *ip, struct buffer_head *bh,
433 * Returns: errno 453 * Returns: errno
434 */ 454 */
435 455
436static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create, 456int gfs2_block_map(struct inode *inode, u64 lblock, int create,
437 struct buffer_head *bh_map, struct metapath *mp) 457 struct buffer_head *bh_map)
438{ 458{
439 struct gfs2_inode *ip = GFS2_I(inode); 459 struct gfs2_inode *ip = GFS2_I(inode);
440 struct gfs2_sbd *sdp = GFS2_SB(inode); 460 struct gfs2_sbd *sdp = GFS2_SB(inode);
@@ -448,57 +468,61 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
448 u64 dblock = 0; 468 u64 dblock = 0;
449 int boundary; 469 int boundary;
450 unsigned int maxlen = bh_map->b_size >> inode->i_blkbits; 470 unsigned int maxlen = bh_map->b_size >> inode->i_blkbits;
471 struct metapath mp;
472 u64 size;
451 473
452 BUG_ON(maxlen == 0); 474 BUG_ON(maxlen == 0);
453 475
454 if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip))) 476 if (gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip)))
455 return 0; 477 return 0;
456 478
479 bmap_lock(inode, create);
480 clear_buffer_mapped(bh_map);
481 clear_buffer_new(bh_map);
482 clear_buffer_boundary(bh_map);
457 bsize = gfs2_is_dir(ip) ? sdp->sd_jbsize : sdp->sd_sb.sb_bsize; 483 bsize = gfs2_is_dir(ip) ? sdp->sd_jbsize : sdp->sd_sb.sb_bsize;
458 484 size = (lblock + 1) * bsize;
459 height = calc_tree_height(ip, (lblock + 1) * bsize); 485
460 if (ip->i_di.di_height < height) { 486 if (size > ip->i_di.di_size) {
461 if (!create) 487 height = calc_tree_height(ip, size);
462 return 0; 488 if (ip->i_di.di_height < height) {
463 489 if (!create)
464 error = build_height(inode, height); 490 goto out_ok;
465 if (error) 491
466 return error; 492 error = build_height(inode, height);
493 if (error)
494 goto out_fail;
495 }
467 } 496 }
468 497
469 find_metapath(ip, lblock, mp); 498 find_metapath(ip, lblock, &mp);
470 end_of_metadata = ip->i_di.di_height - 1; 499 end_of_metadata = ip->i_di.di_height - 1;
471
472 error = gfs2_meta_inode_buffer(ip, &bh); 500 error = gfs2_meta_inode_buffer(ip, &bh);
473 if (error) 501 if (error)
474 return error; 502 goto out_fail;
475 503
476 for (x = 0; x < end_of_metadata; x++) { 504 for (x = 0; x < end_of_metadata; x++) {
477 lookup_block(ip, bh, x, mp, create, &new, &dblock); 505 lookup_block(ip, bh, x, &mp, create, &new, &dblock);
478 brelse(bh); 506 brelse(bh);
479 if (!dblock) 507 if (!dblock)
480 return 0; 508 goto out_ok;
481 509
482 error = gfs2_meta_indirect_buffer(ip, x+1, dblock, new, &bh); 510 error = gfs2_meta_indirect_buffer(ip, x+1, dblock, new, &bh);
483 if (error) 511 if (error)
484 return error; 512 goto out_fail;
485 } 513 }
486 514
487 boundary = lookup_block(ip, bh, end_of_metadata, mp, create, &new, &dblock); 515 boundary = lookup_block(ip, bh, end_of_metadata, &mp, create, &new, &dblock);
488 clear_buffer_mapped(bh_map);
489 clear_buffer_new(bh_map);
490 clear_buffer_boundary(bh_map);
491
492 if (dblock) { 516 if (dblock) {
493 map_bh(bh_map, inode->i_sb, dblock); 517 map_bh(bh_map, inode->i_sb, dblock);
494 if (boundary) 518 if (boundary)
495 set_buffer_boundary(bh); 519 set_buffer_boundary(bh_map);
496 if (new) { 520 if (new) {
497 struct buffer_head *dibh; 521 struct buffer_head *dibh;
498 error = gfs2_meta_inode_buffer(ip, &dibh); 522 error = gfs2_meta_inode_buffer(ip, &dibh);
499 if (!error) { 523 if (!error) {
500 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 524 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
501 gfs2_dinode_out(&ip->i_di, dibh->b_data); 525 gfs2_dinode_out(ip, dibh->b_data);
502 brelse(dibh); 526 brelse(dibh);
503 } 527 }
504 set_buffer_new(bh_map); 528 set_buffer_new(bh_map);
@@ -507,8 +531,8 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
507 while(--maxlen && !buffer_boundary(bh_map)) { 531 while(--maxlen && !buffer_boundary(bh_map)) {
508 u64 eblock; 532 u64 eblock;
509 533
510 mp->mp_list[end_of_metadata]++; 534 mp.mp_list[end_of_metadata]++;
511 boundary = lookup_block(ip, bh, end_of_metadata, mp, 0, &new, &eblock); 535 boundary = lookup_block(ip, bh, end_of_metadata, &mp, 0, &new, &eblock);
512 if (eblock != ++dblock) 536 if (eblock != ++dblock)
513 break; 537 break;
514 bh_map->b_size += (1 << inode->i_blkbits); 538 bh_map->b_size += (1 << inode->i_blkbits);
@@ -518,43 +542,15 @@ static int gfs2_block_pointers(struct inode *inode, u64 lblock, int create,
518 } 542 }
519out_brelse: 543out_brelse:
520 brelse(bh); 544 brelse(bh);
521 return 0; 545out_ok:
522} 546 error = 0;
523 547out_fail:
524
525static inline void bmap_lock(struct inode *inode, int create)
526{
527 struct gfs2_inode *ip = GFS2_I(inode);
528 if (create)
529 down_write(&ip->i_rw_mutex);
530 else
531 down_read(&ip->i_rw_mutex);
532}
533
534static inline void bmap_unlock(struct inode *inode, int create)
535{
536 struct gfs2_inode *ip = GFS2_I(inode);
537 if (create)
538 up_write(&ip->i_rw_mutex);
539 else
540 up_read(&ip->i_rw_mutex);
541}
542
543int gfs2_block_map(struct inode *inode, u64 lblock, int create,
544 struct buffer_head *bh)
545{
546 struct metapath mp;
547 int ret;
548
549 bmap_lock(inode, create);
550 ret = gfs2_block_pointers(inode, lblock, create, bh, &mp);
551 bmap_unlock(inode, create); 548 bmap_unlock(inode, create);
552 return ret; 549 return error;
553} 550}
554 551
555int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen) 552int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsigned *extlen)
556{ 553{
557 struct metapath mp;
558 struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 }; 554 struct buffer_head bh = { .b_state = 0, .b_blocknr = 0 };
559 int ret; 555 int ret;
560 int create = *new; 556 int create = *new;
@@ -564,9 +560,7 @@ int gfs2_extent_map(struct inode *inode, u64 lblock, int *new, u64 *dblock, unsi
564 BUG_ON(!new); 560 BUG_ON(!new);
565 561
566 bh.b_size = 1 << (inode->i_blkbits + 5); 562 bh.b_size = 1 << (inode->i_blkbits + 5);
567 bmap_lock(inode, create); 563 ret = gfs2_block_map(inode, lblock, create, &bh);
568 ret = gfs2_block_pointers(inode, lblock, create, &bh, &mp);
569 bmap_unlock(inode, create);
570 *extlen = bh.b_size >> inode->i_blkbits; 564 *extlen = bh.b_size >> inode->i_blkbits;
571 *dblock = bh.b_blocknr; 565 *dblock = bh.b_blocknr;
572 if (buffer_new(&bh)) 566 if (buffer_new(&bh))
@@ -600,7 +594,7 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
600{ 594{
601 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 595 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
602 struct buffer_head *bh = NULL; 596 struct buffer_head *bh = NULL;
603 u64 *top, *bottom; 597 __be64 *top, *bottom;
604 u64 bn; 598 u64 bn;
605 int error; 599 int error;
606 int mh_size = sizeof(struct gfs2_meta_header); 600 int mh_size = sizeof(struct gfs2_meta_header);
@@ -611,17 +605,17 @@ static int recursive_scan(struct gfs2_inode *ip, struct buffer_head *dibh,
611 return error; 605 return error;
612 dibh = bh; 606 dibh = bh;
613 607
614 top = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0]; 608 top = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + mp->mp_list[0];
615 bottom = (u64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs; 609 bottom = (__be64 *)(bh->b_data + sizeof(struct gfs2_dinode)) + sdp->sd_diptrs;
616 } else { 610 } else {
617 error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh); 611 error = gfs2_meta_indirect_buffer(ip, height, block, 0, &bh);
618 if (error) 612 if (error)
619 return error; 613 return error;
620 614
621 top = (u64 *)(bh->b_data + mh_size) + 615 top = (__be64 *)(bh->b_data + mh_size) +
622 (first ? mp->mp_list[height] : 0); 616 (first ? mp->mp_list[height] : 0);
623 617
624 bottom = (u64 *)(bh->b_data + mh_size) + sdp->sd_inptrs; 618 bottom = (__be64 *)(bh->b_data + mh_size) + sdp->sd_inptrs;
625 } 619 }
626 620
627 error = bc(ip, dibh, bh, top, bottom, height, data); 621 error = bc(ip, dibh, bh, top, bottom, height, data);
@@ -660,7 +654,7 @@ out:
660 */ 654 */
661 655
662static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, 656static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
663 struct buffer_head *bh, u64 *top, u64 *bottom, 657 struct buffer_head *bh, __be64 *top, __be64 *bottom,
664 unsigned int height, void *data) 658 unsigned int height, void *data)
665{ 659{
666 struct strip_mine *sm = data; 660 struct strip_mine *sm = data;
@@ -668,7 +662,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
668 struct gfs2_rgrp_list rlist; 662 struct gfs2_rgrp_list rlist;
669 u64 bn, bstart; 663 u64 bn, bstart;
670 u32 blen; 664 u32 blen;
671 u64 *p; 665 __be64 *p;
672 unsigned int rg_blocks = 0; 666 unsigned int rg_blocks = 0;
673 int metadata; 667 int metadata;
674 unsigned int revokes = 0; 668 unsigned int revokes = 0;
@@ -770,6 +764,7 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
770 if (!ip->i_di.di_blocks) 764 if (!ip->i_di.di_blocks)
771 gfs2_consist_inode(ip); 765 gfs2_consist_inode(ip);
772 ip->i_di.di_blocks--; 766 ip->i_di.di_blocks--;
767 gfs2_set_inode_blocks(&ip->i_inode);
773 } 768 }
774 if (bstart) { 769 if (bstart) {
775 if (metadata) 770 if (metadata)
@@ -778,9 +773,9 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
778 gfs2_free_data(ip, bstart, blen); 773 gfs2_free_data(ip, bstart, blen);
779 } 774 }
780 775
781 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 776 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
782 777
783 gfs2_dinode_out(&ip->i_di, dibh->b_data); 778 gfs2_dinode_out(ip, dibh->b_data);
784 779
785 up_write(&ip->i_rw_mutex); 780 up_write(&ip->i_rw_mutex);
786 781
@@ -819,7 +814,7 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
819 if (error) 814 if (error)
820 goto out; 815 goto out;
821 816
822 error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid); 817 error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
823 if (error) 818 if (error)
824 goto out_gunlock_q; 819 goto out_gunlock_q;
825 820
@@ -853,14 +848,14 @@ static int do_grow(struct gfs2_inode *ip, u64 size)
853 } 848 }
854 849
855 ip->i_di.di_size = size; 850 ip->i_di.di_size = size;
856 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 851 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
857 852
858 error = gfs2_meta_inode_buffer(ip, &dibh); 853 error = gfs2_meta_inode_buffer(ip, &dibh);
859 if (error) 854 if (error)
860 goto out_end_trans; 855 goto out_end_trans;
861 856
862 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 857 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
863 gfs2_dinode_out(&ip->i_di, dibh->b_data); 858 gfs2_dinode_out(ip, dibh->b_data);
864 brelse(dibh); 859 brelse(dibh);
865 860
866out_end_trans: 861out_end_trans:
@@ -968,9 +963,9 @@ static int trunc_start(struct gfs2_inode *ip, u64 size)
968 963
969 if (gfs2_is_stuffed(ip)) { 964 if (gfs2_is_stuffed(ip)) {
970 ip->i_di.di_size = size; 965 ip->i_di.di_size = size;
971 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 966 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
972 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 967 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
973 gfs2_dinode_out(&ip->i_di, dibh->b_data); 968 gfs2_dinode_out(ip, dibh->b_data);
974 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode) + size); 969 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode) + size);
975 error = 1; 970 error = 1;
976 971
@@ -980,10 +975,10 @@ static int trunc_start(struct gfs2_inode *ip, u64 size)
980 975
981 if (!error) { 976 if (!error) {
982 ip->i_di.di_size = size; 977 ip->i_di.di_size = size;
983 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 978 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
984 ip->i_di.di_flags |= GFS2_DIF_TRUNC_IN_PROG; 979 ip->i_di.di_flags |= GFS2_DIF_TRUNC_IN_PROG;
985 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 980 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
986 gfs2_dinode_out(&ip->i_di, dibh->b_data); 981 gfs2_dinode_out(ip, dibh->b_data);
987 } 982 }
988 } 983 }
989 984
@@ -1053,11 +1048,11 @@ static int trunc_end(struct gfs2_inode *ip)
1053 ip->i_num.no_addr; 1048 ip->i_num.no_addr;
1054 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 1049 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
1055 } 1050 }
1056 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 1051 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
1057 ip->i_di.di_flags &= ~GFS2_DIF_TRUNC_IN_PROG; 1052 ip->i_di.di_flags &= ~GFS2_DIF_TRUNC_IN_PROG;
1058 1053
1059 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1054 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1060 gfs2_dinode_out(&ip->i_di, dibh->b_data); 1055 gfs2_dinode_out(ip, dibh->b_data);
1061 brelse(dibh); 1056 brelse(dibh);
1062 1057
1063out: 1058out:
@@ -1109,7 +1104,7 @@ int gfs2_truncatei(struct gfs2_inode *ip, u64 size)
1109{ 1104{
1110 int error; 1105 int error;
1111 1106
1112 if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_di.di_mode))) 1107 if (gfs2_assert_warn(GFS2_SB(&ip->i_inode), S_ISREG(ip->i_inode.i_mode)))
1113 return -EINVAL; 1108 return -EINVAL;
1114 1109
1115 if (size > ip->i_di.di_size) 1110 if (size > ip->i_di.di_size)
diff --git a/fs/gfs2/daemon.c b/fs/gfs2/daemon.c
index cab1f68d4685..683cb5bda870 100644
--- a/fs/gfs2/daemon.c
+++ b/fs/gfs2/daemon.c
@@ -112,6 +112,7 @@ int gfs2_logd(void *data)
112 struct gfs2_sbd *sdp = data; 112 struct gfs2_sbd *sdp = data;
113 struct gfs2_holder ji_gh; 113 struct gfs2_holder ji_gh;
114 unsigned long t; 114 unsigned long t;
115 int need_flush;
115 116
116 while (!kthread_should_stop()) { 117 while (!kthread_should_stop()) {
117 /* Advance the log tail */ 118 /* Advance the log tail */
@@ -120,8 +121,10 @@ int gfs2_logd(void *data)
120 gfs2_tune_get(sdp, gt_log_flush_secs) * HZ; 121 gfs2_tune_get(sdp, gt_log_flush_secs) * HZ;
121 122
122 gfs2_ail1_empty(sdp, DIO_ALL); 123 gfs2_ail1_empty(sdp, DIO_ALL);
123 124 gfs2_log_lock(sdp);
124 if (time_after_eq(jiffies, t)) { 125 need_flush = sdp->sd_log_num_buf > gfs2_tune_get(sdp, gt_incore_log_blocks);
126 gfs2_log_unlock(sdp);
127 if (need_flush || time_after_eq(jiffies, t)) {
125 gfs2_log_flush(sdp, NULL); 128 gfs2_log_flush(sdp, NULL);
126 sdp->sd_log_flush_time = jiffies; 129 sdp->sd_log_flush_time = jiffies;
127 } 130 }
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index e24af28b1a12..0fdcb7713cd9 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -131,8 +131,8 @@ static int gfs2_dir_write_stuffed(struct gfs2_inode *ip, const char *buf,
131 memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size); 131 memcpy(dibh->b_data + offset + sizeof(struct gfs2_dinode), buf, size);
132 if (ip->i_di.di_size < offset + size) 132 if (ip->i_di.di_size < offset + size)
133 ip->i_di.di_size = offset + size; 133 ip->i_di.di_size = offset + size;
134 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 134 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
135 gfs2_dinode_out(&ip->i_di, dibh->b_data); 135 gfs2_dinode_out(ip, dibh->b_data);
136 136
137 brelse(dibh); 137 brelse(dibh);
138 138
@@ -229,10 +229,10 @@ out:
229 229
230 if (ip->i_di.di_size < offset + copied) 230 if (ip->i_di.di_size < offset + copied)
231 ip->i_di.di_size = offset + copied; 231 ip->i_di.di_size = offset + copied;
232 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 232 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
233 233
234 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 234 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
235 gfs2_dinode_out(&ip->i_di, dibh->b_data); 235 gfs2_dinode_out(ip, dibh->b_data);
236 brelse(dibh); 236 brelse(dibh);
237 237
238 return copied; 238 return copied;
@@ -340,10 +340,15 @@ fail:
340 return (copied) ? copied : error; 340 return (copied) ? copied : error;
341} 341}
342 342
343static inline int gfs2_dirent_sentinel(const struct gfs2_dirent *dent)
344{
345 return dent->de_inum.no_addr == 0 || dent->de_inum.no_formal_ino == 0;
346}
347
343static inline int __gfs2_dirent_find(const struct gfs2_dirent *dent, 348static inline int __gfs2_dirent_find(const struct gfs2_dirent *dent,
344 const struct qstr *name, int ret) 349 const struct qstr *name, int ret)
345{ 350{
346 if (dent->de_inum.no_addr != 0 && 351 if (!gfs2_dirent_sentinel(dent) &&
347 be32_to_cpu(dent->de_hash) == name->hash && 352 be32_to_cpu(dent->de_hash) == name->hash &&
348 be16_to_cpu(dent->de_name_len) == name->len && 353 be16_to_cpu(dent->de_name_len) == name->len &&
349 memcmp(dent+1, name->name, name->len) == 0) 354 memcmp(dent+1, name->name, name->len) == 0)
@@ -388,7 +393,7 @@ static int gfs2_dirent_find_space(const struct gfs2_dirent *dent,
388 unsigned actual = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len)); 393 unsigned actual = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len));
389 unsigned totlen = be16_to_cpu(dent->de_rec_len); 394 unsigned totlen = be16_to_cpu(dent->de_rec_len);
390 395
391 if (!dent->de_inum.no_addr) 396 if (gfs2_dirent_sentinel(dent))
392 actual = GFS2_DIRENT_SIZE(0); 397 actual = GFS2_DIRENT_SIZE(0);
393 if (totlen - actual >= required) 398 if (totlen - actual >= required)
394 return 1; 399 return 1;
@@ -405,7 +410,7 @@ static int gfs2_dirent_gather(const struct gfs2_dirent *dent,
405 void *opaque) 410 void *opaque)
406{ 411{
407 struct dirent_gather *g = opaque; 412 struct dirent_gather *g = opaque;
408 if (dent->de_inum.no_addr) { 413 if (!gfs2_dirent_sentinel(dent)) {
409 g->pdent[g->offset++] = dent; 414 g->pdent[g->offset++] = dent;
410 } 415 }
411 return 0; 416 return 0;
@@ -433,10 +438,10 @@ static int gfs2_check_dirent(struct gfs2_dirent *dent, unsigned int offset,
433 if (unlikely(offset + size > len)) 438 if (unlikely(offset + size > len))
434 goto error; 439 goto error;
435 msg = "zero inode number"; 440 msg = "zero inode number";
436 if (unlikely(!first && !dent->de_inum.no_addr)) 441 if (unlikely(!first && gfs2_dirent_sentinel(dent)))
437 goto error; 442 goto error;
438 msg = "name length is greater than space in dirent"; 443 msg = "name length is greater than space in dirent";
439 if (dent->de_inum.no_addr && 444 if (!gfs2_dirent_sentinel(dent) &&
440 unlikely(sizeof(struct gfs2_dirent)+be16_to_cpu(dent->de_name_len) > 445 unlikely(sizeof(struct gfs2_dirent)+be16_to_cpu(dent->de_name_len) >
441 size)) 446 size))
442 goto error; 447 goto error;
@@ -598,7 +603,7 @@ static int dirent_next(struct gfs2_inode *dip, struct buffer_head *bh,
598 return ret; 603 return ret;
599 604
600 /* Only the first dent could ever have de_inum.no_addr == 0 */ 605 /* Only the first dent could ever have de_inum.no_addr == 0 */
601 if (!tmp->de_inum.no_addr) { 606 if (gfs2_dirent_sentinel(tmp)) {
602 gfs2_consist_inode(dip); 607 gfs2_consist_inode(dip);
603 return -EIO; 608 return -EIO;
604 } 609 }
@@ -621,7 +626,7 @@ static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh,
621{ 626{
622 u16 cur_rec_len, prev_rec_len; 627 u16 cur_rec_len, prev_rec_len;
623 628
624 if (!cur->de_inum.no_addr) { 629 if (gfs2_dirent_sentinel(cur)) {
625 gfs2_consist_inode(dip); 630 gfs2_consist_inode(dip);
626 return; 631 return;
627 } 632 }
@@ -633,7 +638,8 @@ static void dirent_del(struct gfs2_inode *dip, struct buffer_head *bh,
633 out the inode number and return. */ 638 out the inode number and return. */
634 639
635 if (!prev) { 640 if (!prev) {
636 cur->de_inum.no_addr = 0; /* No endianess worries */ 641 cur->de_inum.no_addr = 0;
642 cur->de_inum.no_formal_ino = 0;
637 return; 643 return;
638 } 644 }
639 645
@@ -664,7 +670,7 @@ static struct gfs2_dirent *gfs2_init_dirent(struct inode *inode,
664 struct gfs2_dirent *ndent; 670 struct gfs2_dirent *ndent;
665 unsigned offset = 0, totlen; 671 unsigned offset = 0, totlen;
666 672
667 if (dent->de_inum.no_addr) 673 if (!gfs2_dirent_sentinel(dent))
668 offset = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len)); 674 offset = GFS2_DIRENT_SIZE(be16_to_cpu(dent->de_name_len));
669 totlen = be16_to_cpu(dent->de_rec_len); 675 totlen = be16_to_cpu(dent->de_rec_len);
670 BUG_ON(offset + name->len > totlen); 676 BUG_ON(offset + name->len > totlen);
@@ -713,12 +719,12 @@ static int get_leaf(struct gfs2_inode *dip, u64 leaf_no,
713static int get_leaf_nr(struct gfs2_inode *dip, u32 index, 719static int get_leaf_nr(struct gfs2_inode *dip, u32 index,
714 u64 *leaf_out) 720 u64 *leaf_out)
715{ 721{
716 u64 leaf_no; 722 __be64 leaf_no;
717 int error; 723 int error;
718 724
719 error = gfs2_dir_read_data(dip, (char *)&leaf_no, 725 error = gfs2_dir_read_data(dip, (char *)&leaf_no,
720 index * sizeof(u64), 726 index * sizeof(__be64),
721 sizeof(u64), 0); 727 sizeof(__be64), 0);
722 if (error != sizeof(u64)) 728 if (error != sizeof(u64))
723 return (error < 0) ? error : -EIO; 729 return (error < 0) ? error : -EIO;
724 730
@@ -837,7 +843,8 @@ static int dir_make_exhash(struct inode *inode)
837 struct gfs2_leaf *leaf; 843 struct gfs2_leaf *leaf;
838 int y; 844 int y;
839 u32 x; 845 u32 x;
840 u64 *lp, bn; 846 __be64 *lp;
847 u64 bn;
841 int error; 848 int error;
842 849
843 error = gfs2_meta_inode_buffer(dip, &dibh); 850 error = gfs2_meta_inode_buffer(dip, &dibh);
@@ -893,20 +900,20 @@ static int dir_make_exhash(struct inode *inode)
893 gfs2_trans_add_bh(dip->i_gl, dibh, 1); 900 gfs2_trans_add_bh(dip->i_gl, dibh, 1);
894 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode)); 901 gfs2_buffer_clear_tail(dibh, sizeof(struct gfs2_dinode));
895 902
896 lp = (u64 *)(dibh->b_data + sizeof(struct gfs2_dinode)); 903 lp = (__be64 *)(dibh->b_data + sizeof(struct gfs2_dinode));
897 904
898 for (x = sdp->sd_hash_ptrs; x--; lp++) 905 for (x = sdp->sd_hash_ptrs; x--; lp++)
899 *lp = cpu_to_be64(bn); 906 *lp = cpu_to_be64(bn);
900 907
901 dip->i_di.di_size = sdp->sd_sb.sb_bsize / 2; 908 dip->i_di.di_size = sdp->sd_sb.sb_bsize / 2;
902 dip->i_di.di_blocks++; 909 dip->i_di.di_blocks++;
910 gfs2_set_inode_blocks(&dip->i_inode);
903 dip->i_di.di_flags |= GFS2_DIF_EXHASH; 911 dip->i_di.di_flags |= GFS2_DIF_EXHASH;
904 dip->i_di.di_payload_format = 0;
905 912
906 for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ; 913 for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ;
907 dip->i_di.di_depth = y; 914 dip->i_di.di_depth = y;
908 915
909 gfs2_dinode_out(&dip->i_di, dibh->b_data); 916 gfs2_dinode_out(dip, dibh->b_data);
910 917
911 brelse(dibh); 918 brelse(dibh);
912 919
@@ -929,7 +936,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
929 struct gfs2_leaf *nleaf, *oleaf; 936 struct gfs2_leaf *nleaf, *oleaf;
930 struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new; 937 struct gfs2_dirent *dent = NULL, *prev = NULL, *next = NULL, *new;
931 u32 start, len, half_len, divider; 938 u32 start, len, half_len, divider;
932 u64 bn, *lp, leaf_no; 939 u64 bn, leaf_no;
940 __be64 *lp;
933 u32 index; 941 u32 index;
934 int x, moved = 0; 942 int x, moved = 0;
935 int error; 943 int error;
@@ -974,7 +982,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
974 /* Change the pointers. 982 /* Change the pointers.
975 Don't bother distinguishing stuffed from non-stuffed. 983 Don't bother distinguishing stuffed from non-stuffed.
976 This code is complicated enough already. */ 984 This code is complicated enough already. */
977 lp = kmalloc(half_len * sizeof(u64), GFP_NOFS | __GFP_NOFAIL); 985 lp = kmalloc(half_len * sizeof(__be64), GFP_NOFS | __GFP_NOFAIL);
978 /* Change the pointers */ 986 /* Change the pointers */
979 for (x = 0; x < half_len; x++) 987 for (x = 0; x < half_len; x++)
980 lp[x] = cpu_to_be64(bn); 988 lp[x] = cpu_to_be64(bn);
@@ -1000,7 +1008,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
1000 if (dirent_next(dip, obh, &next)) 1008 if (dirent_next(dip, obh, &next))
1001 next = NULL; 1009 next = NULL;
1002 1010
1003 if (dent->de_inum.no_addr && 1011 if (!gfs2_dirent_sentinel(dent) &&
1004 be32_to_cpu(dent->de_hash) < divider) { 1012 be32_to_cpu(dent->de_hash) < divider) {
1005 struct qstr str; 1013 struct qstr str;
1006 str.name = (char*)(dent+1); 1014 str.name = (char*)(dent+1);
@@ -1037,7 +1045,8 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
1037 error = gfs2_meta_inode_buffer(dip, &dibh); 1045 error = gfs2_meta_inode_buffer(dip, &dibh);
1038 if (!gfs2_assert_withdraw(GFS2_SB(&dip->i_inode), !error)) { 1046 if (!gfs2_assert_withdraw(GFS2_SB(&dip->i_inode), !error)) {
1039 dip->i_di.di_blocks++; 1047 dip->i_di.di_blocks++;
1040 gfs2_dinode_out(&dip->i_di, dibh->b_data); 1048 gfs2_set_inode_blocks(&dip->i_inode);
1049 gfs2_dinode_out(dip, dibh->b_data);
1041 brelse(dibh); 1050 brelse(dibh);
1042 } 1051 }
1043 1052
@@ -1117,7 +1126,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
1117 error = gfs2_meta_inode_buffer(dip, &dibh); 1126 error = gfs2_meta_inode_buffer(dip, &dibh);
1118 if (!gfs2_assert_withdraw(sdp, !error)) { 1127 if (!gfs2_assert_withdraw(sdp, !error)) {
1119 dip->i_di.di_depth++; 1128 dip->i_di.di_depth++;
1120 gfs2_dinode_out(&dip->i_di, dibh->b_data); 1129 gfs2_dinode_out(dip, dibh->b_data);
1121 brelse(dibh); 1130 brelse(dibh);
1122 } 1131 }
1123 1132
@@ -1194,7 +1203,7 @@ static int do_filldir_main(struct gfs2_inode *dip, u64 *offset,
1194 int *copied) 1203 int *copied)
1195{ 1204{
1196 const struct gfs2_dirent *dent, *dent_next; 1205 const struct gfs2_dirent *dent, *dent_next;
1197 struct gfs2_inum inum; 1206 struct gfs2_inum_host inum;
1198 u64 off, off_next; 1207 u64 off, off_next;
1199 unsigned int x, y; 1208 unsigned int x, y;
1200 int run = 0; 1209 int run = 0;
@@ -1341,7 +1350,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
1341 u32 hsize, len = 0; 1350 u32 hsize, len = 0;
1342 u32 ht_offset, lp_offset, ht_offset_cur = -1; 1351 u32 ht_offset, lp_offset, ht_offset_cur = -1;
1343 u32 hash, index; 1352 u32 hash, index;
1344 u64 *lp; 1353 __be64 *lp;
1345 int copied = 0; 1354 int copied = 0;
1346 int error = 0; 1355 int error = 0;
1347 unsigned depth = 0; 1356 unsigned depth = 0;
@@ -1365,7 +1374,7 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
1365 1374
1366 if (ht_offset_cur != ht_offset) { 1375 if (ht_offset_cur != ht_offset) {
1367 error = gfs2_dir_read_data(dip, (char *)lp, 1376 error = gfs2_dir_read_data(dip, (char *)lp,
1368 ht_offset * sizeof(u64), 1377 ht_offset * sizeof(__be64),
1369 sdp->sd_hash_bsize, 1); 1378 sdp->sd_hash_bsize, 1);
1370 if (error != sdp->sd_hash_bsize) { 1379 if (error != sdp->sd_hash_bsize) {
1371 if (error >= 0) 1380 if (error >= 0)
@@ -1456,7 +1465,7 @@ out:
1456 */ 1465 */
1457 1466
1458int gfs2_dir_search(struct inode *dir, const struct qstr *name, 1467int gfs2_dir_search(struct inode *dir, const struct qstr *name,
1459 struct gfs2_inum *inum, unsigned int *type) 1468 struct gfs2_inum_host *inum, unsigned int *type)
1460{ 1469{
1461 struct buffer_head *bh; 1470 struct buffer_head *bh;
1462 struct gfs2_dirent *dent; 1471 struct gfs2_dirent *dent;
@@ -1515,7 +1524,8 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name)
1515 return error; 1524 return error;
1516 gfs2_trans_add_bh(ip->i_gl, bh, 1); 1525 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1517 ip->i_di.di_blocks++; 1526 ip->i_di.di_blocks++;
1518 gfs2_dinode_out(&ip->i_di, bh->b_data); 1527 gfs2_set_inode_blocks(&ip->i_inode);
1528 gfs2_dinode_out(ip, bh->b_data);
1519 brelse(bh); 1529 brelse(bh);
1520 return 0; 1530 return 0;
1521} 1531}
@@ -1531,7 +1541,7 @@ static int dir_new_leaf(struct inode *inode, const struct qstr *name)
1531 */ 1541 */
1532 1542
1533int gfs2_dir_add(struct inode *inode, const struct qstr *name, 1543int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1534 const struct gfs2_inum *inum, unsigned type) 1544 const struct gfs2_inum_host *inum, unsigned type)
1535{ 1545{
1536 struct gfs2_inode *ip = GFS2_I(inode); 1546 struct gfs2_inode *ip = GFS2_I(inode);
1537 struct buffer_head *bh; 1547 struct buffer_head *bh;
@@ -1558,8 +1568,8 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
1558 break; 1568 break;
1559 gfs2_trans_add_bh(ip->i_gl, bh, 1); 1569 gfs2_trans_add_bh(ip->i_gl, bh, 1);
1560 ip->i_di.di_entries++; 1570 ip->i_di.di_entries++;
1561 ip->i_di.di_mtime = ip->i_di.di_ctime = get_seconds(); 1571 ip->i_inode.i_mtime.tv_sec = ip->i_inode.i_ctime.tv_sec = get_seconds();
1562 gfs2_dinode_out(&ip->i_di, bh->b_data); 1572 gfs2_dinode_out(ip, bh->b_data);
1563 brelse(bh); 1573 brelse(bh);
1564 error = 0; 1574 error = 0;
1565 break; 1575 break;
@@ -1644,8 +1654,8 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
1644 gfs2_consist_inode(dip); 1654 gfs2_consist_inode(dip);
1645 gfs2_trans_add_bh(dip->i_gl, bh, 1); 1655 gfs2_trans_add_bh(dip->i_gl, bh, 1);
1646 dip->i_di.di_entries--; 1656 dip->i_di.di_entries--;
1647 dip->i_di.di_mtime = dip->i_di.di_ctime = get_seconds(); 1657 dip->i_inode.i_mtime.tv_sec = dip->i_inode.i_ctime.tv_sec = get_seconds();
1648 gfs2_dinode_out(&dip->i_di, bh->b_data); 1658 gfs2_dinode_out(dip, bh->b_data);
1649 brelse(bh); 1659 brelse(bh);
1650 mark_inode_dirty(&dip->i_inode); 1660 mark_inode_dirty(&dip->i_inode);
1651 1661
@@ -1666,7 +1676,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *name)
1666 */ 1676 */
1667 1677
1668int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, 1678int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
1669 struct gfs2_inum *inum, unsigned int new_type) 1679 struct gfs2_inum_host *inum, unsigned int new_type)
1670{ 1680{
1671 struct buffer_head *bh; 1681 struct buffer_head *bh;
1672 struct gfs2_dirent *dent; 1682 struct gfs2_dirent *dent;
@@ -1692,8 +1702,8 @@ int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
1692 gfs2_trans_add_bh(dip->i_gl, bh, 1); 1702 gfs2_trans_add_bh(dip->i_gl, bh, 1);
1693 } 1703 }
1694 1704
1695 dip->i_di.di_mtime = dip->i_di.di_ctime = get_seconds(); 1705 dip->i_inode.i_mtime.tv_sec = dip->i_inode.i_ctime.tv_sec = get_seconds();
1696 gfs2_dinode_out(&dip->i_di, bh->b_data); 1706 gfs2_dinode_out(dip, bh->b_data);
1697 brelse(bh); 1707 brelse(bh);
1698 return 0; 1708 return 0;
1699} 1709}
@@ -1715,7 +1725,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
1715 u32 hsize, len; 1725 u32 hsize, len;
1716 u32 ht_offset, lp_offset, ht_offset_cur = -1; 1726 u32 ht_offset, lp_offset, ht_offset_cur = -1;
1717 u32 index = 0; 1727 u32 index = 0;
1718 u64 *lp; 1728 __be64 *lp;
1719 u64 leaf_no; 1729 u64 leaf_no;
1720 int error = 0; 1730 int error = 0;
1721 1731
@@ -1735,7 +1745,7 @@ static int foreach_leaf(struct gfs2_inode *dip, leaf_call_t lc, void *data)
1735 1745
1736 if (ht_offset_cur != ht_offset) { 1746 if (ht_offset_cur != ht_offset) {
1737 error = gfs2_dir_read_data(dip, (char *)lp, 1747 error = gfs2_dir_read_data(dip, (char *)lp,
1738 ht_offset * sizeof(u64), 1748 ht_offset * sizeof(__be64),
1739 sdp->sd_hash_bsize, 1); 1749 sdp->sd_hash_bsize, 1);
1740 if (error != sdp->sd_hash_bsize) { 1750 if (error != sdp->sd_hash_bsize) {
1741 if (error >= 0) 1751 if (error >= 0)
@@ -1859,6 +1869,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
1859 if (!dip->i_di.di_blocks) 1869 if (!dip->i_di.di_blocks)
1860 gfs2_consist_inode(dip); 1870 gfs2_consist_inode(dip);
1861 dip->i_di.di_blocks--; 1871 dip->i_di.di_blocks--;
1872 gfs2_set_inode_blocks(&dip->i_inode);
1862 } 1873 }
1863 1874
1864 error = gfs2_dir_write_data(dip, ht, index * sizeof(u64), size); 1875 error = gfs2_dir_write_data(dip, ht, index * sizeof(u64), size);
@@ -1873,7 +1884,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len,
1873 goto out_end_trans; 1884 goto out_end_trans;
1874 1885
1875 gfs2_trans_add_bh(dip->i_gl, dibh, 1); 1886 gfs2_trans_add_bh(dip->i_gl, dibh, 1);
1876 gfs2_dinode_out(&dip->i_di, dibh->b_data); 1887 gfs2_dinode_out(dip, dibh->b_data);
1877 brelse(dibh); 1888 brelse(dibh);
1878 1889
1879out_end_trans: 1890out_end_trans:
diff --git a/fs/gfs2/dir.h b/fs/gfs2/dir.h
index 371233419b07..b21b33668a5b 100644
--- a/fs/gfs2/dir.h
+++ b/fs/gfs2/dir.h
@@ -31,17 +31,17 @@ struct gfs2_inum;
31typedef int (*gfs2_filldir_t) (void *opaque, 31typedef int (*gfs2_filldir_t) (void *opaque,
32 const char *name, unsigned int length, 32 const char *name, unsigned int length,
33 u64 offset, 33 u64 offset,
34 struct gfs2_inum *inum, unsigned int type); 34 struct gfs2_inum_host *inum, unsigned int type);
35 35
36int gfs2_dir_search(struct inode *dir, const struct qstr *filename, 36int gfs2_dir_search(struct inode *dir, const struct qstr *filename,
37 struct gfs2_inum *inum, unsigned int *type); 37 struct gfs2_inum_host *inum, unsigned int *type);
38int gfs2_dir_add(struct inode *inode, const struct qstr *filename, 38int gfs2_dir_add(struct inode *inode, const struct qstr *filename,
39 const struct gfs2_inum *inum, unsigned int type); 39 const struct gfs2_inum_host *inum, unsigned int type);
40int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *filename); 40int gfs2_dir_del(struct gfs2_inode *dip, const struct qstr *filename);
41int gfs2_dir_read(struct inode *inode, u64 * offset, void *opaque, 41int gfs2_dir_read(struct inode *inode, u64 * offset, void *opaque,
42 gfs2_filldir_t filldir); 42 gfs2_filldir_t filldir);
43int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename, 43int gfs2_dir_mvino(struct gfs2_inode *dip, const struct qstr *filename,
44 struct gfs2_inum *new_inum, unsigned int new_type); 44 struct gfs2_inum_host *new_inum, unsigned int new_type);
45 45
46int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip); 46int gfs2_dir_exhash_dealloc(struct gfs2_inode *dip);
47 47
diff --git a/fs/gfs2/eaops.c b/fs/gfs2/eaops.c
index 92c54e9b0dc3..cd747c00f670 100644
--- a/fs/gfs2/eaops.c
+++ b/fs/gfs2/eaops.c
@@ -120,7 +120,7 @@ static int system_eo_set(struct gfs2_inode *ip, struct gfs2_ea_request *er)
120 120
121 if (GFS2_ACL_IS_ACCESS(er->er_name, er->er_name_len)) { 121 if (GFS2_ACL_IS_ACCESS(er->er_name, er->er_name_len)) {
122 if (!(er->er_flags & GFS2_ERF_MODE)) { 122 if (!(er->er_flags & GFS2_ERF_MODE)) {
123 er->er_mode = ip->i_di.di_mode; 123 er->er_mode = ip->i_inode.i_mode;
124 er->er_flags |= GFS2_ERF_MODE; 124 er->er_flags |= GFS2_ERF_MODE;
125 } 125 }
126 error = gfs2_acl_validate_set(ip, 1, er, 126 error = gfs2_acl_validate_set(ip, 1, er,
diff --git a/fs/gfs2/eattr.c b/fs/gfs2/eattr.c
index a65a4ccfd4dd..ebebbdcd7057 100644
--- a/fs/gfs2/eattr.c
+++ b/fs/gfs2/eattr.c
@@ -112,7 +112,7 @@ fail:
112static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data) 112static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
113{ 113{
114 struct buffer_head *bh, *eabh; 114 struct buffer_head *bh, *eabh;
115 u64 *eablk, *end; 115 __be64 *eablk, *end;
116 int error; 116 int error;
117 117
118 error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT, &bh); 118 error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT, &bh);
@@ -129,7 +129,7 @@ static int ea_foreach(struct gfs2_inode *ip, ea_call_t ea_call, void *data)
129 goto out; 129 goto out;
130 } 130 }
131 131
132 eablk = (u64 *)(bh->b_data + sizeof(struct gfs2_meta_header)); 132 eablk = (__be64 *)(bh->b_data + sizeof(struct gfs2_meta_header));
133 end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs; 133 end = eablk + GFS2_SB(&ip->i_inode)->sd_inptrs;
134 134
135 for (; eablk < end; eablk++) { 135 for (; eablk < end; eablk++) {
@@ -224,7 +224,8 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
224 struct gfs2_rgrpd *rgd; 224 struct gfs2_rgrpd *rgd;
225 struct gfs2_holder rg_gh; 225 struct gfs2_holder rg_gh;
226 struct buffer_head *dibh; 226 struct buffer_head *dibh;
227 u64 *dataptrs, bn = 0; 227 __be64 *dataptrs;
228 u64 bn = 0;
228 u64 bstart = 0; 229 u64 bstart = 0;
229 unsigned int blen = 0; 230 unsigned int blen = 0;
230 unsigned int blks = 0; 231 unsigned int blks = 0;
@@ -280,6 +281,7 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
280 if (!ip->i_di.di_blocks) 281 if (!ip->i_di.di_blocks)
281 gfs2_consist_inode(ip); 282 gfs2_consist_inode(ip);
282 ip->i_di.di_blocks--; 283 ip->i_di.di_blocks--;
284 gfs2_set_inode_blocks(&ip->i_inode);
283 } 285 }
284 if (bstart) 286 if (bstart)
285 gfs2_free_meta(ip, bstart, blen); 287 gfs2_free_meta(ip, bstart, blen);
@@ -299,9 +301,9 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh,
299 301
300 error = gfs2_meta_inode_buffer(ip, &dibh); 302 error = gfs2_meta_inode_buffer(ip, &dibh);
301 if (!error) { 303 if (!error) {
302 ip->i_di.di_ctime = get_seconds(); 304 ip->i_inode.i_ctime.tv_sec = get_seconds();
303 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 305 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
304 gfs2_dinode_out(&ip->i_di, dibh->b_data); 306 gfs2_dinode_out(ip, dibh->b_data);
305 brelse(dibh); 307 brelse(dibh);
306 } 308 }
307 309
@@ -444,7 +446,7 @@ static int ea_get_unstuffed(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
444 struct buffer_head **bh; 446 struct buffer_head **bh;
445 unsigned int amount = GFS2_EA_DATA_LEN(ea); 447 unsigned int amount = GFS2_EA_DATA_LEN(ea);
446 unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize); 448 unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
447 u64 *dataptrs = GFS2_EA2DATAPTRS(ea); 449 __be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
448 unsigned int x; 450 unsigned int x;
449 int error = 0; 451 int error = 0;
450 452
@@ -597,6 +599,7 @@ static int ea_alloc_blk(struct gfs2_inode *ip, struct buffer_head **bhp)
597 ea->ea_num_ptrs = 0; 599 ea->ea_num_ptrs = 0;
598 600
599 ip->i_di.di_blocks++; 601 ip->i_di.di_blocks++;
602 gfs2_set_inode_blocks(&ip->i_inode);
600 603
601 return 0; 604 return 0;
602} 605}
@@ -629,7 +632,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
629 ea->ea_num_ptrs = 0; 632 ea->ea_num_ptrs = 0;
630 memcpy(GFS2_EA2DATA(ea), er->er_data, er->er_data_len); 633 memcpy(GFS2_EA2DATA(ea), er->er_data, er->er_data_len);
631 } else { 634 } else {
632 u64 *dataptr = GFS2_EA2DATAPTRS(ea); 635 __be64 *dataptr = GFS2_EA2DATAPTRS(ea);
633 const char *data = er->er_data; 636 const char *data = er->er_data;
634 unsigned int data_len = er->er_data_len; 637 unsigned int data_len = er->er_data_len;
635 unsigned int copy; 638 unsigned int copy;
@@ -648,6 +651,7 @@ static int ea_write(struct gfs2_inode *ip, struct gfs2_ea_header *ea,
648 gfs2_metatype_set(bh, GFS2_METATYPE_ED, GFS2_FORMAT_ED); 651 gfs2_metatype_set(bh, GFS2_METATYPE_ED, GFS2_FORMAT_ED);
649 652
650 ip->i_di.di_blocks++; 653 ip->i_di.di_blocks++;
654 gfs2_set_inode_blocks(&ip->i_inode);
651 655
652 copy = data_len > sdp->sd_jbsize ? sdp->sd_jbsize : 656 copy = data_len > sdp->sd_jbsize ? sdp->sd_jbsize :
653 data_len; 657 data_len;
@@ -686,7 +690,7 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
686 if (error) 690 if (error)
687 goto out; 691 goto out;
688 692
689 error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid); 693 error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
690 if (error) 694 if (error)
691 goto out_gunlock_q; 695 goto out_gunlock_q;
692 696
@@ -710,13 +714,13 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
710 if (!error) { 714 if (!error) {
711 if (er->er_flags & GFS2_ERF_MODE) { 715 if (er->er_flags & GFS2_ERF_MODE) {
712 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), 716 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode),
713 (ip->i_di.di_mode & S_IFMT) == 717 (ip->i_inode.i_mode & S_IFMT) ==
714 (er->er_mode & S_IFMT)); 718 (er->er_mode & S_IFMT));
715 ip->i_di.di_mode = er->er_mode; 719 ip->i_inode.i_mode = er->er_mode;
716 } 720 }
717 ip->i_di.di_ctime = get_seconds(); 721 ip->i_inode.i_ctime.tv_sec = get_seconds();
718 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 722 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
719 gfs2_dinode_out(&ip->i_di, dibh->b_data); 723 gfs2_dinode_out(ip, dibh->b_data);
720 brelse(dibh); 724 brelse(dibh);
721 } 725 }
722 726
@@ -846,12 +850,12 @@ static int ea_set_simple_noalloc(struct gfs2_inode *ip, struct buffer_head *bh,
846 850
847 if (er->er_flags & GFS2_ERF_MODE) { 851 if (er->er_flags & GFS2_ERF_MODE) {
848 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), 852 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode),
849 (ip->i_di.di_mode & S_IFMT) == (er->er_mode & S_IFMT)); 853 (ip->i_inode.i_mode & S_IFMT) == (er->er_mode & S_IFMT));
850 ip->i_di.di_mode = er->er_mode; 854 ip->i_inode.i_mode = er->er_mode;
851 } 855 }
852 ip->i_di.di_ctime = get_seconds(); 856 ip->i_inode.i_ctime.tv_sec = get_seconds();
853 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 857 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
854 gfs2_dinode_out(&ip->i_di, dibh->b_data); 858 gfs2_dinode_out(ip, dibh->b_data);
855 brelse(dibh); 859 brelse(dibh);
856out: 860out:
857 gfs2_trans_end(GFS2_SB(&ip->i_inode)); 861 gfs2_trans_end(GFS2_SB(&ip->i_inode));
@@ -931,12 +935,12 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
931{ 935{
932 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 936 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
933 struct buffer_head *indbh, *newbh; 937 struct buffer_head *indbh, *newbh;
934 u64 *eablk; 938 __be64 *eablk;
935 int error; 939 int error;
936 int mh_size = sizeof(struct gfs2_meta_header); 940 int mh_size = sizeof(struct gfs2_meta_header);
937 941
938 if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) { 942 if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT) {
939 u64 *end; 943 __be64 *end;
940 944
941 error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT, 945 error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_WAIT,
942 &indbh); 946 &indbh);
@@ -948,7 +952,7 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
948 goto out; 952 goto out;
949 } 953 }
950 954
951 eablk = (u64 *)(indbh->b_data + mh_size); 955 eablk = (__be64 *)(indbh->b_data + mh_size);
952 end = eablk + sdp->sd_inptrs; 956 end = eablk + sdp->sd_inptrs;
953 957
954 for (; eablk < end; eablk++) 958 for (; eablk < end; eablk++)
@@ -971,11 +975,12 @@ static int ea_set_block(struct gfs2_inode *ip, struct gfs2_ea_request *er,
971 gfs2_metatype_set(indbh, GFS2_METATYPE_IN, GFS2_FORMAT_IN); 975 gfs2_metatype_set(indbh, GFS2_METATYPE_IN, GFS2_FORMAT_IN);
972 gfs2_buffer_clear_tail(indbh, mh_size); 976 gfs2_buffer_clear_tail(indbh, mh_size);
973 977
974 eablk = (u64 *)(indbh->b_data + mh_size); 978 eablk = (__be64 *)(indbh->b_data + mh_size);
975 *eablk = cpu_to_be64(ip->i_di.di_eattr); 979 *eablk = cpu_to_be64(ip->i_di.di_eattr);
976 ip->i_di.di_eattr = blk; 980 ip->i_di.di_eattr = blk;
977 ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT; 981 ip->i_di.di_flags |= GFS2_DIF_EA_INDIRECT;
978 ip->i_di.di_blocks++; 982 ip->i_di.di_blocks++;
983 gfs2_set_inode_blocks(&ip->i_inode);
979 984
980 eablk++; 985 eablk++;
981 } 986 }
@@ -1129,9 +1134,9 @@ static int ea_remove_stuffed(struct gfs2_inode *ip, struct gfs2_ea_location *el)
1129 1134
1130 error = gfs2_meta_inode_buffer(ip, &dibh); 1135 error = gfs2_meta_inode_buffer(ip, &dibh);
1131 if (!error) { 1136 if (!error) {
1132 ip->i_di.di_ctime = get_seconds(); 1137 ip->i_inode.i_ctime.tv_sec = get_seconds();
1133 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1138 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1134 gfs2_dinode_out(&ip->i_di, dibh->b_data); 1139 gfs2_dinode_out(ip, dibh->b_data);
1135 brelse(dibh); 1140 brelse(dibh);
1136 } 1141 }
1137 1142
@@ -1202,7 +1207,7 @@ static int ea_acl_chmod_unstuffed(struct gfs2_inode *ip,
1202 struct buffer_head **bh; 1207 struct buffer_head **bh;
1203 unsigned int amount = GFS2_EA_DATA_LEN(ea); 1208 unsigned int amount = GFS2_EA_DATA_LEN(ea);
1204 unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize); 1209 unsigned int nptrs = DIV_ROUND_UP(amount, sdp->sd_jbsize);
1205 u64 *dataptrs = GFS2_EA2DATAPTRS(ea); 1210 __be64 *dataptrs = GFS2_EA2DATAPTRS(ea);
1206 unsigned int x; 1211 unsigned int x;
1207 int error; 1212 int error;
1208 1213
@@ -1284,9 +1289,8 @@ int gfs2_ea_acl_chmod(struct gfs2_inode *ip, struct gfs2_ea_location *el,
1284 if (!error) { 1289 if (!error) {
1285 error = inode_setattr(&ip->i_inode, attr); 1290 error = inode_setattr(&ip->i_inode, attr);
1286 gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error); 1291 gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error);
1287 gfs2_inode_attr_out(ip);
1288 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1292 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1289 gfs2_dinode_out(&ip->i_di, dibh->b_data); 1293 gfs2_dinode_out(ip, dibh->b_data);
1290 brelse(dibh); 1294 brelse(dibh);
1291 } 1295 }
1292 1296
@@ -1300,7 +1304,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1300 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 1304 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1301 struct gfs2_rgrp_list rlist; 1305 struct gfs2_rgrp_list rlist;
1302 struct buffer_head *indbh, *dibh; 1306 struct buffer_head *indbh, *dibh;
1303 u64 *eablk, *end; 1307 __be64 *eablk, *end;
1304 unsigned int rg_blocks = 0; 1308 unsigned int rg_blocks = 0;
1305 u64 bstart = 0; 1309 u64 bstart = 0;
1306 unsigned int blen = 0; 1310 unsigned int blen = 0;
@@ -1319,7 +1323,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1319 goto out; 1323 goto out;
1320 } 1324 }
1321 1325
1322 eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header)); 1326 eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
1323 end = eablk + sdp->sd_inptrs; 1327 end = eablk + sdp->sd_inptrs;
1324 1328
1325 for (; eablk < end; eablk++) { 1329 for (; eablk < end; eablk++) {
@@ -1363,7 +1367,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1363 1367
1364 gfs2_trans_add_bh(ip->i_gl, indbh, 1); 1368 gfs2_trans_add_bh(ip->i_gl, indbh, 1);
1365 1369
1366 eablk = (u64 *)(indbh->b_data + sizeof(struct gfs2_meta_header)); 1370 eablk = (__be64 *)(indbh->b_data + sizeof(struct gfs2_meta_header));
1367 bstart = 0; 1371 bstart = 0;
1368 blen = 0; 1372 blen = 0;
1369 1373
@@ -1387,6 +1391,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1387 if (!ip->i_di.di_blocks) 1391 if (!ip->i_di.di_blocks)
1388 gfs2_consist_inode(ip); 1392 gfs2_consist_inode(ip);
1389 ip->i_di.di_blocks--; 1393 ip->i_di.di_blocks--;
1394 gfs2_set_inode_blocks(&ip->i_inode);
1390 } 1395 }
1391 if (bstart) 1396 if (bstart)
1392 gfs2_free_meta(ip, bstart, blen); 1397 gfs2_free_meta(ip, bstart, blen);
@@ -1396,7 +1401,7 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip)
1396 error = gfs2_meta_inode_buffer(ip, &dibh); 1401 error = gfs2_meta_inode_buffer(ip, &dibh);
1397 if (!error) { 1402 if (!error) {
1398 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1403 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1399 gfs2_dinode_out(&ip->i_di, dibh->b_data); 1404 gfs2_dinode_out(ip, dibh->b_data);
1400 brelse(dibh); 1405 brelse(dibh);
1401 } 1406 }
1402 1407
@@ -1441,11 +1446,12 @@ static int ea_dealloc_block(struct gfs2_inode *ip)
1441 if (!ip->i_di.di_blocks) 1446 if (!ip->i_di.di_blocks)
1442 gfs2_consist_inode(ip); 1447 gfs2_consist_inode(ip);
1443 ip->i_di.di_blocks--; 1448 ip->i_di.di_blocks--;
1449 gfs2_set_inode_blocks(&ip->i_inode);
1444 1450
1445 error = gfs2_meta_inode_buffer(ip, &dibh); 1451 error = gfs2_meta_inode_buffer(ip, &dibh);
1446 if (!error) { 1452 if (!error) {
1447 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1453 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1448 gfs2_dinode_out(&ip->i_di, dibh->b_data); 1454 gfs2_dinode_out(ip, dibh->b_data);
1449 brelse(dibh); 1455 brelse(dibh);
1450 } 1456 }
1451 1457
diff --git a/fs/gfs2/eattr.h b/fs/gfs2/eattr.h
index ffa65947d686..c82dbe01d713 100644
--- a/fs/gfs2/eattr.h
+++ b/fs/gfs2/eattr.h
@@ -19,7 +19,7 @@ struct iattr;
19#define GFS2_EA_SIZE(ea) \ 19#define GFS2_EA_SIZE(ea) \
20ALIGN(sizeof(struct gfs2_ea_header) + (ea)->ea_name_len + \ 20ALIGN(sizeof(struct gfs2_ea_header) + (ea)->ea_name_len + \
21 ((GFS2_EA_IS_STUFFED(ea)) ? GFS2_EA_DATA_LEN(ea) : \ 21 ((GFS2_EA_IS_STUFFED(ea)) ? GFS2_EA_DATA_LEN(ea) : \
22 (sizeof(u64) * (ea)->ea_num_ptrs)), 8) 22 (sizeof(__be64) * (ea)->ea_num_ptrs)), 8)
23 23
24#define GFS2_EA_IS_STUFFED(ea) (!(ea)->ea_num_ptrs) 24#define GFS2_EA_IS_STUFFED(ea) (!(ea)->ea_num_ptrs)
25#define GFS2_EA_IS_LAST(ea) ((ea)->ea_flags & GFS2_EAFLAG_LAST) 25#define GFS2_EA_IS_LAST(ea) ((ea)->ea_flags & GFS2_EAFLAG_LAST)
@@ -29,13 +29,13 @@ ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + (er)->er_data_len, 8)
29 29
30#define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \ 30#define GFS2_EAREQ_SIZE_UNSTUFFED(sdp, er) \
31ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \ 31ALIGN(sizeof(struct gfs2_ea_header) + (er)->er_name_len + \
32 sizeof(u64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8) 32 sizeof(__be64) * DIV_ROUND_UP((er)->er_data_len, (sdp)->sd_jbsize), 8)
33 33
34#define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1)) 34#define GFS2_EA2NAME(ea) ((char *)((struct gfs2_ea_header *)(ea) + 1))
35#define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len) 35#define GFS2_EA2DATA(ea) (GFS2_EA2NAME(ea) + (ea)->ea_name_len)
36 36
37#define GFS2_EA2DATAPTRS(ea) \ 37#define GFS2_EA2DATAPTRS(ea) \
38((u64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8))) 38((__be64 *)(GFS2_EA2NAME(ea) + ALIGN((ea)->ea_name_len, 8)))
39 39
40#define GFS2_EA2NEXT(ea) \ 40#define GFS2_EA2NEXT(ea) \
41((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea))) 41((struct gfs2_ea_header *)((char *)(ea) + GFS2_EA_REC_LEN(ea)))
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 55f5333dae99..438146904b58 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -96,7 +96,7 @@ static inline rwlock_t *gl_lock_addr(unsigned int x)
96 return &gl_hash_locks[x & (GL_HASH_LOCK_SZ-1)]; 96 return &gl_hash_locks[x & (GL_HASH_LOCK_SZ-1)];
97} 97}
98#else /* not SMP, so no spinlocks required */ 98#else /* not SMP, so no spinlocks required */
99static inline rwlock_t *gl_lock_addr(x) 99static inline rwlock_t *gl_lock_addr(unsigned int x)
100{ 100{
101 return NULL; 101 return NULL;
102} 102}
@@ -769,7 +769,7 @@ restart:
769 } else { 769 } else {
770 spin_unlock(&gl->gl_spin); 770 spin_unlock(&gl->gl_spin);
771 771
772 new_gh = gfs2_holder_get(gl, state, LM_FLAG_TRY, GFP_KERNEL); 772 new_gh = gfs2_holder_get(gl, state, LM_FLAG_TRY, GFP_NOFS);
773 if (!new_gh) 773 if (!new_gh)
774 return; 774 return;
775 set_bit(HIF_DEMOTE, &new_gh->gh_iflags); 775 set_bit(HIF_DEMOTE, &new_gh->gh_iflags);
@@ -785,21 +785,6 @@ out:
785 gfs2_holder_put(new_gh); 785 gfs2_holder_put(new_gh);
786} 786}
787 787
788void gfs2_glock_inode_squish(struct inode *inode)
789{
790 struct gfs2_holder gh;
791 struct gfs2_glock *gl = GFS2_I(inode)->i_gl;
792 gfs2_holder_init(gl, LM_ST_UNLOCKED, 0, &gh);
793 set_bit(HIF_DEMOTE, &gh.gh_iflags);
794 spin_lock(&gl->gl_spin);
795 gfs2_assert(inode->i_sb->s_fs_info, list_empty(&gl->gl_holders));
796 list_add_tail(&gh.gh_list, &gl->gl_waiters2);
797 run_queue(gl);
798 spin_unlock(&gl->gl_spin);
799 wait_for_completion(&gh.gh_wait);
800 gfs2_holder_uninit(&gh);
801}
802
803/** 788/**
804 * state_change - record that the glock is now in a different state 789 * state_change - record that the glock is now in a different state
805 * @gl: the glock 790 * @gl: the glock
@@ -847,12 +832,12 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret)
847 832
848 if (prev_state != LM_ST_UNLOCKED && !(ret & LM_OUT_CACHEABLE)) { 833 if (prev_state != LM_ST_UNLOCKED && !(ret & LM_OUT_CACHEABLE)) {
849 if (glops->go_inval) 834 if (glops->go_inval)
850 glops->go_inval(gl, DIO_METADATA | DIO_DATA); 835 glops->go_inval(gl, DIO_METADATA);
851 } else if (gl->gl_state == LM_ST_DEFERRED) { 836 } else if (gl->gl_state == LM_ST_DEFERRED) {
852 /* We might not want to do this here. 837 /* We might not want to do this here.
853 Look at moving to the inode glops. */ 838 Look at moving to the inode glops. */
854 if (glops->go_inval) 839 if (glops->go_inval)
855 glops->go_inval(gl, DIO_DATA); 840 glops->go_inval(gl, 0);
856 } 841 }
857 842
858 /* Deal with each possible exit condition */ 843 /* Deal with each possible exit condition */
@@ -954,7 +939,7 @@ void gfs2_glock_xmote_th(struct gfs2_glock *gl, unsigned int state, int flags)
954 gfs2_assert_warn(sdp, state != gl->gl_state); 939 gfs2_assert_warn(sdp, state != gl->gl_state);
955 940
956 if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync) 941 if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync)
957 glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE); 942 glops->go_sync(gl);
958 943
959 gfs2_glock_hold(gl); 944 gfs2_glock_hold(gl);
960 gl->gl_req_bh = xmote_bh; 945 gl->gl_req_bh = xmote_bh;
@@ -995,7 +980,7 @@ static void drop_bh(struct gfs2_glock *gl, unsigned int ret)
995 state_change(gl, LM_ST_UNLOCKED); 980 state_change(gl, LM_ST_UNLOCKED);
996 981
997 if (glops->go_inval) 982 if (glops->go_inval)
998 glops->go_inval(gl, DIO_METADATA | DIO_DATA); 983 glops->go_inval(gl, DIO_METADATA);
999 984
1000 if (gh) { 985 if (gh) {
1001 spin_lock(&gl->gl_spin); 986 spin_lock(&gl->gl_spin);
@@ -1041,7 +1026,7 @@ void gfs2_glock_drop_th(struct gfs2_glock *gl)
1041 gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED); 1026 gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED);
1042 1027
1043 if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync) 1028 if (gl->gl_state == LM_ST_EXCLUSIVE && glops->go_sync)
1044 glops->go_sync(gl, DIO_METADATA | DIO_DATA | DIO_RELEASE); 1029 glops->go_sync(gl);
1045 1030
1046 gfs2_glock_hold(gl); 1031 gfs2_glock_hold(gl);
1047 gl->gl_req_bh = drop_bh; 1032 gl->gl_req_bh = drop_bh;
@@ -1244,9 +1229,6 @@ restart:
1244 1229
1245 clear_bit(GLF_PREFETCH, &gl->gl_flags); 1230 clear_bit(GLF_PREFETCH, &gl->gl_flags);
1246 1231
1247 if (error == GLR_TRYFAILED && (gh->gh_flags & GL_DUMP))
1248 dump_glock(gl);
1249
1250 return error; 1232 return error;
1251} 1233}
1252 1234
@@ -1923,7 +1905,7 @@ out:
1923 1905
1924static void scan_glock(struct gfs2_glock *gl) 1906static void scan_glock(struct gfs2_glock *gl)
1925{ 1907{
1926 if (gl->gl_ops == &gfs2_inode_glops) 1908 if (gl->gl_ops == &gfs2_inode_glops && gl->gl_object)
1927 return; 1909 return;
1928 1910
1929 if (gfs2_glmutex_trylock(gl)) { 1911 if (gfs2_glmutex_trylock(gl)) {
@@ -2078,7 +2060,7 @@ static int dump_inode(struct gfs2_inode *ip)
2078 printk(KERN_INFO " num = %llu %llu\n", 2060 printk(KERN_INFO " num = %llu %llu\n",
2079 (unsigned long long)ip->i_num.no_formal_ino, 2061 (unsigned long long)ip->i_num.no_formal_ino,
2080 (unsigned long long)ip->i_num.no_addr); 2062 (unsigned long long)ip->i_num.no_addr);
2081 printk(KERN_INFO " type = %u\n", IF2DT(ip->i_di.di_mode)); 2063 printk(KERN_INFO " type = %u\n", IF2DT(ip->i_inode.i_mode));
2082 printk(KERN_INFO " i_flags ="); 2064 printk(KERN_INFO " i_flags =");
2083 for (x = 0; x < 32; x++) 2065 for (x = 0; x < 32; x++)
2084 if (test_bit(x, &ip->i_flags)) 2066 if (test_bit(x, &ip->i_flags))
diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h
index 2b2a889ee2cc..fb39108fc05c 100644
--- a/fs/gfs2/glock.h
+++ b/fs/gfs2/glock.h
@@ -27,8 +27,6 @@
27#define GL_ATIME 0x00000200 27#define GL_ATIME 0x00000200
28#define GL_NOCACHE 0x00000400 28#define GL_NOCACHE 0x00000400
29#define GL_NOCANCEL 0x00001000 29#define GL_NOCANCEL 0x00001000
30#define GL_AOP 0x00004000
31#define GL_DUMP 0x00008000
32 30
33#define GLR_TRYFAILED 13 31#define GLR_TRYFAILED 13
34#define GLR_CANCELED 14 32#define GLR_CANCELED 14
@@ -108,7 +106,6 @@ void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs);
108void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, u64 number, 106void gfs2_glock_prefetch_num(struct gfs2_sbd *sdp, u64 number,
109 const struct gfs2_glock_operations *glops, 107 const struct gfs2_glock_operations *glops,
110 unsigned int state, int flags); 108 unsigned int state, int flags);
111void gfs2_glock_inode_squish(struct inode *inode);
112 109
113/** 110/**
114 * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock 111 * gfs2_glock_nq_init - intialize a holder and enqueue it on a glock
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 41a6b6818a50..b068d10bcb6e 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -92,7 +92,7 @@ static void gfs2_pte_inval(struct gfs2_glock *gl)
92 92
93 ip = gl->gl_object; 93 ip = gl->gl_object;
94 inode = &ip->i_inode; 94 inode = &ip->i_inode;
95 if (!ip || !S_ISREG(ip->i_di.di_mode)) 95 if (!ip || !S_ISREG(inode->i_mode))
96 return; 96 return;
97 97
98 if (!test_bit(GIF_PAGED, &ip->i_flags)) 98 if (!test_bit(GIF_PAGED, &ip->i_flags))
@@ -107,89 +107,20 @@ static void gfs2_pte_inval(struct gfs2_glock *gl)
107} 107}
108 108
109/** 109/**
110 * gfs2_page_inval - Invalidate all pages associated with a glock
111 * @gl: the glock
112 *
113 */
114
115static void gfs2_page_inval(struct gfs2_glock *gl)
116{
117 struct gfs2_inode *ip;
118 struct inode *inode;
119
120 ip = gl->gl_object;
121 inode = &ip->i_inode;
122 if (!ip || !S_ISREG(ip->i_di.di_mode))
123 return;
124
125 truncate_inode_pages(inode->i_mapping, 0);
126 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), !inode->i_mapping->nrpages);
127 clear_bit(GIF_PAGED, &ip->i_flags);
128}
129
130/**
131 * gfs2_page_wait - Wait for writeback of data
132 * @gl: the glock
133 *
134 * Syncs data (not metadata) for a regular file.
135 * No-op for all other types.
136 */
137
138static void gfs2_page_wait(struct gfs2_glock *gl)
139{
140 struct gfs2_inode *ip = gl->gl_object;
141 struct inode *inode = &ip->i_inode;
142 struct address_space *mapping = inode->i_mapping;
143 int error;
144
145 if (!S_ISREG(ip->i_di.di_mode))
146 return;
147
148 error = filemap_fdatawait(mapping);
149
150 /* Put back any errors cleared by filemap_fdatawait()
151 so they can be caught by someone who can pass them
152 up to user space. */
153
154 if (error == -ENOSPC)
155 set_bit(AS_ENOSPC, &mapping->flags);
156 else if (error)
157 set_bit(AS_EIO, &mapping->flags);
158
159}
160
161static void gfs2_page_writeback(struct gfs2_glock *gl)
162{
163 struct gfs2_inode *ip = gl->gl_object;
164 struct inode *inode = &ip->i_inode;
165 struct address_space *mapping = inode->i_mapping;
166
167 if (!S_ISREG(ip->i_di.di_mode))
168 return;
169
170 filemap_fdatawrite(mapping);
171}
172
173/**
174 * meta_go_sync - sync out the metadata for this glock 110 * meta_go_sync - sync out the metadata for this glock
175 * @gl: the glock 111 * @gl: the glock
176 * @flags: DIO_*
177 * 112 *
178 * Called when demoting or unlocking an EX glock. We must flush 113 * Called when demoting or unlocking an EX glock. We must flush
179 * to disk all dirty buffers/pages relating to this glock, and must not 114 * to disk all dirty buffers/pages relating to this glock, and must not
180 * not return to caller to demote/unlock the glock until I/O is complete. 115 * not return to caller to demote/unlock the glock until I/O is complete.
181 */ 116 */
182 117
183static void meta_go_sync(struct gfs2_glock *gl, int flags) 118static void meta_go_sync(struct gfs2_glock *gl)
184{ 119{
185 if (!(flags & DIO_METADATA))
186 return;
187
188 if (test_and_clear_bit(GLF_DIRTY, &gl->gl_flags)) { 120 if (test_and_clear_bit(GLF_DIRTY, &gl->gl_flags)) {
189 gfs2_log_flush(gl->gl_sbd, gl); 121 gfs2_log_flush(gl->gl_sbd, gl);
190 gfs2_meta_sync(gl); 122 gfs2_meta_sync(gl);
191 if (flags & DIO_RELEASE) 123 gfs2_ail_empty_gl(gl);
192 gfs2_ail_empty_gl(gl);
193 } 124 }
194 125
195} 126}
@@ -264,31 +195,31 @@ static void inode_go_drop_th(struct gfs2_glock *gl)
264/** 195/**
265 * inode_go_sync - Sync the dirty data and/or metadata for an inode glock 196 * inode_go_sync - Sync the dirty data and/or metadata for an inode glock
266 * @gl: the glock protecting the inode 197 * @gl: the glock protecting the inode
267 * @flags:
268 * 198 *
269 */ 199 */
270 200
271static void inode_go_sync(struct gfs2_glock *gl, int flags) 201static void inode_go_sync(struct gfs2_glock *gl)
272{ 202{
273 int meta = (flags & DIO_METADATA); 203 struct gfs2_inode *ip = gl->gl_object;
274 int data = (flags & DIO_DATA); 204
205 if (ip && !S_ISREG(ip->i_inode.i_mode))
206 ip = NULL;
275 207
276 if (test_bit(GLF_DIRTY, &gl->gl_flags)) { 208 if (test_bit(GLF_DIRTY, &gl->gl_flags)) {
277 if (meta && data) { 209 gfs2_log_flush(gl->gl_sbd, gl);
278 gfs2_page_writeback(gl); 210 if (ip)
279 gfs2_log_flush(gl->gl_sbd, gl); 211 filemap_fdatawrite(ip->i_inode.i_mapping);
280 gfs2_meta_sync(gl); 212 gfs2_meta_sync(gl);
281 gfs2_page_wait(gl); 213 if (ip) {
282 clear_bit(GLF_DIRTY, &gl->gl_flags); 214 struct address_space *mapping = ip->i_inode.i_mapping;
283 } else if (meta) { 215 int error = filemap_fdatawait(mapping);
284 gfs2_log_flush(gl->gl_sbd, gl); 216 if (error == -ENOSPC)
285 gfs2_meta_sync(gl); 217 set_bit(AS_ENOSPC, &mapping->flags);
286 } else if (data) { 218 else if (error)
287 gfs2_page_writeback(gl); 219 set_bit(AS_EIO, &mapping->flags);
288 gfs2_page_wait(gl);
289 } 220 }
290 if (flags & DIO_RELEASE) 221 clear_bit(GLF_DIRTY, &gl->gl_flags);
291 gfs2_ail_empty_gl(gl); 222 gfs2_ail_empty_gl(gl);
292 } 223 }
293} 224}
294 225
@@ -301,15 +232,20 @@ static void inode_go_sync(struct gfs2_glock *gl, int flags)
301 232
302static void inode_go_inval(struct gfs2_glock *gl, int flags) 233static void inode_go_inval(struct gfs2_glock *gl, int flags)
303{ 234{
235 struct gfs2_inode *ip = gl->gl_object;
304 int meta = (flags & DIO_METADATA); 236 int meta = (flags & DIO_METADATA);
305 int data = (flags & DIO_DATA);
306 237
307 if (meta) { 238 if (meta) {
308 gfs2_meta_inval(gl); 239 gfs2_meta_inval(gl);
309 gl->gl_vn++; 240 if (ip)
241 set_bit(GIF_INVALID, &ip->i_flags);
242 }
243
244 if (ip && S_ISREG(ip->i_inode.i_mode)) {
245 truncate_inode_pages(ip->i_inode.i_mapping, 0);
246 gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), !ip->i_inode.i_mapping->nrpages);
247 clear_bit(GIF_PAGED, &ip->i_flags);
310 } 248 }
311 if (data)
312 gfs2_page_inval(gl);
313} 249}
314 250
315/** 251/**
@@ -351,11 +287,10 @@ static int inode_go_lock(struct gfs2_holder *gh)
351 if (!ip) 287 if (!ip)
352 return 0; 288 return 0;
353 289
354 if (ip->i_vn != gl->gl_vn) { 290 if (test_bit(GIF_INVALID, &ip->i_flags)) {
355 error = gfs2_inode_refresh(ip); 291 error = gfs2_inode_refresh(ip);
356 if (error) 292 if (error)
357 return error; 293 return error;
358 gfs2_inode_attr_in(ip);
359 } 294 }
360 295
361 if ((ip->i_di.di_flags & GFS2_DIF_TRUNC_IN_PROG) && 296 if ((ip->i_di.di_flags & GFS2_DIF_TRUNC_IN_PROG) &&
@@ -379,11 +314,8 @@ static void inode_go_unlock(struct gfs2_holder *gh)
379 struct gfs2_glock *gl = gh->gh_gl; 314 struct gfs2_glock *gl = gh->gh_gl;
380 struct gfs2_inode *ip = gl->gl_object; 315 struct gfs2_inode *ip = gl->gl_object;
381 316
382 if (ip == NULL) 317 if (ip)
383 return; 318 gfs2_meta_cache_flush(ip);
384 if (test_bit(GLF_DIRTY, &gl->gl_flags))
385 gfs2_inode_attr_in(ip);
386 gfs2_meta_cache_flush(ip);
387} 319}
388 320
389/** 321/**
@@ -491,13 +423,13 @@ static void trans_go_xmote_bh(struct gfs2_glock *gl)
491 struct gfs2_sbd *sdp = gl->gl_sbd; 423 struct gfs2_sbd *sdp = gl->gl_sbd;
492 struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode); 424 struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
493 struct gfs2_glock *j_gl = ip->i_gl; 425 struct gfs2_glock *j_gl = ip->i_gl;
494 struct gfs2_log_header head; 426 struct gfs2_log_header_host head;
495 int error; 427 int error;
496 428
497 if (gl->gl_state != LM_ST_UNLOCKED && 429 if (gl->gl_state != LM_ST_UNLOCKED &&
498 test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) { 430 test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
499 gfs2_meta_cache_flush(GFS2_I(sdp->sd_jdesc->jd_inode)); 431 gfs2_meta_cache_flush(GFS2_I(sdp->sd_jdesc->jd_inode));
500 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA); 432 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
501 433
502 error = gfs2_find_jhead(sdp->sd_jdesc, &head); 434 error = gfs2_find_jhead(sdp->sd_jdesc, &head);
503 if (error) 435 if (error)
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 118dc693d111..734421edae85 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -14,8 +14,6 @@
14 14
15#define DIO_WAIT 0x00000010 15#define DIO_WAIT 0x00000010
16#define DIO_METADATA 0x00000020 16#define DIO_METADATA 0x00000020
17#define DIO_DATA 0x00000040
18#define DIO_RELEASE 0x00000080
19#define DIO_ALL 0x00000100 17#define DIO_ALL 0x00000100
20 18
21struct gfs2_log_operations; 19struct gfs2_log_operations;
@@ -41,7 +39,7 @@ struct gfs2_log_operations {
41 void (*lo_before_commit) (struct gfs2_sbd *sdp); 39 void (*lo_before_commit) (struct gfs2_sbd *sdp);
42 void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_ail *ai); 40 void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_ail *ai);
43 void (*lo_before_scan) (struct gfs2_jdesc *jd, 41 void (*lo_before_scan) (struct gfs2_jdesc *jd,
44 struct gfs2_log_header *head, int pass); 42 struct gfs2_log_header_host *head, int pass);
45 int (*lo_scan_elements) (struct gfs2_jdesc *jd, unsigned int start, 43 int (*lo_scan_elements) (struct gfs2_jdesc *jd, unsigned int start,
46 struct gfs2_log_descriptor *ld, __be64 *ptr, 44 struct gfs2_log_descriptor *ld, __be64 *ptr,
47 int pass); 45 int pass);
@@ -67,8 +65,8 @@ struct gfs2_rgrpd {
67 struct list_head rd_list_mru; 65 struct list_head rd_list_mru;
68 struct list_head rd_recent; /* Recently used rgrps */ 66 struct list_head rd_recent; /* Recently used rgrps */
69 struct gfs2_glock *rd_gl; /* Glock for this rgrp */ 67 struct gfs2_glock *rd_gl; /* Glock for this rgrp */
70 struct gfs2_rindex rd_ri; 68 struct gfs2_rindex_host rd_ri;
71 struct gfs2_rgrp rd_rg; 69 struct gfs2_rgrp_host rd_rg;
72 u64 rd_rg_vn; 70 u64 rd_rg_vn;
73 struct gfs2_bitmap *rd_bits; 71 struct gfs2_bitmap *rd_bits;
74 unsigned int rd_bh_count; 72 unsigned int rd_bh_count;
@@ -103,18 +101,17 @@ struct gfs2_bufdata {
103}; 101};
104 102
105struct gfs2_glock_operations { 103struct gfs2_glock_operations {
106 void (*go_xmote_th) (struct gfs2_glock * gl, unsigned int state, 104 void (*go_xmote_th) (struct gfs2_glock *gl, unsigned int state, int flags);
107 int flags); 105 void (*go_xmote_bh) (struct gfs2_glock *gl);
108 void (*go_xmote_bh) (struct gfs2_glock * gl); 106 void (*go_drop_th) (struct gfs2_glock *gl);
109 void (*go_drop_th) (struct gfs2_glock * gl); 107 void (*go_drop_bh) (struct gfs2_glock *gl);
110 void (*go_drop_bh) (struct gfs2_glock * gl); 108 void (*go_sync) (struct gfs2_glock *gl);
111 void (*go_sync) (struct gfs2_glock * gl, int flags); 109 void (*go_inval) (struct gfs2_glock *gl, int flags);
112 void (*go_inval) (struct gfs2_glock * gl, int flags); 110 int (*go_demote_ok) (struct gfs2_glock *gl);
113 int (*go_demote_ok) (struct gfs2_glock * gl); 111 int (*go_lock) (struct gfs2_holder *gh);
114 int (*go_lock) (struct gfs2_holder * gh); 112 void (*go_unlock) (struct gfs2_holder *gh);
115 void (*go_unlock) (struct gfs2_holder * gh); 113 void (*go_callback) (struct gfs2_glock *gl, unsigned int state);
116 void (*go_callback) (struct gfs2_glock * gl, unsigned int state); 114 void (*go_greedy) (struct gfs2_glock *gl);
117 void (*go_greedy) (struct gfs2_glock * gl);
118 const int go_type; 115 const int go_type;
119}; 116};
120 117
@@ -217,6 +214,7 @@ struct gfs2_alloc {
217}; 214};
218 215
219enum { 216enum {
217 GIF_INVALID = 0,
220 GIF_QD_LOCKED = 1, 218 GIF_QD_LOCKED = 1,
221 GIF_PAGED = 2, 219 GIF_PAGED = 2,
222 GIF_SW_PAGED = 3, 220 GIF_SW_PAGED = 3,
@@ -224,12 +222,11 @@ enum {
224 222
225struct gfs2_inode { 223struct gfs2_inode {
226 struct inode i_inode; 224 struct inode i_inode;
227 struct gfs2_inum i_num; 225 struct gfs2_inum_host i_num;
228 226
229 unsigned long i_flags; /* GIF_... */ 227 unsigned long i_flags; /* GIF_... */
230 228
231 u64 i_vn; 229 struct gfs2_dinode_host i_di; /* To be replaced by ref to block */
232 struct gfs2_dinode i_di; /* To be replaced by ref to block */
233 230
234 struct gfs2_glock *i_gl; /* Move into i_gh? */ 231 struct gfs2_glock *i_gl; /* Move into i_gh? */
235 struct gfs2_holder i_iopen_gh; 232 struct gfs2_holder i_iopen_gh;
@@ -450,7 +447,7 @@ struct gfs2_sbd {
450 struct super_block *sd_vfs_meta; 447 struct super_block *sd_vfs_meta;
451 struct kobject sd_kobj; 448 struct kobject sd_kobj;
452 unsigned long sd_flags; /* SDF_... */ 449 unsigned long sd_flags; /* SDF_... */
453 struct gfs2_sb sd_sb; 450 struct gfs2_sb_host sd_sb;
454 451
455 /* Constants computed on mount */ 452 /* Constants computed on mount */
456 453
@@ -503,8 +500,8 @@ struct gfs2_sbd {
503 500
504 spinlock_t sd_statfs_spin; 501 spinlock_t sd_statfs_spin;
505 struct mutex sd_statfs_mutex; 502 struct mutex sd_statfs_mutex;
506 struct gfs2_statfs_change sd_statfs_master; 503 struct gfs2_statfs_change_host sd_statfs_master;
507 struct gfs2_statfs_change sd_statfs_local; 504 struct gfs2_statfs_change_host sd_statfs_local;
508 unsigned long sd_statfs_sync_time; 505 unsigned long sd_statfs_sync_time;
509 506
510 /* Resource group stuff */ 507 /* Resource group stuff */
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index d470e5286ecd..d122074c45e1 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -38,83 +38,12 @@
38#include "trans.h" 38#include "trans.h"
39#include "util.h" 39#include "util.h"
40 40
41/**
42 * gfs2_inode_attr_in - Copy attributes from the dinode into the VFS inode
43 * @ip: The GFS2 inode (with embedded disk inode data)
44 * @inode: The Linux VFS inode
45 *
46 */
47
48void gfs2_inode_attr_in(struct gfs2_inode *ip)
49{
50 struct inode *inode = &ip->i_inode;
51 struct gfs2_dinode *di = &ip->i_di;
52
53 inode->i_ino = ip->i_num.no_addr;
54
55 switch (di->di_mode & S_IFMT) {
56 case S_IFBLK:
57 case S_IFCHR:
58 inode->i_rdev = MKDEV(di->di_major, di->di_minor);
59 break;
60 default:
61 inode->i_rdev = 0;
62 break;
63 };
64
65 inode->i_mode = di->di_mode;
66 inode->i_nlink = di->di_nlink;
67 inode->i_uid = di->di_uid;
68 inode->i_gid = di->di_gid;
69 i_size_write(inode, di->di_size);
70 inode->i_atime.tv_sec = di->di_atime;
71 inode->i_mtime.tv_sec = di->di_mtime;
72 inode->i_ctime.tv_sec = di->di_ctime;
73 inode->i_atime.tv_nsec = 0;
74 inode->i_mtime.tv_nsec = 0;
75 inode->i_ctime.tv_nsec = 0;
76 inode->i_blocks = di->di_blocks <<
77 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
78
79 if (di->di_flags & GFS2_DIF_IMMUTABLE)
80 inode->i_flags |= S_IMMUTABLE;
81 else
82 inode->i_flags &= ~S_IMMUTABLE;
83
84 if (di->di_flags & GFS2_DIF_APPENDONLY)
85 inode->i_flags |= S_APPEND;
86 else
87 inode->i_flags &= ~S_APPEND;
88}
89
90/**
91 * gfs2_inode_attr_out - Copy attributes from VFS inode into the dinode
92 * @ip: The GFS2 inode
93 *
94 * Only copy out the attributes that we want the VFS layer
95 * to be able to modify.
96 */
97
98void gfs2_inode_attr_out(struct gfs2_inode *ip)
99{
100 struct inode *inode = &ip->i_inode;
101 struct gfs2_dinode *di = &ip->i_di;
102 gfs2_assert_withdraw(GFS2_SB(inode),
103 (di->di_mode & S_IFMT) == (inode->i_mode & S_IFMT));
104 di->di_mode = inode->i_mode;
105 di->di_uid = inode->i_uid;
106 di->di_gid = inode->i_gid;
107 di->di_atime = inode->i_atime.tv_sec;
108 di->di_mtime = inode->i_mtime.tv_sec;
109 di->di_ctime = inode->i_ctime.tv_sec;
110}
111
112static int iget_test(struct inode *inode, void *opaque) 41static int iget_test(struct inode *inode, void *opaque)
113{ 42{
114 struct gfs2_inode *ip = GFS2_I(inode); 43 struct gfs2_inode *ip = GFS2_I(inode);
115 struct gfs2_inum *inum = opaque; 44 struct gfs2_inum_host *inum = opaque;
116 45
117 if (ip && ip->i_num.no_addr == inum->no_addr) 46 if (ip->i_num.no_addr == inum->no_addr)
118 return 1; 47 return 1;
119 48
120 return 0; 49 return 0;
@@ -123,19 +52,20 @@ static int iget_test(struct inode *inode, void *opaque)
123static int iget_set(struct inode *inode, void *opaque) 52static int iget_set(struct inode *inode, void *opaque)
124{ 53{
125 struct gfs2_inode *ip = GFS2_I(inode); 54 struct gfs2_inode *ip = GFS2_I(inode);
126 struct gfs2_inum *inum = opaque; 55 struct gfs2_inum_host *inum = opaque;
127 56
128 ip->i_num = *inum; 57 ip->i_num = *inum;
58 inode->i_ino = inum->no_addr;
129 return 0; 59 return 0;
130} 60}
131 61
132struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum *inum) 62struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum_host *inum)
133{ 63{
134 return ilookup5(sb, (unsigned long)inum->no_formal_ino, 64 return ilookup5(sb, (unsigned long)inum->no_formal_ino,
135 iget_test, inum); 65 iget_test, inum);
136} 66}
137 67
138static struct inode *gfs2_iget(struct super_block *sb, struct gfs2_inum *inum) 68static struct inode *gfs2_iget(struct super_block *sb, struct gfs2_inum_host *inum)
139{ 69{
140 return iget5_locked(sb, (unsigned long)inum->no_formal_ino, 70 return iget5_locked(sb, (unsigned long)inum->no_formal_ino,
141 iget_test, iget_set, inum); 71 iget_test, iget_set, inum);
@@ -150,7 +80,7 @@ static struct inode *gfs2_iget(struct super_block *sb, struct gfs2_inum *inum)
150 * Returns: A VFS inode, or an error 80 * Returns: A VFS inode, or an error
151 */ 81 */
152 82
153struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum *inum, unsigned int type) 83struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum_host *inum, unsigned int type)
154{ 84{
155 struct inode *inode = gfs2_iget(sb, inum); 85 struct inode *inode = gfs2_iget(sb, inum);
156 struct gfs2_inode *ip = GFS2_I(inode); 86 struct gfs2_inode *ip = GFS2_I(inode);
@@ -188,7 +118,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum *inum,
188 if (unlikely(error)) 118 if (unlikely(error))
189 goto fail_put; 119 goto fail_put;
190 120
191 ip->i_vn = ip->i_gl->gl_vn - 1; 121 set_bit(GIF_INVALID, &ip->i_flags);
192 error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh); 122 error = gfs2_glock_nq_init(io_gl, LM_ST_SHARED, GL_EXACT, &ip->i_iopen_gh);
193 if (unlikely(error)) 123 if (unlikely(error))
194 goto fail_iopen; 124 goto fail_iopen;
@@ -208,6 +138,63 @@ fail:
208 return ERR_PTR(error); 138 return ERR_PTR(error);
209} 139}
210 140
141static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
142{
143 struct gfs2_dinode_host *di = &ip->i_di;
144 const struct gfs2_dinode *str = buf;
145
146 if (ip->i_num.no_addr != be64_to_cpu(str->di_num.no_addr)) {
147 if (gfs2_consist_inode(ip))
148 gfs2_dinode_print(ip);
149 return -EIO;
150 }
151 if (ip->i_num.no_formal_ino != be64_to_cpu(str->di_num.no_formal_ino))
152 return -ESTALE;
153
154 ip->i_inode.i_mode = be32_to_cpu(str->di_mode);
155 ip->i_inode.i_rdev = 0;
156 switch (ip->i_inode.i_mode & S_IFMT) {
157 case S_IFBLK:
158 case S_IFCHR:
159 ip->i_inode.i_rdev = MKDEV(be32_to_cpu(str->di_major),
160 be32_to_cpu(str->di_minor));
161 break;
162 };
163
164 ip->i_inode.i_uid = be32_to_cpu(str->di_uid);
165 ip->i_inode.i_gid = be32_to_cpu(str->di_gid);
166 /*
167 * We will need to review setting the nlink count here in the
168 * light of the forthcoming ro bind mount work. This is a reminder
169 * to do that.
170 */
171 ip->i_inode.i_nlink = be32_to_cpu(str->di_nlink);
172 di->di_size = be64_to_cpu(str->di_size);
173 i_size_write(&ip->i_inode, di->di_size);
174 di->di_blocks = be64_to_cpu(str->di_blocks);
175 gfs2_set_inode_blocks(&ip->i_inode);
176 ip->i_inode.i_atime.tv_sec = be64_to_cpu(str->di_atime);
177 ip->i_inode.i_atime.tv_nsec = 0;
178 ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
179 ip->i_inode.i_mtime.tv_nsec = 0;
180 ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime);
181 ip->i_inode.i_ctime.tv_nsec = 0;
182
183 di->di_goal_meta = be64_to_cpu(str->di_goal_meta);
184 di->di_goal_data = be64_to_cpu(str->di_goal_data);
185 di->di_generation = be64_to_cpu(str->di_generation);
186
187 di->di_flags = be32_to_cpu(str->di_flags);
188 gfs2_set_inode_flags(&ip->i_inode);
189 di->di_height = be16_to_cpu(str->di_height);
190
191 di->di_depth = be16_to_cpu(str->di_depth);
192 di->di_entries = be32_to_cpu(str->di_entries);
193
194 di->di_eattr = be64_to_cpu(str->di_eattr);
195 return 0;
196}
197
211/** 198/**
212 * gfs2_inode_refresh - Refresh the incore copy of the dinode 199 * gfs2_inode_refresh - Refresh the incore copy of the dinode
213 * @ip: The GFS2 inode 200 * @ip: The GFS2 inode
@@ -229,21 +216,11 @@ int gfs2_inode_refresh(struct gfs2_inode *ip)
229 return -EIO; 216 return -EIO;
230 } 217 }
231 218
232 gfs2_dinode_in(&ip->i_di, dibh->b_data); 219 error = gfs2_dinode_in(ip, dibh->b_data);
233
234 brelse(dibh); 220 brelse(dibh);
221 clear_bit(GIF_INVALID, &ip->i_flags);
235 222
236 if (ip->i_num.no_addr != ip->i_di.di_num.no_addr) { 223 return error;
237 if (gfs2_consist_inode(ip))
238 gfs2_dinode_print(&ip->i_di);
239 return -EIO;
240 }
241 if (ip->i_num.no_formal_ino != ip->i_di.di_num.no_formal_ino)
242 return -ESTALE;
243
244 ip->i_vn = ip->i_gl->gl_vn;
245
246 return 0;
247} 224}
248 225
249int gfs2_dinode_dealloc(struct gfs2_inode *ip) 226int gfs2_dinode_dealloc(struct gfs2_inode *ip)
@@ -255,7 +232,7 @@ int gfs2_dinode_dealloc(struct gfs2_inode *ip)
255 232
256 if (ip->i_di.di_blocks != 1) { 233 if (ip->i_di.di_blocks != 1) {
257 if (gfs2_consist_inode(ip)) 234 if (gfs2_consist_inode(ip))
258 gfs2_dinode_print(&ip->i_di); 235 gfs2_dinode_print(ip);
259 return -EIO; 236 return -EIO;
260 } 237 }
261 238
@@ -318,14 +295,14 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
318 u32 nlink; 295 u32 nlink;
319 int error; 296 int error;
320 297
321 BUG_ON(ip->i_di.di_nlink != ip->i_inode.i_nlink); 298 BUG_ON(diff != 1 && diff != -1);
322 nlink = ip->i_di.di_nlink + diff; 299 nlink = ip->i_inode.i_nlink + diff;
323 300
324 /* If we are reducing the nlink count, but the new value ends up being 301 /* If we are reducing the nlink count, but the new value ends up being
325 bigger than the old one, we must have underflowed. */ 302 bigger than the old one, we must have underflowed. */
326 if (diff < 0 && nlink > ip->i_di.di_nlink) { 303 if (diff < 0 && nlink > ip->i_inode.i_nlink) {
327 if (gfs2_consist_inode(ip)) 304 if (gfs2_consist_inode(ip))
328 gfs2_dinode_print(&ip->i_di); 305 gfs2_dinode_print(ip);
329 return -EIO; 306 return -EIO;
330 } 307 }
331 308
@@ -333,16 +310,19 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
333 if (error) 310 if (error)
334 return error; 311 return error;
335 312
336 ip->i_di.di_nlink = nlink; 313 if (diff > 0)
337 ip->i_di.di_ctime = get_seconds(); 314 inc_nlink(&ip->i_inode);
338 ip->i_inode.i_nlink = nlink; 315 else
316 drop_nlink(&ip->i_inode);
317
318 ip->i_inode.i_ctime.tv_sec = get_seconds();
339 319
340 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 320 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
341 gfs2_dinode_out(&ip->i_di, dibh->b_data); 321 gfs2_dinode_out(ip, dibh->b_data);
342 brelse(dibh); 322 brelse(dibh);
343 mark_inode_dirty(&ip->i_inode); 323 mark_inode_dirty(&ip->i_inode);
344 324
345 if (ip->i_di.di_nlink == 0) { 325 if (ip->i_inode.i_nlink == 0) {
346 struct gfs2_rgrpd *rgd; 326 struct gfs2_rgrpd *rgd;
347 struct gfs2_holder ri_gh, rg_gh; 327 struct gfs2_holder ri_gh, rg_gh;
348 328
@@ -357,7 +337,6 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
357 if (error) 337 if (error)
358 goto out_norgrp; 338 goto out_norgrp;
359 339
360 clear_nlink(&ip->i_inode);
361 gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */ 340 gfs2_unlink_di(&ip->i_inode); /* mark inode unlinked */
362 gfs2_glock_dq_uninit(&rg_gh); 341 gfs2_glock_dq_uninit(&rg_gh);
363out_norgrp: 342out_norgrp:
@@ -394,7 +373,7 @@ struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
394 struct super_block *sb = dir->i_sb; 373 struct super_block *sb = dir->i_sb;
395 struct gfs2_inode *dip = GFS2_I(dir); 374 struct gfs2_inode *dip = GFS2_I(dir);
396 struct gfs2_holder d_gh; 375 struct gfs2_holder d_gh;
397 struct gfs2_inum inum; 376 struct gfs2_inum_host inum;
398 unsigned int type; 377 unsigned int type;
399 int error = 0; 378 int error = 0;
400 struct inode *inode = NULL; 379 struct inode *inode = NULL;
@@ -436,7 +415,7 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, u64 *formal_ino)
436{ 415{
437 struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); 416 struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode);
438 struct buffer_head *bh; 417 struct buffer_head *bh;
439 struct gfs2_inum_range ir; 418 struct gfs2_inum_range_host ir;
440 int error; 419 int error;
441 420
442 error = gfs2_trans_begin(sdp, RES_DINODE, 0); 421 error = gfs2_trans_begin(sdp, RES_DINODE, 0);
@@ -479,7 +458,7 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino)
479 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_inum_inode); 458 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_inum_inode);
480 struct gfs2_holder gh; 459 struct gfs2_holder gh;
481 struct buffer_head *bh; 460 struct buffer_head *bh;
482 struct gfs2_inum_range ir; 461 struct gfs2_inum_range_host ir;
483 int error; 462 int error;
484 463
485 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); 464 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
@@ -500,21 +479,22 @@ static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino)
500 if (!ir.ir_length) { 479 if (!ir.ir_length) {
501 struct buffer_head *m_bh; 480 struct buffer_head *m_bh;
502 u64 x, y; 481 u64 x, y;
482 __be64 z;
503 483
504 error = gfs2_meta_inode_buffer(m_ip, &m_bh); 484 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
505 if (error) 485 if (error)
506 goto out_brelse; 486 goto out_brelse;
507 487
508 x = *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)); 488 z = *(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode));
509 x = y = be64_to_cpu(x); 489 x = y = be64_to_cpu(z);
510 ir.ir_start = x; 490 ir.ir_start = x;
511 ir.ir_length = GFS2_INUM_QUANTUM; 491 ir.ir_length = GFS2_INUM_QUANTUM;
512 x += GFS2_INUM_QUANTUM; 492 x += GFS2_INUM_QUANTUM;
513 if (x < y) 493 if (x < y)
514 gfs2_consist_inode(m_ip); 494 gfs2_consist_inode(m_ip);
515 x = cpu_to_be64(x); 495 z = cpu_to_be64(x);
516 gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1); 496 gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1);
517 *(u64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = x; 497 *(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = z;
518 498
519 brelse(m_bh); 499 brelse(m_bh);
520 } 500 }
@@ -567,7 +547,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
567 return error; 547 return error;
568 548
569 /* Don't create entries in an unlinked directory */ 549 /* Don't create entries in an unlinked directory */
570 if (!dip->i_di.di_nlink) 550 if (!dip->i_inode.i_nlink)
571 return -EPERM; 551 return -EPERM;
572 552
573 error = gfs2_dir_search(&dip->i_inode, name, NULL, NULL); 553 error = gfs2_dir_search(&dip->i_inode, name, NULL, NULL);
@@ -583,7 +563,7 @@ static int create_ok(struct gfs2_inode *dip, const struct qstr *name,
583 563
584 if (dip->i_di.di_entries == (u32)-1) 564 if (dip->i_di.di_entries == (u32)-1)
585 return -EFBIG; 565 return -EFBIG;
586 if (S_ISDIR(mode) && dip->i_di.di_nlink == (u32)-1) 566 if (S_ISDIR(mode) && dip->i_inode.i_nlink == (u32)-1)
587 return -EMLINK; 567 return -EMLINK;
588 568
589 return 0; 569 return 0;
@@ -593,24 +573,24 @@ static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode,
593 unsigned int *uid, unsigned int *gid) 573 unsigned int *uid, unsigned int *gid)
594{ 574{
595 if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir && 575 if (GFS2_SB(&dip->i_inode)->sd_args.ar_suiddir &&
596 (dip->i_di.di_mode & S_ISUID) && dip->i_di.di_uid) { 576 (dip->i_inode.i_mode & S_ISUID) && dip->i_inode.i_uid) {
597 if (S_ISDIR(*mode)) 577 if (S_ISDIR(*mode))
598 *mode |= S_ISUID; 578 *mode |= S_ISUID;
599 else if (dip->i_di.di_uid != current->fsuid) 579 else if (dip->i_inode.i_uid != current->fsuid)
600 *mode &= ~07111; 580 *mode &= ~07111;
601 *uid = dip->i_di.di_uid; 581 *uid = dip->i_inode.i_uid;
602 } else 582 } else
603 *uid = current->fsuid; 583 *uid = current->fsuid;
604 584
605 if (dip->i_di.di_mode & S_ISGID) { 585 if (dip->i_inode.i_mode & S_ISGID) {
606 if (S_ISDIR(*mode)) 586 if (S_ISDIR(*mode))
607 *mode |= S_ISGID; 587 *mode |= S_ISGID;
608 *gid = dip->i_di.di_gid; 588 *gid = dip->i_inode.i_gid;
609 } else 589 } else
610 *gid = current->fsgid; 590 *gid = current->fsgid;
611} 591}
612 592
613static int alloc_dinode(struct gfs2_inode *dip, struct gfs2_inum *inum, 593static int alloc_dinode(struct gfs2_inode *dip, struct gfs2_inum_host *inum,
614 u64 *generation) 594 u64 *generation)
615{ 595{
616 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 596 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
@@ -650,9 +630,9 @@ out:
650 */ 630 */
651 631
652static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, 632static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
653 const struct gfs2_inum *inum, unsigned int mode, 633 const struct gfs2_inum_host *inum, unsigned int mode,
654 unsigned int uid, unsigned int gid, 634 unsigned int uid, unsigned int gid,
655 const u64 *generation) 635 const u64 *generation, dev_t dev)
656{ 636{
657 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 637 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
658 struct gfs2_dinode *di; 638 struct gfs2_dinode *di;
@@ -669,14 +649,15 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
669 di->di_mode = cpu_to_be32(mode); 649 di->di_mode = cpu_to_be32(mode);
670 di->di_uid = cpu_to_be32(uid); 650 di->di_uid = cpu_to_be32(uid);
671 di->di_gid = cpu_to_be32(gid); 651 di->di_gid = cpu_to_be32(gid);
672 di->di_nlink = cpu_to_be32(0); 652 di->di_nlink = 0;
673 di->di_size = cpu_to_be64(0); 653 di->di_size = 0;
674 di->di_blocks = cpu_to_be64(1); 654 di->di_blocks = cpu_to_be64(1);
675 di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(get_seconds()); 655 di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(get_seconds());
676 di->di_major = di->di_minor = cpu_to_be32(0); 656 di->di_major = cpu_to_be32(MAJOR(dev));
657 di->di_minor = cpu_to_be32(MINOR(dev));
677 di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr); 658 di->di_goal_meta = di->di_goal_data = cpu_to_be64(inum->no_addr);
678 di->di_generation = cpu_to_be64(*generation); 659 di->di_generation = cpu_to_be64(*generation);
679 di->di_flags = cpu_to_be32(0); 660 di->di_flags = 0;
680 661
681 if (S_ISREG(mode)) { 662 if (S_ISREG(mode)) {
682 if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA) || 663 if ((dip->i_di.di_flags & GFS2_DIF_INHERIT_JDATA) ||
@@ -693,22 +674,22 @@ static void init_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
693 } 674 }
694 675
695 di->__pad1 = 0; 676 di->__pad1 = 0;
696 di->di_payload_format = cpu_to_be32(0); 677 di->di_payload_format = cpu_to_be32(S_ISDIR(mode) ? GFS2_FORMAT_DE : 0);
697 di->di_height = cpu_to_be32(0); 678 di->di_height = 0;
698 di->__pad2 = 0; 679 di->__pad2 = 0;
699 di->__pad3 = 0; 680 di->__pad3 = 0;
700 di->di_depth = cpu_to_be16(0); 681 di->di_depth = 0;
701 di->di_entries = cpu_to_be32(0); 682 di->di_entries = 0;
702 memset(&di->__pad4, 0, sizeof(di->__pad4)); 683 memset(&di->__pad4, 0, sizeof(di->__pad4));
703 di->di_eattr = cpu_to_be64(0); 684 di->di_eattr = 0;
704 memset(&di->di_reserved, 0, sizeof(di->di_reserved)); 685 memset(&di->di_reserved, 0, sizeof(di->di_reserved));
705 686
706 brelse(dibh); 687 brelse(dibh);
707} 688}
708 689
709static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, 690static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
710 unsigned int mode, const struct gfs2_inum *inum, 691 unsigned int mode, const struct gfs2_inum_host *inum,
711 const u64 *generation) 692 const u64 *generation, dev_t dev)
712{ 693{
713 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 694 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
714 unsigned int uid, gid; 695 unsigned int uid, gid;
@@ -729,7 +710,7 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl,
729 if (error) 710 if (error)
730 goto out_quota; 711 goto out_quota;
731 712
732 init_dinode(dip, gl, inum, mode, uid, gid, generation); 713 init_dinode(dip, gl, inum, mode, uid, gid, generation, dev);
733 gfs2_quota_change(dip, +1, uid, gid); 714 gfs2_quota_change(dip, +1, uid, gid);
734 gfs2_trans_end(sdp); 715 gfs2_trans_end(sdp);
735 716
@@ -759,8 +740,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
759 if (alloc_required < 0) 740 if (alloc_required < 0)
760 goto fail; 741 goto fail;
761 if (alloc_required) { 742 if (alloc_required) {
762 error = gfs2_quota_check(dip, dip->i_di.di_uid, 743 error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid);
763 dip->i_di.di_gid);
764 if (error) 744 if (error)
765 goto fail_quota_locks; 745 goto fail_quota_locks;
766 746
@@ -782,16 +762,16 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name,
782 goto fail_quota_locks; 762 goto fail_quota_locks;
783 } 763 }
784 764
785 error = gfs2_dir_add(&dip->i_inode, name, &ip->i_num, IF2DT(ip->i_di.di_mode)); 765 error = gfs2_dir_add(&dip->i_inode, name, &ip->i_num, IF2DT(ip->i_inode.i_mode));
786 if (error) 766 if (error)
787 goto fail_end_trans; 767 goto fail_end_trans;
788 768
789 error = gfs2_meta_inode_buffer(ip, &dibh); 769 error = gfs2_meta_inode_buffer(ip, &dibh);
790 if (error) 770 if (error)
791 goto fail_end_trans; 771 goto fail_end_trans;
792 ip->i_di.di_nlink = 1; 772 ip->i_inode.i_nlink = 1;
793 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 773 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
794 gfs2_dinode_out(&ip->i_di, dibh->b_data); 774 gfs2_dinode_out(ip, dibh->b_data);
795 brelse(dibh); 775 brelse(dibh);
796 return 0; 776 return 0;
797 777
@@ -860,13 +840,13 @@ static int gfs2_security_init(struct gfs2_inode *dip, struct gfs2_inode *ip)
860 */ 840 */
861 841
862struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, 842struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
863 unsigned int mode) 843 unsigned int mode, dev_t dev)
864{ 844{
865 struct inode *inode; 845 struct inode *inode;
866 struct gfs2_inode *dip = ghs->gh_gl->gl_object; 846 struct gfs2_inode *dip = ghs->gh_gl->gl_object;
867 struct inode *dir = &dip->i_inode; 847 struct inode *dir = &dip->i_inode;
868 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); 848 struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode);
869 struct gfs2_inum inum; 849 struct gfs2_inum_host inum;
870 int error; 850 int error;
871 u64 generation; 851 u64 generation;
872 852
@@ -890,35 +870,12 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
890 if (error) 870 if (error)
891 goto fail_gunlock; 871 goto fail_gunlock;
892 872
893 if (inum.no_addr < dip->i_num.no_addr) { 873 error = gfs2_glock_nq_num(sdp, inum.no_addr, &gfs2_inode_glops,
894 gfs2_glock_dq(ghs); 874 LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1);
895 875 if (error)
896 error = gfs2_glock_nq_num(sdp, inum.no_addr, 876 goto fail_gunlock;
897 &gfs2_inode_glops, LM_ST_EXCLUSIVE,
898 GL_SKIP, ghs + 1);
899 if (error) {
900 return ERR_PTR(error);
901 }
902
903 gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs);
904 error = gfs2_glock_nq(ghs);
905 if (error) {
906 gfs2_glock_dq_uninit(ghs + 1);
907 return ERR_PTR(error);
908 }
909
910 error = create_ok(dip, name, mode);
911 if (error)
912 goto fail_gunlock2;
913 } else {
914 error = gfs2_glock_nq_num(sdp, inum.no_addr,
915 &gfs2_inode_glops, LM_ST_EXCLUSIVE,
916 GL_SKIP, ghs + 1);
917 if (error)
918 goto fail_gunlock;
919 }
920 877
921 error = make_dinode(dip, ghs[1].gh_gl, mode, &inum, &generation); 878 error = make_dinode(dip, ghs[1].gh_gl, mode, &inum, &generation, dev);
922 if (error) 879 if (error)
923 goto fail_gunlock2; 880 goto fail_gunlock2;
924 881
@@ -975,7 +932,7 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
975 932
976 if (ip->i_di.di_entries != 2) { 933 if (ip->i_di.di_entries != 2) {
977 if (gfs2_consist_inode(ip)) 934 if (gfs2_consist_inode(ip))
978 gfs2_dinode_print(&ip->i_di); 935 gfs2_dinode_print(ip);
979 return -EIO; 936 return -EIO;
980 } 937 }
981 938
@@ -997,7 +954,12 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
997 if (error) 954 if (error)
998 return error; 955 return error;
999 956
1000 error = gfs2_change_nlink(ip, -2); 957 /* It looks odd, but it really should be done twice */
958 error = gfs2_change_nlink(ip, -1);
959 if (error)
960 return error;
961
962 error = gfs2_change_nlink(ip, -1);
1001 if (error) 963 if (error)
1002 return error; 964 return error;
1003 965
@@ -1018,16 +980,16 @@ int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
1018int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name, 980int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
1019 struct gfs2_inode *ip) 981 struct gfs2_inode *ip)
1020{ 982{
1021 struct gfs2_inum inum; 983 struct gfs2_inum_host inum;
1022 unsigned int type; 984 unsigned int type;
1023 int error; 985 int error;
1024 986
1025 if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode)) 987 if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode))
1026 return -EPERM; 988 return -EPERM;
1027 989
1028 if ((dip->i_di.di_mode & S_ISVTX) && 990 if ((dip->i_inode.i_mode & S_ISVTX) &&
1029 dip->i_di.di_uid != current->fsuid && 991 dip->i_inode.i_uid != current->fsuid &&
1030 ip->i_di.di_uid != current->fsuid && !capable(CAP_FOWNER)) 992 ip->i_inode.i_uid != current->fsuid && !capable(CAP_FOWNER))
1031 return -EPERM; 993 return -EPERM;
1032 994
1033 if (IS_APPEND(&dip->i_inode)) 995 if (IS_APPEND(&dip->i_inode))
@@ -1044,7 +1006,7 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
1044 if (!gfs2_inum_equal(&inum, &ip->i_num)) 1006 if (!gfs2_inum_equal(&inum, &ip->i_num))
1045 return -ENOENT; 1007 return -ENOENT;
1046 1008
1047 if (IF2DT(ip->i_di.di_mode) != type) { 1009 if (IF2DT(ip->i_inode.i_mode) != type) {
1048 gfs2_consist_inode(dip); 1010 gfs2_consist_inode(dip);
1049 return -EIO; 1011 return -EIO;
1050 } 1012 }
@@ -1194,7 +1156,7 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh)
1194 return 0; 1156 return 0;
1195 1157
1196 curtime = get_seconds(); 1158 curtime = get_seconds();
1197 if (curtime - ip->i_di.di_atime >= quantum) { 1159 if (curtime - ip->i_inode.i_atime.tv_sec >= quantum) {
1198 gfs2_glock_dq(gh); 1160 gfs2_glock_dq(gh);
1199 gfs2_holder_reinit(LM_ST_EXCLUSIVE, gh->gh_flags & ~LM_FLAG_ANY, 1161 gfs2_holder_reinit(LM_ST_EXCLUSIVE, gh->gh_flags & ~LM_FLAG_ANY,
1200 gh); 1162 gh);
@@ -1206,7 +1168,7 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh)
1206 trying to get exclusive lock. */ 1168 trying to get exclusive lock. */
1207 1169
1208 curtime = get_seconds(); 1170 curtime = get_seconds();
1209 if (curtime - ip->i_di.di_atime >= quantum) { 1171 if (curtime - ip->i_inode.i_atime.tv_sec >= quantum) {
1210 struct buffer_head *dibh; 1172 struct buffer_head *dibh;
1211 struct gfs2_dinode *di; 1173 struct gfs2_dinode *di;
1212 1174
@@ -1220,11 +1182,11 @@ int gfs2_glock_nq_atime(struct gfs2_holder *gh)
1220 if (error) 1182 if (error)
1221 goto fail_end_trans; 1183 goto fail_end_trans;
1222 1184
1223 ip->i_di.di_atime = curtime; 1185 ip->i_inode.i_atime.tv_sec = curtime;
1224 1186
1225 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1187 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1226 di = (struct gfs2_dinode *)dibh->b_data; 1188 di = (struct gfs2_dinode *)dibh->b_data;
1227 di->di_atime = cpu_to_be64(ip->i_di.di_atime); 1189 di->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
1228 brelse(dibh); 1190 brelse(dibh);
1229 1191
1230 gfs2_trans_end(sdp); 1192 gfs2_trans_end(sdp);
@@ -1249,92 +1211,6 @@ fail:
1249 return error; 1211 return error;
1250} 1212}
1251 1213
1252/**
1253 * glock_compare_atime - Compare two struct gfs2_glock structures for sort
1254 * @arg_a: the first structure
1255 * @arg_b: the second structure
1256 *
1257 * Returns: 1 if A > B
1258 * -1 if A < B
1259 * 0 if A == B
1260 */
1261
1262static int glock_compare_atime(const void *arg_a, const void *arg_b)
1263{
1264 const struct gfs2_holder *gh_a = *(const struct gfs2_holder **)arg_a;
1265 const struct gfs2_holder *gh_b = *(const struct gfs2_holder **)arg_b;
1266 const struct lm_lockname *a = &gh_a->gh_gl->gl_name;
1267 const struct lm_lockname *b = &gh_b->gh_gl->gl_name;
1268
1269 if (a->ln_number > b->ln_number)
1270 return 1;
1271 if (a->ln_number < b->ln_number)
1272 return -1;
1273 if (gh_a->gh_state == LM_ST_SHARED && gh_b->gh_state == LM_ST_EXCLUSIVE)
1274 return 1;
1275 if (gh_a->gh_state == LM_ST_SHARED && (gh_b->gh_flags & GL_ATIME))
1276 return 1;
1277
1278 return 0;
1279}
1280
1281/**
1282 * gfs2_glock_nq_m_atime - acquire multiple glocks where one may need an
1283 * atime update
1284 * @num_gh: the number of structures
1285 * @ghs: an array of struct gfs2_holder structures
1286 *
1287 * Returns: 0 on success (all glocks acquired),
1288 * errno on failure (no glocks acquired)
1289 */
1290
1291int gfs2_glock_nq_m_atime(unsigned int num_gh, struct gfs2_holder *ghs)
1292{
1293 struct gfs2_holder **p;
1294 unsigned int x;
1295 int error = 0;
1296
1297 if (!num_gh)
1298 return 0;
1299
1300 if (num_gh == 1) {
1301 ghs->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC);
1302 if (ghs->gh_flags & GL_ATIME)
1303 error = gfs2_glock_nq_atime(ghs);
1304 else
1305 error = gfs2_glock_nq(ghs);
1306 return error;
1307 }
1308
1309 p = kcalloc(num_gh, sizeof(struct gfs2_holder *), GFP_KERNEL);
1310 if (!p)
1311 return -ENOMEM;
1312
1313 for (x = 0; x < num_gh; x++)
1314 p[x] = &ghs[x];
1315
1316 sort(p, num_gh, sizeof(struct gfs2_holder *), glock_compare_atime,NULL);
1317
1318 for (x = 0; x < num_gh; x++) {
1319 p[x]->gh_flags &= ~(LM_FLAG_TRY | GL_ASYNC);
1320
1321 if (p[x]->gh_flags & GL_ATIME)
1322 error = gfs2_glock_nq_atime(p[x]);
1323 else
1324 error = gfs2_glock_nq(p[x]);
1325
1326 if (error) {
1327 while (x--)
1328 gfs2_glock_dq(p[x]);
1329 break;
1330 }
1331 }
1332
1333 kfree(p);
1334 return error;
1335}
1336
1337
1338static int 1214static int
1339__gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr) 1215__gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
1340{ 1216{
@@ -1345,10 +1221,8 @@ __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
1345 if (!error) { 1221 if (!error) {
1346 error = inode_setattr(&ip->i_inode, attr); 1222 error = inode_setattr(&ip->i_inode, attr);
1347 gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error); 1223 gfs2_assert_warn(GFS2_SB(&ip->i_inode), !error);
1348 gfs2_inode_attr_out(ip);
1349
1350 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1224 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1351 gfs2_dinode_out(&ip->i_di, dibh->b_data); 1225 gfs2_dinode_out(ip, dibh->b_data);
1352 brelse(dibh); 1226 brelse(dibh);
1353 } 1227 }
1354 return error; 1228 return error;
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index f5d861760579..b57f448b15bc 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -22,13 +22,19 @@ static inline int gfs2_is_jdata(struct gfs2_inode *ip)
22 22
23static inline int gfs2_is_dir(struct gfs2_inode *ip) 23static inline int gfs2_is_dir(struct gfs2_inode *ip)
24{ 24{
25 return S_ISDIR(ip->i_di.di_mode); 25 return S_ISDIR(ip->i_inode.i_mode);
26}
27
28static inline void gfs2_set_inode_blocks(struct inode *inode)
29{
30 struct gfs2_inode *ip = GFS2_I(inode);
31 inode->i_blocks = ip->i_di.di_blocks <<
32 (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
26} 33}
27 34
28void gfs2_inode_attr_in(struct gfs2_inode *ip); 35void gfs2_inode_attr_in(struct gfs2_inode *ip);
29void gfs2_inode_attr_out(struct gfs2_inode *ip); 36struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum_host *inum, unsigned type);
30struct inode *gfs2_inode_lookup(struct super_block *sb, struct gfs2_inum *inum, unsigned type); 37struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum_host *inum);
31struct inode *gfs2_ilookup(struct super_block *sb, struct gfs2_inum *inum);
32 38
33int gfs2_inode_refresh(struct gfs2_inode *ip); 39int gfs2_inode_refresh(struct gfs2_inode *ip);
34 40
@@ -37,19 +43,15 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff);
37struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name, 43struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
38 int is_root, struct nameidata *nd); 44 int is_root, struct nameidata *nd);
39struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, 45struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
40 unsigned int mode); 46 unsigned int mode, dev_t dev);
41int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name, 47int gfs2_rmdiri(struct gfs2_inode *dip, const struct qstr *name,
42 struct gfs2_inode *ip); 48 struct gfs2_inode *ip);
43int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name, 49int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
44 struct gfs2_inode *ip); 50 struct gfs2_inode *ip);
45int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to); 51int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to);
46int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len); 52int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);
47
48int gfs2_glock_nq_atime(struct gfs2_holder *gh); 53int gfs2_glock_nq_atime(struct gfs2_holder *gh);
49int gfs2_glock_nq_m_atime(unsigned int num_gh, struct gfs2_holder *ghs);
50
51int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr); 54int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr);
52
53struct inode *gfs2_lookup_simple(struct inode *dip, const char *name); 55struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
54 56
55#endif /* __INODE_DOT_H__ */ 57#endif /* __INODE_DOT_H__ */
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 0cace3da9dbb..291415ddfe51 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -15,6 +15,7 @@
15#include <linux/gfs2_ondisk.h> 15#include <linux/gfs2_ondisk.h>
16#include <linux/crc32.h> 16#include <linux/crc32.h>
17#include <linux/lm_interface.h> 17#include <linux/lm_interface.h>
18#include <linux/delay.h>
18 19
19#include "gfs2.h" 20#include "gfs2.h"
20#include "incore.h" 21#include "incore.h"
@@ -142,7 +143,7 @@ static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_ail *ai, int fl
142 return list_empty(&ai->ai_ail1_list); 143 return list_empty(&ai->ai_ail1_list);
143} 144}
144 145
145void gfs2_ail1_start(struct gfs2_sbd *sdp, int flags) 146static void gfs2_ail1_start(struct gfs2_sbd *sdp, int flags)
146{ 147{
147 struct list_head *head = &sdp->sd_ail1_list; 148 struct list_head *head = &sdp->sd_ail1_list;
148 u64 sync_gen; 149 u64 sync_gen;
@@ -261,6 +262,12 @@ static void ail2_empty(struct gfs2_sbd *sdp, unsigned int new_tail)
261 * @sdp: The GFS2 superblock 262 * @sdp: The GFS2 superblock
262 * @blks: The number of blocks to reserve 263 * @blks: The number of blocks to reserve
263 * 264 *
265 * Note that we never give out the last 6 blocks of the journal. Thats
266 * due to the fact that there is are a small number of header blocks
267 * associated with each log flush. The exact number can't be known until
268 * flush time, so we ensure that we have just enough free blocks at all
269 * times to avoid running out during a log flush.
270 *
264 * Returns: errno 271 * Returns: errno
265 */ 272 */
266 273
@@ -274,7 +281,7 @@ int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)
274 281
275 mutex_lock(&sdp->sd_log_reserve_mutex); 282 mutex_lock(&sdp->sd_log_reserve_mutex);
276 gfs2_log_lock(sdp); 283 gfs2_log_lock(sdp);
277 while(sdp->sd_log_blks_free <= blks) { 284 while(sdp->sd_log_blks_free <= (blks + 6)) {
278 gfs2_log_unlock(sdp); 285 gfs2_log_unlock(sdp);
279 gfs2_ail1_empty(sdp, 0); 286 gfs2_ail1_empty(sdp, 0);
280 gfs2_log_flush(sdp, NULL); 287 gfs2_log_flush(sdp, NULL);
@@ -319,7 +326,8 @@ static u64 log_bmap(struct gfs2_sbd *sdp, unsigned int lbn)
319 bh_map.b_size = 1 << inode->i_blkbits; 326 bh_map.b_size = 1 << inode->i_blkbits;
320 error = gfs2_block_map(inode, lbn, 0, &bh_map); 327 error = gfs2_block_map(inode, lbn, 0, &bh_map);
321 if (error || !bh_map.b_blocknr) 328 if (error || !bh_map.b_blocknr)
322 printk(KERN_INFO "error=%d, dbn=%llu lbn=%u", error, bh_map.b_blocknr, lbn); 329 printk(KERN_INFO "error=%d, dbn=%llu lbn=%u", error,
330 (unsigned long long)bh_map.b_blocknr, lbn);
323 gfs2_assert_withdraw(sdp, !error && bh_map.b_blocknr); 331 gfs2_assert_withdraw(sdp, !error && bh_map.b_blocknr);
324 332
325 return bh_map.b_blocknr; 333 return bh_map.b_blocknr;
@@ -643,12 +651,9 @@ void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *tr)
643 up_read(&sdp->sd_log_flush_lock); 651 up_read(&sdp->sd_log_flush_lock);
644 652
645 gfs2_log_lock(sdp); 653 gfs2_log_lock(sdp);
646 if (sdp->sd_log_num_buf > gfs2_tune_get(sdp, gt_incore_log_blocks)) { 654 if (sdp->sd_log_num_buf > gfs2_tune_get(sdp, gt_incore_log_blocks))
647 gfs2_log_unlock(sdp); 655 wake_up_process(sdp->sd_logd_process);
648 gfs2_log_flush(sdp, NULL); 656 gfs2_log_unlock(sdp);
649 } else {
650 gfs2_log_unlock(sdp);
651 }
652} 657}
653 658
654/** 659/**
@@ -686,3 +691,21 @@ void gfs2_log_shutdown(struct gfs2_sbd *sdp)
686 up_write(&sdp->sd_log_flush_lock); 691 up_write(&sdp->sd_log_flush_lock);
687} 692}
688 693
694
695/**
696 * gfs2_meta_syncfs - sync all the buffers in a filesystem
697 * @sdp: the filesystem
698 *
699 */
700
701void gfs2_meta_syncfs(struct gfs2_sbd *sdp)
702{
703 gfs2_log_flush(sdp, NULL);
704 for (;;) {
705 gfs2_ail1_start(sdp, DIO_ALL);
706 if (gfs2_ail1_empty(sdp, DIO_ALL))
707 break;
708 msleep(10);
709 }
710}
711
diff --git a/fs/gfs2/log.h b/fs/gfs2/log.h
index 7f5737d55612..8e7aa0f29109 100644
--- a/fs/gfs2/log.h
+++ b/fs/gfs2/log.h
@@ -48,7 +48,6 @@ static inline void gfs2_log_pointers_init(struct gfs2_sbd *sdp,
48unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct, 48unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct,
49 unsigned int ssize); 49 unsigned int ssize);
50 50
51void gfs2_ail1_start(struct gfs2_sbd *sdp, int flags);
52int gfs2_ail1_empty(struct gfs2_sbd *sdp, int flags); 51int gfs2_ail1_empty(struct gfs2_sbd *sdp, int flags);
53 52
54int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks); 53int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks);
@@ -61,5 +60,6 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl);
61void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans); 60void gfs2_log_commit(struct gfs2_sbd *sdp, struct gfs2_trans *trans);
62 61
63void gfs2_log_shutdown(struct gfs2_sbd *sdp); 62void gfs2_log_shutdown(struct gfs2_sbd *sdp);
63void gfs2_meta_syncfs(struct gfs2_sbd *sdp);
64 64
65#endif /* __LOG_DOT_H__ */ 65#endif /* __LOG_DOT_H__ */
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index ab6d1115f95d..4d7f94d8c7bd 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -182,7 +182,7 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
182} 182}
183 183
184static void buf_lo_before_scan(struct gfs2_jdesc *jd, 184static void buf_lo_before_scan(struct gfs2_jdesc *jd,
185 struct gfs2_log_header *head, int pass) 185 struct gfs2_log_header_host *head, int pass)
186{ 186{
187 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); 187 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
188 188
@@ -328,7 +328,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
328} 328}
329 329
330static void revoke_lo_before_scan(struct gfs2_jdesc *jd, 330static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
331 struct gfs2_log_header *head, int pass) 331 struct gfs2_log_header_host *head, int pass)
332{ 332{
333 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); 333 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
334 334
@@ -509,7 +509,7 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
509{ 509{
510 LIST_HEAD(started); 510 LIST_HEAD(started);
511 struct gfs2_bufdata *bd1 = NULL, *bd2, *bdt; 511 struct gfs2_bufdata *bd1 = NULL, *bd2, *bdt;
512 struct buffer_head *bh = NULL; 512 struct buffer_head *bh = NULL,*bh1 = NULL;
513 unsigned int offset = sizeof(struct gfs2_log_descriptor); 513 unsigned int offset = sizeof(struct gfs2_log_descriptor);
514 struct gfs2_log_descriptor *ld; 514 struct gfs2_log_descriptor *ld;
515 unsigned int limit; 515 unsigned int limit;
@@ -537,8 +537,13 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
537 list_for_each_entry_safe_continue(bd1, bdt, 537 list_for_each_entry_safe_continue(bd1, bdt,
538 &sdp->sd_log_le_databuf, 538 &sdp->sd_log_le_databuf,
539 bd_le.le_list) { 539 bd_le.le_list) {
540 /* store off the buffer head in a local ptr since
541 * gfs2_bufdata might change when we drop the log lock
542 */
543 bh1 = bd1->bd_bh;
544
540 /* An ordered write buffer */ 545 /* An ordered write buffer */
541 if (bd1->bd_bh && !buffer_pinned(bd1->bd_bh)) { 546 if (bh1 && !buffer_pinned(bh1)) {
542 list_move(&bd1->bd_le.le_list, &started); 547 list_move(&bd1->bd_le.le_list, &started);
543 if (bd1 == bd2) { 548 if (bd1 == bd2) {
544 bd2 = NULL; 549 bd2 = NULL;
@@ -547,20 +552,21 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
547 bd_le.le_list); 552 bd_le.le_list);
548 } 553 }
549 total_dbuf--; 554 total_dbuf--;
550 if (bd1->bd_bh) { 555 if (bh1) {
551 get_bh(bd1->bd_bh); 556 if (buffer_dirty(bh1)) {
552 if (buffer_dirty(bd1->bd_bh)) { 557 get_bh(bh1);
558
553 gfs2_log_unlock(sdp); 559 gfs2_log_unlock(sdp);
554 wait_on_buffer(bd1->bd_bh); 560
555 ll_rw_block(WRITE, 1, 561 ll_rw_block(SWRITE, 1, &bh1);
556 &bd1->bd_bh); 562 brelse(bh1);
563
557 gfs2_log_lock(sdp); 564 gfs2_log_lock(sdp);
558 } 565 }
559 brelse(bd1->bd_bh);
560 continue; 566 continue;
561 } 567 }
562 continue; 568 continue;
563 } else if (bd1->bd_bh) { /* A journaled buffer */ 569 } else if (bh1) { /* A journaled buffer */
564 int magic; 570 int magic;
565 gfs2_log_unlock(sdp); 571 gfs2_log_unlock(sdp);
566 if (!bh) { 572 if (!bh) {
@@ -582,16 +588,16 @@ static void databuf_lo_before_commit(struct gfs2_sbd *sdp)
582 ld->ld_data2 = cpu_to_be32(0); 588 ld->ld_data2 = cpu_to_be32(0);
583 memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved)); 589 memset(ld->ld_reserved, 0, sizeof(ld->ld_reserved));
584 } 590 }
585 magic = gfs2_check_magic(bd1->bd_bh); 591 magic = gfs2_check_magic(bh1);
586 *ptr++ = cpu_to_be64(bd1->bd_bh->b_blocknr); 592 *ptr++ = cpu_to_be64(bh1->b_blocknr);
587 *ptr++ = cpu_to_be64((__u64)magic); 593 *ptr++ = cpu_to_be64((__u64)magic);
588 clear_buffer_escaped(bd1->bd_bh); 594 clear_buffer_escaped(bh1);
589 if (unlikely(magic != 0)) 595 if (unlikely(magic != 0))
590 set_buffer_escaped(bd1->bd_bh); 596 set_buffer_escaped(bh1);
591 gfs2_log_lock(sdp); 597 gfs2_log_lock(sdp);
592 if (n++ > num) 598 if (n++ > num)
593 break; 599 break;
594 } else if (!bd1->bd_bh) { 600 } else if (!bh1) {
595 total_dbuf--; 601 total_dbuf--;
596 sdp->sd_log_num_databuf--; 602 sdp->sd_log_num_databuf--;
597 list_del_init(&bd1->bd_le.le_list); 603 list_del_init(&bd1->bd_le.le_list);
diff --git a/fs/gfs2/lops.h b/fs/gfs2/lops.h
index 5839c05ae6be..965bc65c7c64 100644
--- a/fs/gfs2/lops.h
+++ b/fs/gfs2/lops.h
@@ -60,7 +60,7 @@ static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
60} 60}
61 61
62static inline void lops_before_scan(struct gfs2_jdesc *jd, 62static inline void lops_before_scan(struct gfs2_jdesc *jd,
63 struct gfs2_log_header *head, 63 struct gfs2_log_header_host *head,
64 unsigned int pass) 64 unsigned int pass)
65{ 65{
66 int x; 66 int x;
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c
index 9889c1eacec1..7c1a9e22a526 100644
--- a/fs/gfs2/main.c
+++ b/fs/gfs2/main.c
@@ -25,7 +25,7 @@
25#include "util.h" 25#include "util.h"
26#include "glock.h" 26#include "glock.h"
27 27
28static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 28static void gfs2_init_inode_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
29{ 29{
30 struct gfs2_inode *ip = foo; 30 struct gfs2_inode *ip = foo;
31 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 31 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
@@ -37,7 +37,7 @@ static void gfs2_init_inode_once(void *foo, kmem_cache_t *cachep, unsigned long
37 } 37 }
38} 38}
39 39
40static void gfs2_init_glock_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 40static void gfs2_init_glock_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
41{ 41{
42 struct gfs2_glock *gl = foo; 42 struct gfs2_glock *gl = foo;
43 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) == 43 if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c
index 3912d6a4b1e6..0e34d9918973 100644
--- a/fs/gfs2/meta_io.c
+++ b/fs/gfs2/meta_io.c
@@ -127,17 +127,17 @@ void gfs2_meta_sync(struct gfs2_glock *gl)
127 127
128/** 128/**
129 * getbuf - Get a buffer with a given address space 129 * getbuf - Get a buffer with a given address space
130 * @sdp: the filesystem 130 * @gl: the glock
131 * @aspace: the address space
132 * @blkno: the block number (filesystem scope) 131 * @blkno: the block number (filesystem scope)
133 * @create: 1 if the buffer should be created 132 * @create: 1 if the buffer should be created
134 * 133 *
135 * Returns: the buffer 134 * Returns: the buffer
136 */ 135 */
137 136
138static struct buffer_head *getbuf(struct gfs2_sbd *sdp, struct inode *aspace, 137static struct buffer_head *getbuf(struct gfs2_glock *gl, u64 blkno, int create)
139 u64 blkno, int create)
140{ 138{
139 struct address_space *mapping = gl->gl_aspace->i_mapping;
140 struct gfs2_sbd *sdp = gl->gl_sbd;
141 struct page *page; 141 struct page *page;
142 struct buffer_head *bh; 142 struct buffer_head *bh;
143 unsigned int shift; 143 unsigned int shift;
@@ -150,13 +150,13 @@ static struct buffer_head *getbuf(struct gfs2_sbd *sdp, struct inode *aspace,
150 150
151 if (create) { 151 if (create) {
152 for (;;) { 152 for (;;) {
153 page = grab_cache_page(aspace->i_mapping, index); 153 page = grab_cache_page(mapping, index);
154 if (page) 154 if (page)
155 break; 155 break;
156 yield(); 156 yield();
157 } 157 }
158 } else { 158 } else {
159 page = find_lock_page(aspace->i_mapping, index); 159 page = find_lock_page(mapping, index);
160 if (!page) 160 if (!page)
161 return NULL; 161 return NULL;
162 } 162 }
@@ -202,7 +202,7 @@ static void meta_prep_new(struct buffer_head *bh)
202struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno) 202struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno)
203{ 203{
204 struct buffer_head *bh; 204 struct buffer_head *bh;
205 bh = getbuf(gl->gl_sbd, gl->gl_aspace, blkno, CREATE); 205 bh = getbuf(gl, blkno, CREATE);
206 meta_prep_new(bh); 206 meta_prep_new(bh);
207 return bh; 207 return bh;
208} 208}
@@ -220,7 +220,7 @@ struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno)
220int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags, 220int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno, int flags,
221 struct buffer_head **bhp) 221 struct buffer_head **bhp)
222{ 222{
223 *bhp = getbuf(gl->gl_sbd, gl->gl_aspace, blkno, CREATE); 223 *bhp = getbuf(gl, blkno, CREATE);
224 if (!buffer_uptodate(*bhp)) 224 if (!buffer_uptodate(*bhp))
225 ll_rw_block(READ_META, 1, bhp); 225 ll_rw_block(READ_META, 1, bhp);
226 if (flags & DIO_WAIT) { 226 if (flags & DIO_WAIT) {
@@ -379,11 +379,10 @@ void gfs2_unpin(struct gfs2_sbd *sdp, struct buffer_head *bh,
379void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen) 379void gfs2_meta_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen)
380{ 380{
381 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 381 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
382 struct inode *aspace = ip->i_gl->gl_aspace;
383 struct buffer_head *bh; 382 struct buffer_head *bh;
384 383
385 while (blen) { 384 while (blen) {
386 bh = getbuf(sdp, aspace, bstart, NO_CREATE); 385 bh = getbuf(ip->i_gl, bstart, NO_CREATE);
387 if (bh) { 386 if (bh) {
388 struct gfs2_bufdata *bd = bh->b_private; 387 struct gfs2_bufdata *bd = bh->b_private;
389 388
@@ -472,6 +471,9 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num,
472 struct buffer_head *bh = NULL, **bh_slot = ip->i_cache + height; 471 struct buffer_head *bh = NULL, **bh_slot = ip->i_cache + height;
473 int in_cache = 0; 472 int in_cache = 0;
474 473
474 BUG_ON(!gl);
475 BUG_ON(!sdp);
476
475 spin_lock(&ip->i_spin); 477 spin_lock(&ip->i_spin);
476 if (*bh_slot && (*bh_slot)->b_blocknr == num) { 478 if (*bh_slot && (*bh_slot)->b_blocknr == num) {
477 bh = *bh_slot; 479 bh = *bh_slot;
@@ -481,7 +483,7 @@ int gfs2_meta_indirect_buffer(struct gfs2_inode *ip, int height, u64 num,
481 spin_unlock(&ip->i_spin); 483 spin_unlock(&ip->i_spin);
482 484
483 if (!bh) 485 if (!bh)
484 bh = getbuf(gl->gl_sbd, gl->gl_aspace, num, CREATE); 486 bh = getbuf(gl, num, CREATE);
485 487
486 if (!bh) 488 if (!bh)
487 return -ENOBUFS; 489 return -ENOBUFS;
@@ -532,7 +534,6 @@ err:
532struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen) 534struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
533{ 535{
534 struct gfs2_sbd *sdp = gl->gl_sbd; 536 struct gfs2_sbd *sdp = gl->gl_sbd;
535 struct inode *aspace = gl->gl_aspace;
536 struct buffer_head *first_bh, *bh; 537 struct buffer_head *first_bh, *bh;
537 u32 max_ra = gfs2_tune_get(sdp, gt_max_readahead) >> 538 u32 max_ra = gfs2_tune_get(sdp, gt_max_readahead) >>
538 sdp->sd_sb.sb_bsize_shift; 539 sdp->sd_sb.sb_bsize_shift;
@@ -544,7 +545,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
544 if (extlen > max_ra) 545 if (extlen > max_ra)
545 extlen = max_ra; 546 extlen = max_ra;
546 547
547 first_bh = getbuf(sdp, aspace, dblock, CREATE); 548 first_bh = getbuf(gl, dblock, CREATE);
548 549
549 if (buffer_uptodate(first_bh)) 550 if (buffer_uptodate(first_bh))
550 goto out; 551 goto out;
@@ -555,7 +556,7 @@ struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen)
555 extlen--; 556 extlen--;
556 557
557 while (extlen) { 558 while (extlen) {
558 bh = getbuf(sdp, aspace, dblock, CREATE); 559 bh = getbuf(gl, dblock, CREATE);
559 560
560 if (!buffer_uptodate(bh) && !buffer_locked(bh)) 561 if (!buffer_uptodate(bh) && !buffer_locked(bh))
561 ll_rw_block(READA, 1, &bh); 562 ll_rw_block(READA, 1, &bh);
@@ -571,20 +572,3 @@ out:
571 return first_bh; 572 return first_bh;
572} 573}
573 574
574/**
575 * gfs2_meta_syncfs - sync all the buffers in a filesystem
576 * @sdp: the filesystem
577 *
578 */
579
580void gfs2_meta_syncfs(struct gfs2_sbd *sdp)
581{
582 gfs2_log_flush(sdp, NULL);
583 for (;;) {
584 gfs2_ail1_start(sdp, DIO_ALL);
585 if (gfs2_ail1_empty(sdp, DIO_ALL))
586 break;
587 msleep(10);
588 }
589}
590
diff --git a/fs/gfs2/meta_io.h b/fs/gfs2/meta_io.h
index 3ec939e20dff..e037425bc042 100644
--- a/fs/gfs2/meta_io.h
+++ b/fs/gfs2/meta_io.h
@@ -67,7 +67,6 @@ static inline int gfs2_meta_inode_buffer(struct gfs2_inode *ip,
67} 67}
68 68
69struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen); 69struct buffer_head *gfs2_meta_ra(struct gfs2_glock *gl, u64 dblock, u32 extlen);
70void gfs2_meta_syncfs(struct gfs2_sbd *sdp);
71 70
72#define buffer_busy(bh) \ 71#define buffer_busy(bh) \
73((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned))) 72((bh)->b_state & ((1ul << BH_Dirty) | (1ul << BH_Lock) | (1ul << BH_Pinned)))
diff --git a/fs/gfs2/ondisk.c b/fs/gfs2/ondisk.c
index 1025960b0e6e..f2495f1e21ad 100644
--- a/fs/gfs2/ondisk.c
+++ b/fs/gfs2/ondisk.c
@@ -15,6 +15,8 @@
15 15
16#include "gfs2.h" 16#include "gfs2.h"
17#include <linux/gfs2_ondisk.h> 17#include <linux/gfs2_ondisk.h>
18#include <linux/lm_interface.h>
19#include "incore.h"
18 20
19#define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", \ 21#define pv(struct, member, fmt) printk(KERN_INFO " "#member" = "fmt"\n", \
20 struct->member); 22 struct->member);
@@ -32,7 +34,7 @@
32 * first arg: the cpu-order structure 34 * first arg: the cpu-order structure
33 */ 35 */
34 36
35void gfs2_inum_in(struct gfs2_inum *no, const void *buf) 37void gfs2_inum_in(struct gfs2_inum_host *no, const void *buf)
36{ 38{
37 const struct gfs2_inum *str = buf; 39 const struct gfs2_inum *str = buf;
38 40
@@ -40,7 +42,7 @@ void gfs2_inum_in(struct gfs2_inum *no, const void *buf)
40 no->no_addr = be64_to_cpu(str->no_addr); 42 no->no_addr = be64_to_cpu(str->no_addr);
41} 43}
42 44
43void gfs2_inum_out(const struct gfs2_inum *no, void *buf) 45void gfs2_inum_out(const struct gfs2_inum_host *no, void *buf)
44{ 46{
45 struct gfs2_inum *str = buf; 47 struct gfs2_inum *str = buf;
46 48
@@ -48,13 +50,13 @@ void gfs2_inum_out(const struct gfs2_inum *no, void *buf)
48 str->no_addr = cpu_to_be64(no->no_addr); 50 str->no_addr = cpu_to_be64(no->no_addr);
49} 51}
50 52
51static void gfs2_inum_print(const struct gfs2_inum *no) 53static void gfs2_inum_print(const struct gfs2_inum_host *no)
52{ 54{
53 printk(KERN_INFO " no_formal_ino = %llu\n", (unsigned long long)no->no_formal_ino); 55 printk(KERN_INFO " no_formal_ino = %llu\n", (unsigned long long)no->no_formal_ino);
54 printk(KERN_INFO " no_addr = %llu\n", (unsigned long long)no->no_addr); 56 printk(KERN_INFO " no_addr = %llu\n", (unsigned long long)no->no_addr);
55} 57}
56 58
57static void gfs2_meta_header_in(struct gfs2_meta_header *mh, const void *buf) 59static void gfs2_meta_header_in(struct gfs2_meta_header_host *mh, const void *buf)
58{ 60{
59 const struct gfs2_meta_header *str = buf; 61 const struct gfs2_meta_header *str = buf;
60 62
@@ -63,23 +65,7 @@ static void gfs2_meta_header_in(struct gfs2_meta_header *mh, const void *buf)
63 mh->mh_format = be32_to_cpu(str->mh_format); 65 mh->mh_format = be32_to_cpu(str->mh_format);
64} 66}
65 67
66static void gfs2_meta_header_out(const struct gfs2_meta_header *mh, void *buf) 68void gfs2_sb_in(struct gfs2_sb_host *sb, const void *buf)
67{
68 struct gfs2_meta_header *str = buf;
69
70 str->mh_magic = cpu_to_be32(mh->mh_magic);
71 str->mh_type = cpu_to_be32(mh->mh_type);
72 str->mh_format = cpu_to_be32(mh->mh_format);
73}
74
75static void gfs2_meta_header_print(const struct gfs2_meta_header *mh)
76{
77 pv(mh, mh_magic, "0x%.8X");
78 pv(mh, mh_type, "%u");
79 pv(mh, mh_format, "%u");
80}
81
82void gfs2_sb_in(struct gfs2_sb *sb, const void *buf)
83{ 69{
84 const struct gfs2_sb *str = buf; 70 const struct gfs2_sb *str = buf;
85 71
@@ -97,7 +83,7 @@ void gfs2_sb_in(struct gfs2_sb *sb, const void *buf)
97 memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN); 83 memcpy(sb->sb_locktable, str->sb_locktable, GFS2_LOCKNAME_LEN);
98} 84}
99 85
100void gfs2_rindex_in(struct gfs2_rindex *ri, const void *buf) 86void gfs2_rindex_in(struct gfs2_rindex_host *ri, const void *buf)
101{ 87{
102 const struct gfs2_rindex *str = buf; 88 const struct gfs2_rindex *str = buf;
103 89
@@ -109,7 +95,7 @@ void gfs2_rindex_in(struct gfs2_rindex *ri, const void *buf)
109 95
110} 96}
111 97
112void gfs2_rindex_print(const struct gfs2_rindex *ri) 98void gfs2_rindex_print(const struct gfs2_rindex_host *ri)
113{ 99{
114 printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)ri->ri_addr); 100 printk(KERN_INFO " ri_addr = %llu\n", (unsigned long long)ri->ri_addr);
115 pv(ri, ri_length, "%u"); 101 pv(ri, ri_length, "%u");
@@ -120,22 +106,20 @@ void gfs2_rindex_print(const struct gfs2_rindex *ri)
120 pv(ri, ri_bitbytes, "%u"); 106 pv(ri, ri_bitbytes, "%u");
121} 107}
122 108
123void gfs2_rgrp_in(struct gfs2_rgrp *rg, const void *buf) 109void gfs2_rgrp_in(struct gfs2_rgrp_host *rg, const void *buf)
124{ 110{
125 const struct gfs2_rgrp *str = buf; 111 const struct gfs2_rgrp *str = buf;
126 112
127 gfs2_meta_header_in(&rg->rg_header, buf);
128 rg->rg_flags = be32_to_cpu(str->rg_flags); 113 rg->rg_flags = be32_to_cpu(str->rg_flags);
129 rg->rg_free = be32_to_cpu(str->rg_free); 114 rg->rg_free = be32_to_cpu(str->rg_free);
130 rg->rg_dinodes = be32_to_cpu(str->rg_dinodes); 115 rg->rg_dinodes = be32_to_cpu(str->rg_dinodes);
131 rg->rg_igeneration = be64_to_cpu(str->rg_igeneration); 116 rg->rg_igeneration = be64_to_cpu(str->rg_igeneration);
132} 117}
133 118
134void gfs2_rgrp_out(const struct gfs2_rgrp *rg, void *buf) 119void gfs2_rgrp_out(const struct gfs2_rgrp_host *rg, void *buf)
135{ 120{
136 struct gfs2_rgrp *str = buf; 121 struct gfs2_rgrp *str = buf;
137 122
138 gfs2_meta_header_out(&rg->rg_header, buf);
139 str->rg_flags = cpu_to_be32(rg->rg_flags); 123 str->rg_flags = cpu_to_be32(rg->rg_flags);
140 str->rg_free = cpu_to_be32(rg->rg_free); 124 str->rg_free = cpu_to_be32(rg->rg_free);
141 str->rg_dinodes = cpu_to_be32(rg->rg_dinodes); 125 str->rg_dinodes = cpu_to_be32(rg->rg_dinodes);
@@ -144,7 +128,7 @@ void gfs2_rgrp_out(const struct gfs2_rgrp *rg, void *buf)
144 memset(&str->rg_reserved, 0, sizeof(str->rg_reserved)); 128 memset(&str->rg_reserved, 0, sizeof(str->rg_reserved));
145} 129}
146 130
147void gfs2_quota_in(struct gfs2_quota *qu, const void *buf) 131void gfs2_quota_in(struct gfs2_quota_host *qu, const void *buf)
148{ 132{
149 const struct gfs2_quota *str = buf; 133 const struct gfs2_quota *str = buf;
150 134
@@ -153,96 +137,56 @@ void gfs2_quota_in(struct gfs2_quota *qu, const void *buf)
153 qu->qu_value = be64_to_cpu(str->qu_value); 137 qu->qu_value = be64_to_cpu(str->qu_value);
154} 138}
155 139
156void gfs2_dinode_in(struct gfs2_dinode *di, const void *buf) 140void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
157{
158 const struct gfs2_dinode *str = buf;
159
160 gfs2_meta_header_in(&di->di_header, buf);
161 gfs2_inum_in(&di->di_num, &str->di_num);
162
163 di->di_mode = be32_to_cpu(str->di_mode);
164 di->di_uid = be32_to_cpu(str->di_uid);
165 di->di_gid = be32_to_cpu(str->di_gid);
166 di->di_nlink = be32_to_cpu(str->di_nlink);
167 di->di_size = be64_to_cpu(str->di_size);
168 di->di_blocks = be64_to_cpu(str->di_blocks);
169 di->di_atime = be64_to_cpu(str->di_atime);
170 di->di_mtime = be64_to_cpu(str->di_mtime);
171 di->di_ctime = be64_to_cpu(str->di_ctime);
172 di->di_major = be32_to_cpu(str->di_major);
173 di->di_minor = be32_to_cpu(str->di_minor);
174
175 di->di_goal_meta = be64_to_cpu(str->di_goal_meta);
176 di->di_goal_data = be64_to_cpu(str->di_goal_data);
177 di->di_generation = be64_to_cpu(str->di_generation);
178
179 di->di_flags = be32_to_cpu(str->di_flags);
180 di->di_payload_format = be32_to_cpu(str->di_payload_format);
181 di->di_height = be16_to_cpu(str->di_height);
182
183 di->di_depth = be16_to_cpu(str->di_depth);
184 di->di_entries = be32_to_cpu(str->di_entries);
185
186 di->di_eattr = be64_to_cpu(str->di_eattr);
187
188}
189
190void gfs2_dinode_out(const struct gfs2_dinode *di, void *buf)
191{ 141{
142 const struct gfs2_dinode_host *di = &ip->i_di;
192 struct gfs2_dinode *str = buf; 143 struct gfs2_dinode *str = buf;
193 144
194 gfs2_meta_header_out(&di->di_header, buf); 145 str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
195 gfs2_inum_out(&di->di_num, (char *)&str->di_num); 146 str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI);
147 str->di_header.__pad0 = 0;
148 str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI);
149 str->di_header.__pad1 = 0;
196 150
197 str->di_mode = cpu_to_be32(di->di_mode); 151 gfs2_inum_out(&ip->i_num, &str->di_num);
198 str->di_uid = cpu_to_be32(di->di_uid); 152
199 str->di_gid = cpu_to_be32(di->di_gid); 153 str->di_mode = cpu_to_be32(ip->i_inode.i_mode);
200 str->di_nlink = cpu_to_be32(di->di_nlink); 154 str->di_uid = cpu_to_be32(ip->i_inode.i_uid);
155 str->di_gid = cpu_to_be32(ip->i_inode.i_gid);
156 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink);
201 str->di_size = cpu_to_be64(di->di_size); 157 str->di_size = cpu_to_be64(di->di_size);
202 str->di_blocks = cpu_to_be64(di->di_blocks); 158 str->di_blocks = cpu_to_be64(di->di_blocks);
203 str->di_atime = cpu_to_be64(di->di_atime); 159 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
204 str->di_mtime = cpu_to_be64(di->di_mtime); 160 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec);
205 str->di_ctime = cpu_to_be64(di->di_ctime); 161 str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec);
206 str->di_major = cpu_to_be32(di->di_major);
207 str->di_minor = cpu_to_be32(di->di_minor);
208 162
209 str->di_goal_meta = cpu_to_be64(di->di_goal_meta); 163 str->di_goal_meta = cpu_to_be64(di->di_goal_meta);
210 str->di_goal_data = cpu_to_be64(di->di_goal_data); 164 str->di_goal_data = cpu_to_be64(di->di_goal_data);
211 str->di_generation = cpu_to_be64(di->di_generation); 165 str->di_generation = cpu_to_be64(di->di_generation);
212 166
213 str->di_flags = cpu_to_be32(di->di_flags); 167 str->di_flags = cpu_to_be32(di->di_flags);
214 str->di_payload_format = cpu_to_be32(di->di_payload_format);
215 str->di_height = cpu_to_be16(di->di_height); 168 str->di_height = cpu_to_be16(di->di_height);
216 169 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
170 !(ip->i_di.di_flags & GFS2_DIF_EXHASH) ?
171 GFS2_FORMAT_DE : 0);
217 str->di_depth = cpu_to_be16(di->di_depth); 172 str->di_depth = cpu_to_be16(di->di_depth);
218 str->di_entries = cpu_to_be32(di->di_entries); 173 str->di_entries = cpu_to_be32(di->di_entries);
219 174
220 str->di_eattr = cpu_to_be64(di->di_eattr); 175 str->di_eattr = cpu_to_be64(di->di_eattr);
221
222} 176}
223 177
224void gfs2_dinode_print(const struct gfs2_dinode *di) 178void gfs2_dinode_print(const struct gfs2_inode *ip)
225{ 179{
226 gfs2_meta_header_print(&di->di_header); 180 const struct gfs2_dinode_host *di = &ip->i_di;
227 gfs2_inum_print(&di->di_num); 181
182 gfs2_inum_print(&ip->i_num);
228 183
229 pv(di, di_mode, "0%o");
230 pv(di, di_uid, "%u");
231 pv(di, di_gid, "%u");
232 pv(di, di_nlink, "%u");
233 printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size); 184 printk(KERN_INFO " di_size = %llu\n", (unsigned long long)di->di_size);
234 printk(KERN_INFO " di_blocks = %llu\n", (unsigned long long)di->di_blocks); 185 printk(KERN_INFO " di_blocks = %llu\n", (unsigned long long)di->di_blocks);
235 printk(KERN_INFO " di_atime = %lld\n", (long long)di->di_atime);
236 printk(KERN_INFO " di_mtime = %lld\n", (long long)di->di_mtime);
237 printk(KERN_INFO " di_ctime = %lld\n", (long long)di->di_ctime);
238 pv(di, di_major, "%u");
239 pv(di, di_minor, "%u");
240
241 printk(KERN_INFO " di_goal_meta = %llu\n", (unsigned long long)di->di_goal_meta); 186 printk(KERN_INFO " di_goal_meta = %llu\n", (unsigned long long)di->di_goal_meta);
242 printk(KERN_INFO " di_goal_data = %llu\n", (unsigned long long)di->di_goal_data); 187 printk(KERN_INFO " di_goal_data = %llu\n", (unsigned long long)di->di_goal_data);
243 188
244 pv(di, di_flags, "0x%.8X"); 189 pv(di, di_flags, "0x%.8X");
245 pv(di, di_payload_format, "%u");
246 pv(di, di_height, "%u"); 190 pv(di, di_height, "%u");
247 191
248 pv(di, di_depth, "%u"); 192 pv(di, di_depth, "%u");
@@ -251,7 +195,7 @@ void gfs2_dinode_print(const struct gfs2_dinode *di)
251 printk(KERN_INFO " di_eattr = %llu\n", (unsigned long long)di->di_eattr); 195 printk(KERN_INFO " di_eattr = %llu\n", (unsigned long long)di->di_eattr);
252} 196}
253 197
254void gfs2_log_header_in(struct gfs2_log_header *lh, const void *buf) 198void gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf)
255{ 199{
256 const struct gfs2_log_header *str = buf; 200 const struct gfs2_log_header *str = buf;
257 201
@@ -263,7 +207,7 @@ void gfs2_log_header_in(struct gfs2_log_header *lh, const void *buf)
263 lh->lh_hash = be32_to_cpu(str->lh_hash); 207 lh->lh_hash = be32_to_cpu(str->lh_hash);
264} 208}
265 209
266void gfs2_inum_range_in(struct gfs2_inum_range *ir, const void *buf) 210void gfs2_inum_range_in(struct gfs2_inum_range_host *ir, const void *buf)
267{ 211{
268 const struct gfs2_inum_range *str = buf; 212 const struct gfs2_inum_range *str = buf;
269 213
@@ -271,7 +215,7 @@ void gfs2_inum_range_in(struct gfs2_inum_range *ir, const void *buf)
271 ir->ir_length = be64_to_cpu(str->ir_length); 215 ir->ir_length = be64_to_cpu(str->ir_length);
272} 216}
273 217
274void gfs2_inum_range_out(const struct gfs2_inum_range *ir, void *buf) 218void gfs2_inum_range_out(const struct gfs2_inum_range_host *ir, void *buf)
275{ 219{
276 struct gfs2_inum_range *str = buf; 220 struct gfs2_inum_range *str = buf;
277 221
@@ -279,7 +223,7 @@ void gfs2_inum_range_out(const struct gfs2_inum_range *ir, void *buf)
279 str->ir_length = cpu_to_be64(ir->ir_length); 223 str->ir_length = cpu_to_be64(ir->ir_length);
280} 224}
281 225
282void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, const void *buf) 226void gfs2_statfs_change_in(struct gfs2_statfs_change_host *sc, const void *buf)
283{ 227{
284 const struct gfs2_statfs_change *str = buf; 228 const struct gfs2_statfs_change *str = buf;
285 229
@@ -288,7 +232,7 @@ void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, const void *buf)
288 sc->sc_dinodes = be64_to_cpu(str->sc_dinodes); 232 sc->sc_dinodes = be64_to_cpu(str->sc_dinodes);
289} 233}
290 234
291void gfs2_statfs_change_out(const struct gfs2_statfs_change *sc, void *buf) 235void gfs2_statfs_change_out(const struct gfs2_statfs_change_host *sc, void *buf)
292{ 236{
293 struct gfs2_statfs_change *str = buf; 237 struct gfs2_statfs_change *str = buf;
294 238
@@ -297,7 +241,7 @@ void gfs2_statfs_change_out(const struct gfs2_statfs_change *sc, void *buf)
297 str->sc_dinodes = cpu_to_be64(sc->sc_dinodes); 241 str->sc_dinodes = cpu_to_be64(sc->sc_dinodes);
298} 242}
299 243
300void gfs2_quota_change_in(struct gfs2_quota_change *qc, const void *buf) 244void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *buf)
301{ 245{
302 const struct gfs2_quota_change *str = buf; 246 const struct gfs2_quota_change *str = buf;
303 247
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index 015640b3f123..d8d69a72a10d 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -156,19 +156,6 @@ out_ignore:
156 return 0; 156 return 0;
157} 157}
158 158
159static int zero_readpage(struct page *page)
160{
161 void *kaddr;
162
163 kaddr = kmap_atomic(page, KM_USER0);
164 memset(kaddr, 0, PAGE_CACHE_SIZE);
165 kunmap_atomic(kaddr, KM_USER0);
166
167 SetPageUptodate(page);
168
169 return 0;
170}
171
172/** 159/**
173 * stuffed_readpage - Fill in a Linux page with stuffed file data 160 * stuffed_readpage - Fill in a Linux page with stuffed file data
174 * @ip: the inode 161 * @ip: the inode
@@ -183,9 +170,7 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
183 void *kaddr; 170 void *kaddr;
184 int error; 171 int error;
185 172
186 /* Only the first page of a stuffed file might contain data */ 173 BUG_ON(page->index);
187 if (unlikely(page->index))
188 return zero_readpage(page);
189 174
190 error = gfs2_meta_inode_buffer(ip, &dibh); 175 error = gfs2_meta_inode_buffer(ip, &dibh);
191 if (error) 176 if (error)
@@ -230,9 +215,9 @@ static int gfs2_readpage(struct file *file, struct page *page)
230 /* gfs2_sharewrite_nopage has grabbed the ip->i_gl already */ 215 /* gfs2_sharewrite_nopage has grabbed the ip->i_gl already */
231 goto skip_lock; 216 goto skip_lock;
232 } 217 }
233 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|GL_AOP, &gh); 218 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|LM_FLAG_TRY_1CB, &gh);
234 do_unlock = 1; 219 do_unlock = 1;
235 error = gfs2_glock_nq_m_atime(1, &gh); 220 error = gfs2_glock_nq_atime(&gh);
236 if (unlikely(error)) 221 if (unlikely(error))
237 goto out_unlock; 222 goto out_unlock;
238 } 223 }
@@ -254,6 +239,8 @@ skip_lock:
254out: 239out:
255 return error; 240 return error;
256out_unlock: 241out_unlock:
242 if (error == GLR_TRYFAILED)
243 error = AOP_TRUNCATED_PAGE;
257 unlock_page(page); 244 unlock_page(page);
258 if (do_unlock) 245 if (do_unlock)
259 gfs2_holder_uninit(&gh); 246 gfs2_holder_uninit(&gh);
@@ -293,9 +280,9 @@ static int gfs2_readpages(struct file *file, struct address_space *mapping,
293 goto skip_lock; 280 goto skip_lock;
294 } 281 }
295 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 282 gfs2_holder_init(ip->i_gl, LM_ST_SHARED,
296 LM_FLAG_TRY_1CB|GL_ATIME|GL_AOP, &gh); 283 LM_FLAG_TRY_1CB|GL_ATIME, &gh);
297 do_unlock = 1; 284 do_unlock = 1;
298 ret = gfs2_glock_nq_m_atime(1, &gh); 285 ret = gfs2_glock_nq_atime(&gh);
299 if (ret == GLR_TRYFAILED) 286 if (ret == GLR_TRYFAILED)
300 goto out_noerror; 287 goto out_noerror;
301 if (unlikely(ret)) 288 if (unlikely(ret))
@@ -366,10 +353,13 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
366 unsigned int write_len = to - from; 353 unsigned int write_len = to - from;
367 354
368 355
369 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|GL_AOP, &ip->i_gh); 356 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|LM_FLAG_TRY_1CB, &ip->i_gh);
370 error = gfs2_glock_nq_m_atime(1, &ip->i_gh); 357 error = gfs2_glock_nq_atime(&ip->i_gh);
371 if (error) 358 if (unlikely(error)) {
359 if (error == GLR_TRYFAILED)
360 error = AOP_TRUNCATED_PAGE;
372 goto out_uninit; 361 goto out_uninit;
362 }
373 363
374 gfs2_write_calc_reserv(ip, write_len, &data_blocks, &ind_blocks); 364 gfs2_write_calc_reserv(ip, write_len, &data_blocks, &ind_blocks);
375 365
@@ -386,7 +376,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
386 if (error) 376 if (error)
387 goto out_alloc_put; 377 goto out_alloc_put;
388 378
389 error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid); 379 error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
390 if (error) 380 if (error)
391 goto out_qunlock; 381 goto out_qunlock;
392 382
@@ -482,8 +472,10 @@ static int gfs2_commit_write(struct file *file, struct page *page,
482 472
483 SetPageUptodate(page); 473 SetPageUptodate(page);
484 474
485 if (inode->i_size < file_size) 475 if (inode->i_size < file_size) {
486 i_size_write(inode, file_size); 476 i_size_write(inode, file_size);
477 mark_inode_dirty(inode);
478 }
487 } else { 479 } else {
488 if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || 480 if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED ||
489 gfs2_is_jdata(ip)) 481 gfs2_is_jdata(ip))
@@ -498,11 +490,6 @@ static int gfs2_commit_write(struct file *file, struct page *page,
498 di->di_size = cpu_to_be64(inode->i_size); 490 di->di_size = cpu_to_be64(inode->i_size);
499 } 491 }
500 492
501 di->di_mode = cpu_to_be32(inode->i_mode);
502 di->di_atime = cpu_to_be64(inode->i_atime.tv_sec);
503 di->di_mtime = cpu_to_be64(inode->i_mtime.tv_sec);
504 di->di_ctime = cpu_to_be64(inode->i_ctime.tv_sec);
505
506 brelse(dibh); 493 brelse(dibh);
507 gfs2_trans_end(sdp); 494 gfs2_trans_end(sdp);
508 if (al->al_requested) { 495 if (al->al_requested) {
@@ -624,7 +611,7 @@ static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
624 * on this path. All we need change is atime. 611 * on this path. All we need change is atime.
625 */ 612 */
626 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); 613 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
627 rv = gfs2_glock_nq_m_atime(1, &gh); 614 rv = gfs2_glock_nq_atime(&gh);
628 if (rv) 615 if (rv)
629 goto out; 616 goto out;
630 617
@@ -737,6 +724,9 @@ int gfs2_releasepage(struct page *page, gfp_t gfp_mask)
737 if (!atomic_read(&aspace->i_writecount)) 724 if (!atomic_read(&aspace->i_writecount))
738 return 0; 725 return 0;
739 726
727 if (!(gfp_mask & __GFP_WAIT))
728 return 0;
729
740 if (time_after_eq(jiffies, t)) { 730 if (time_after_eq(jiffies, t)) {
741 stuck_releasepage(bh); 731 stuck_releasepage(bh);
742 /* should we withdraw here? */ 732 /* should we withdraw here? */
diff --git a/fs/gfs2/ops_dentry.c b/fs/gfs2/ops_dentry.c
index 00041b1b8025..d355899585d8 100644
--- a/fs/gfs2/ops_dentry.c
+++ b/fs/gfs2/ops_dentry.c
@@ -43,7 +43,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
43 struct inode *inode = dentry->d_inode; 43 struct inode *inode = dentry->d_inode;
44 struct gfs2_holder d_gh; 44 struct gfs2_holder d_gh;
45 struct gfs2_inode *ip; 45 struct gfs2_inode *ip;
46 struct gfs2_inum inum; 46 struct gfs2_inum_host inum;
47 unsigned int type; 47 unsigned int type;
48 int error; 48 int error;
49 49
@@ -76,7 +76,7 @@ static int gfs2_drevalidate(struct dentry *dentry, struct nameidata *nd)
76 if (!gfs2_inum_equal(&ip->i_num, &inum)) 76 if (!gfs2_inum_equal(&ip->i_num, &inum))
77 goto invalid_gunlock; 77 goto invalid_gunlock;
78 78
79 if (IF2DT(ip->i_di.di_mode) != type) { 79 if (IF2DT(ip->i_inode.i_mode) != type) {
80 gfs2_consist_inode(dip); 80 gfs2_consist_inode(dip);
81 goto fail_gunlock; 81 goto fail_gunlock;
82 } 82 }
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c
index 86127d93bd35..b4e7b8775315 100644
--- a/fs/gfs2/ops_export.c
+++ b/fs/gfs2/ops_export.c
@@ -27,15 +27,16 @@
27#include "util.h" 27#include "util.h"
28 28
29static struct dentry *gfs2_decode_fh(struct super_block *sb, 29static struct dentry *gfs2_decode_fh(struct super_block *sb,
30 __u32 *fh, 30 __u32 *p,
31 int fh_len, 31 int fh_len,
32 int fh_type, 32 int fh_type,
33 int (*acceptable)(void *context, 33 int (*acceptable)(void *context,
34 struct dentry *dentry), 34 struct dentry *dentry),
35 void *context) 35 void *context)
36{ 36{
37 __be32 *fh = (__force __be32 *)p;
37 struct gfs2_fh_obj fh_obj; 38 struct gfs2_fh_obj fh_obj;
38 struct gfs2_inum *this, parent; 39 struct gfs2_inum_host *this, parent;
39 40
40 if (fh_type != fh_len) 41 if (fh_type != fh_len)
41 return NULL; 42 return NULL;
@@ -65,9 +66,10 @@ static struct dentry *gfs2_decode_fh(struct super_block *sb,
65 acceptable, context); 66 acceptable, context);
66} 67}
67 68
68static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len, 69static int gfs2_encode_fh(struct dentry *dentry, __u32 *p, int *len,
69 int connectable) 70 int connectable)
70{ 71{
72 __be32 *fh = (__force __be32 *)p;
71 struct inode *inode = dentry->d_inode; 73 struct inode *inode = dentry->d_inode;
72 struct super_block *sb = inode->i_sb; 74 struct super_block *sb = inode->i_sb;
73 struct gfs2_inode *ip = GFS2_I(inode); 75 struct gfs2_inode *ip = GFS2_I(inode);
@@ -76,14 +78,10 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
76 (connectable && *len < GFS2_LARGE_FH_SIZE)) 78 (connectable && *len < GFS2_LARGE_FH_SIZE))
77 return 255; 79 return 255;
78 80
79 fh[0] = ip->i_num.no_formal_ino >> 32; 81 fh[0] = cpu_to_be32(ip->i_num.no_formal_ino >> 32);
80 fh[0] = cpu_to_be32(fh[0]); 82 fh[1] = cpu_to_be32(ip->i_num.no_formal_ino & 0xFFFFFFFF);
81 fh[1] = ip->i_num.no_formal_ino & 0xFFFFFFFF; 83 fh[2] = cpu_to_be32(ip->i_num.no_addr >> 32);
82 fh[1] = cpu_to_be32(fh[1]); 84 fh[3] = cpu_to_be32(ip->i_num.no_addr & 0xFFFFFFFF);
83 fh[2] = ip->i_num.no_addr >> 32;
84 fh[2] = cpu_to_be32(fh[2]);
85 fh[3] = ip->i_num.no_addr & 0xFFFFFFFF;
86 fh[3] = cpu_to_be32(fh[3]);
87 *len = GFS2_SMALL_FH_SIZE; 85 *len = GFS2_SMALL_FH_SIZE;
88 86
89 if (!connectable || inode == sb->s_root->d_inode) 87 if (!connectable || inode == sb->s_root->d_inode)
@@ -95,14 +93,10 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
95 igrab(inode); 93 igrab(inode);
96 spin_unlock(&dentry->d_lock); 94 spin_unlock(&dentry->d_lock);
97 95
98 fh[4] = ip->i_num.no_formal_ino >> 32; 96 fh[4] = cpu_to_be32(ip->i_num.no_formal_ino >> 32);
99 fh[4] = cpu_to_be32(fh[4]); 97 fh[5] = cpu_to_be32(ip->i_num.no_formal_ino & 0xFFFFFFFF);
100 fh[5] = ip->i_num.no_formal_ino & 0xFFFFFFFF; 98 fh[6] = cpu_to_be32(ip->i_num.no_addr >> 32);
101 fh[5] = cpu_to_be32(fh[5]); 99 fh[7] = cpu_to_be32(ip->i_num.no_addr & 0xFFFFFFFF);
102 fh[6] = ip->i_num.no_addr >> 32;
103 fh[6] = cpu_to_be32(fh[6]);
104 fh[7] = ip->i_num.no_addr & 0xFFFFFFFF;
105 fh[7] = cpu_to_be32(fh[7]);
106 100
107 fh[8] = cpu_to_be32(inode->i_mode); 101 fh[8] = cpu_to_be32(inode->i_mode);
108 fh[9] = 0; /* pad to double word */ 102 fh[9] = 0; /* pad to double word */
@@ -114,12 +108,12 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
114} 108}
115 109
116struct get_name_filldir { 110struct get_name_filldir {
117 struct gfs2_inum inum; 111 struct gfs2_inum_host inum;
118 char *name; 112 char *name;
119}; 113};
120 114
121static int get_name_filldir(void *opaque, const char *name, unsigned int length, 115static int get_name_filldir(void *opaque, const char *name, unsigned int length,
122 u64 offset, struct gfs2_inum *inum, 116 u64 offset, struct gfs2_inum_host *inum,
123 unsigned int type) 117 unsigned int type)
124{ 118{
125 struct get_name_filldir *gnfd = (struct get_name_filldir *)opaque; 119 struct get_name_filldir *gnfd = (struct get_name_filldir *)opaque;
@@ -202,7 +196,7 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb, void *inum_obj)
202{ 196{
203 struct gfs2_sbd *sdp = sb->s_fs_info; 197 struct gfs2_sbd *sdp = sb->s_fs_info;
204 struct gfs2_fh_obj *fh_obj = (struct gfs2_fh_obj *)inum_obj; 198 struct gfs2_fh_obj *fh_obj = (struct gfs2_fh_obj *)inum_obj;
205 struct gfs2_inum *inum = &fh_obj->this; 199 struct gfs2_inum_host *inum = &fh_obj->this;
206 struct gfs2_holder i_gh, ri_gh, rgd_gh; 200 struct gfs2_holder i_gh, ri_gh, rgd_gh;
207 struct gfs2_rgrpd *rgd; 201 struct gfs2_rgrpd *rgd;
208 struct inode *inode; 202 struct inode *inode;
diff --git a/fs/gfs2/ops_export.h b/fs/gfs2/ops_export.h
index 09aca5046fb1..f925a955b3b8 100644
--- a/fs/gfs2/ops_export.h
+++ b/fs/gfs2/ops_export.h
@@ -15,7 +15,7 @@
15 15
16extern struct export_operations gfs2_export_ops; 16extern struct export_operations gfs2_export_ops;
17struct gfs2_fh_obj { 17struct gfs2_fh_obj {
18 struct gfs2_inum this; 18 struct gfs2_inum_host this;
19 __u32 imode; 19 __u32 imode;
20}; 20};
21 21
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 3064f133bf3c..b3f1e0349ae0 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -22,6 +22,7 @@
22#include <linux/ext2_fs.h> 22#include <linux/ext2_fs.h>
23#include <linux/crc32.h> 23#include <linux/crc32.h>
24#include <linux/lm_interface.h> 24#include <linux/lm_interface.h>
25#include <linux/writeback.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26 27
27#include "gfs2.h" 28#include "gfs2.h"
@@ -71,7 +72,7 @@ static int gfs2_read_actor(read_descriptor_t *desc, struct page *page,
71 size = count; 72 size = count;
72 73
73 kaddr = kmap(page); 74 kaddr = kmap(page);
74 memcpy(desc->arg.buf, kaddr + offset, size); 75 memcpy(desc->arg.data, kaddr + offset, size);
75 kunmap(page); 76 kunmap(page);
76 77
77 desc->count = count - size; 78 desc->count = count - size;
@@ -86,7 +87,7 @@ int gfs2_internal_read(struct gfs2_inode *ip, struct file_ra_state *ra_state,
86 struct inode *inode = &ip->i_inode; 87 struct inode *inode = &ip->i_inode;
87 read_descriptor_t desc; 88 read_descriptor_t desc;
88 desc.written = 0; 89 desc.written = 0;
89 desc.arg.buf = buf; 90 desc.arg.data = buf;
90 desc.count = size; 91 desc.count = size;
91 desc.error = 0; 92 desc.error = 0;
92 do_generic_mapping_read(inode->i_mapping, ra_state, 93 do_generic_mapping_read(inode->i_mapping, ra_state,
@@ -139,7 +140,7 @@ static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin)
139 */ 140 */
140 141
141static int filldir_func(void *opaque, const char *name, unsigned int length, 142static int filldir_func(void *opaque, const char *name, unsigned int length,
142 u64 offset, struct gfs2_inum *inum, 143 u64 offset, struct gfs2_inum_host *inum,
143 unsigned int type) 144 unsigned int type)
144{ 145{
145 struct filldir_reg *fdr = (struct filldir_reg *)opaque; 146 struct filldir_reg *fdr = (struct filldir_reg *)opaque;
@@ -253,7 +254,7 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
253 u32 fsflags; 254 u32 fsflags;
254 255
255 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh); 256 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
256 error = gfs2_glock_nq_m_atime(1, &gh); 257 error = gfs2_glock_nq_atime(&gh);
257 if (error) 258 if (error)
258 return error; 259 return error;
259 260
@@ -266,6 +267,24 @@ static int gfs2_get_flags(struct file *filp, u32 __user *ptr)
266 return error; 267 return error;
267} 268}
268 269
270void gfs2_set_inode_flags(struct inode *inode)
271{
272 struct gfs2_inode *ip = GFS2_I(inode);
273 struct gfs2_dinode_host *di = &ip->i_di;
274 unsigned int flags = inode->i_flags;
275
276 flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
277 if (di->di_flags & GFS2_DIF_IMMUTABLE)
278 flags |= S_IMMUTABLE;
279 if (di->di_flags & GFS2_DIF_APPENDONLY)
280 flags |= S_APPEND;
281 if (di->di_flags & GFS2_DIF_NOATIME)
282 flags |= S_NOATIME;
283 if (di->di_flags & GFS2_DIF_SYNC)
284 flags |= S_SYNC;
285 inode->i_flags = flags;
286}
287
269/* Flags that can be set by user space */ 288/* Flags that can be set by user space */
270#define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA| \ 289#define GFS2_FLAGS_USER_SET (GFS2_DIF_JDATA| \
271 GFS2_DIF_DIRECTIO| \ 290 GFS2_DIF_DIRECTIO| \
@@ -336,8 +355,9 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
336 goto out_trans_end; 355 goto out_trans_end;
337 gfs2_trans_add_bh(ip->i_gl, bh, 1); 356 gfs2_trans_add_bh(ip->i_gl, bh, 1);
338 ip->i_di.di_flags = new_flags; 357 ip->i_di.di_flags = new_flags;
339 gfs2_dinode_out(&ip->i_di, bh->b_data); 358 gfs2_dinode_out(ip, bh->b_data);
340 brelse(bh); 359 brelse(bh);
360 gfs2_set_inode_flags(inode);
341out_trans_end: 361out_trans_end:
342 gfs2_trans_end(sdp); 362 gfs2_trans_end(sdp);
343out: 363out:
@@ -425,7 +445,7 @@ static int gfs2_open(struct inode *inode, struct file *file)
425 gfs2_assert_warn(GFS2_SB(inode), !file->private_data); 445 gfs2_assert_warn(GFS2_SB(inode), !file->private_data);
426 file->private_data = fp; 446 file->private_data = fp;
427 447
428 if (S_ISREG(ip->i_di.di_mode)) { 448 if (S_ISREG(ip->i_inode.i_mode)) {
429 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, 449 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
430 &i_gh); 450 &i_gh);
431 if (error) 451 if (error)
@@ -484,16 +504,40 @@ static int gfs2_close(struct inode *inode, struct file *file)
484 * @file: the file that points to the dentry (we ignore this) 504 * @file: the file that points to the dentry (we ignore this)
485 * @dentry: the dentry that points to the inode to sync 505 * @dentry: the dentry that points to the inode to sync
486 * 506 *
507 * The VFS will flush "normal" data for us. We only need to worry
508 * about metadata here. For journaled data, we just do a log flush
509 * as we can't avoid it. Otherwise we can just bale out if datasync
510 * is set. For stuffed inodes we must flush the log in order to
511 * ensure that all data is on disk.
512 *
513 * The call to write_inode_now() is there to write back metadata and
514 * the inode itself. It does also try and write the data, but thats
515 * (hopefully) a no-op due to the VFS having already called filemap_fdatawrite()
516 * for us.
517 *
487 * Returns: errno 518 * Returns: errno
488 */ 519 */
489 520
490static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync) 521static int gfs2_fsync(struct file *file, struct dentry *dentry, int datasync)
491{ 522{
492 struct gfs2_inode *ip = GFS2_I(dentry->d_inode); 523 struct inode *inode = dentry->d_inode;
524 int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC);
525 int ret = 0;
493 526
494 gfs2_log_flush(ip->i_gl->gl_sbd, ip->i_gl); 527 if (gfs2_is_jdata(GFS2_I(inode))) {
528 gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
529 return 0;
530 }
495 531
496 return 0; 532 if (sync_state != 0) {
533 if (!datasync)
534 ret = write_inode_now(inode, 0);
535
536 if (gfs2_is_stuffed(GFS2_I(inode)))
537 gfs2_log_flush(GFS2_SB(inode), GFS2_I(inode)->i_gl);
538 }
539
540 return ret;
497} 541}
498 542
499/** 543/**
@@ -515,7 +559,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
515 559
516 if (!(fl->fl_flags & FL_POSIX)) 560 if (!(fl->fl_flags & FL_POSIX))
517 return -ENOLCK; 561 return -ENOLCK;
518 if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID) 562 if ((ip->i_inode.i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
519 return -ENOLCK; 563 return -ENOLCK;
520 564
521 if (sdp->sd_args.ar_localflocks) { 565 if (sdp->sd_args.ar_localflocks) {
@@ -617,7 +661,7 @@ static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl)
617 661
618 if (!(fl->fl_flags & FL_FLOCK)) 662 if (!(fl->fl_flags & FL_FLOCK))
619 return -ENOLCK; 663 return -ENOLCK;
620 if ((ip->i_di.di_mode & (S_ISGID | S_IXGRP)) == S_ISGID) 664 if ((ip->i_inode.i_mode & (S_ISGID | S_IXGRP)) == S_ISGID)
621 return -ENOLCK; 665 return -ENOLCK;
622 666
623 if (sdp->sd_args.ar_localflocks) 667 if (sdp->sd_args.ar_localflocks)
diff --git a/fs/gfs2/ops_file.h b/fs/gfs2/ops_file.h
index ce319f89ec8e..7e5d8ec9c846 100644
--- a/fs/gfs2/ops_file.h
+++ b/fs/gfs2/ops_file.h
@@ -17,7 +17,7 @@ extern struct file gfs2_internal_file_sentinel;
17extern int gfs2_internal_read(struct gfs2_inode *ip, 17extern int gfs2_internal_read(struct gfs2_inode *ip,
18 struct file_ra_state *ra_state, 18 struct file_ra_state *ra_state,
19 char *buf, loff_t *pos, unsigned size); 19 char *buf, loff_t *pos, unsigned size);
20 20extern void gfs2_set_inode_flags(struct inode *inode);
21extern const struct file_operations gfs2_file_fops; 21extern const struct file_operations gfs2_file_fops;
22extern const struct file_operations gfs2_dir_fops; 22extern const struct file_operations gfs2_dir_fops;
23 23
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 882873a6bd69..d14e139d2674 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -237,7 +237,7 @@ fail:
237} 237}
238 238
239static struct inode *gfs2_lookup_root(struct super_block *sb, 239static struct inode *gfs2_lookup_root(struct super_block *sb,
240 struct gfs2_inum *inum) 240 struct gfs2_inum_host *inum)
241{ 241{
242 return gfs2_inode_lookup(sb, inum, DT_DIR); 242 return gfs2_inode_lookup(sb, inum, DT_DIR);
243} 243}
@@ -246,7 +246,7 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
246{ 246{
247 struct super_block *sb = sdp->sd_vfs; 247 struct super_block *sb = sdp->sd_vfs;
248 struct gfs2_holder sb_gh; 248 struct gfs2_holder sb_gh;
249 struct gfs2_inum *inum; 249 struct gfs2_inum_host *inum;
250 struct inode *inode; 250 struct inode *inode;
251 int error = 0; 251 int error = 0;
252 252
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index ef6e5ed70e94..636dda4c7d38 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -59,7 +59,7 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
59 gfs2_holder_init(dip->i_gl, 0, 0, ghs); 59 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
60 60
61 for (;;) { 61 for (;;) {
62 inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode); 62 inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode, 0);
63 if (!IS_ERR(inode)) { 63 if (!IS_ERR(inode)) {
64 gfs2_trans_end(sdp); 64 gfs2_trans_end(sdp);
65 if (dip->i_alloc.al_rgd) 65 if (dip->i_alloc.al_rgd)
@@ -144,7 +144,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
144 int alloc_required; 144 int alloc_required;
145 int error; 145 int error;
146 146
147 if (S_ISDIR(ip->i_di.di_mode)) 147 if (S_ISDIR(inode->i_mode))
148 return -EPERM; 148 return -EPERM;
149 149
150 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); 150 gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
@@ -169,7 +169,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
169 } 169 }
170 170
171 error = -EINVAL; 171 error = -EINVAL;
172 if (!dip->i_di.di_nlink) 172 if (!dip->i_inode.i_nlink)
173 goto out_gunlock; 173 goto out_gunlock;
174 error = -EFBIG; 174 error = -EFBIG;
175 if (dip->i_di.di_entries == (u32)-1) 175 if (dip->i_di.di_entries == (u32)-1)
@@ -178,10 +178,10 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
178 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 178 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
179 goto out_gunlock; 179 goto out_gunlock;
180 error = -EINVAL; 180 error = -EINVAL;
181 if (!ip->i_di.di_nlink) 181 if (!ip->i_inode.i_nlink)
182 goto out_gunlock; 182 goto out_gunlock;
183 error = -EMLINK; 183 error = -EMLINK;
184 if (ip->i_di.di_nlink == (u32)-1) 184 if (ip->i_inode.i_nlink == (u32)-1)
185 goto out_gunlock; 185 goto out_gunlock;
186 186
187 alloc_required = error = gfs2_diradd_alloc_required(dir, &dentry->d_name); 187 alloc_required = error = gfs2_diradd_alloc_required(dir, &dentry->d_name);
@@ -196,8 +196,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
196 if (error) 196 if (error)
197 goto out_alloc; 197 goto out_alloc;
198 198
199 error = gfs2_quota_check(dip, dip->i_di.di_uid, 199 error = gfs2_quota_check(dip, dip->i_inode.i_uid, dip->i_inode.i_gid);
200 dip->i_di.di_gid);
201 if (error) 200 if (error)
202 goto out_gunlock_q; 201 goto out_gunlock_q;
203 202
@@ -220,7 +219,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
220 } 219 }
221 220
222 error = gfs2_dir_add(dir, &dentry->d_name, &ip->i_num, 221 error = gfs2_dir_add(dir, &dentry->d_name, &ip->i_num,
223 IF2DT(ip->i_di.di_mode)); 222 IF2DT(inode->i_mode));
224 if (error) 223 if (error)
225 goto out_end_trans; 224 goto out_end_trans;
226 225
@@ -326,7 +325,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
326 325
327 gfs2_holder_init(dip->i_gl, 0, 0, ghs); 326 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
328 327
329 inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO); 328 inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO, 0);
330 if (IS_ERR(inode)) { 329 if (IS_ERR(inode)) {
331 gfs2_holder_uninit(ghs); 330 gfs2_holder_uninit(ghs);
332 return PTR_ERR(inode); 331 return PTR_ERR(inode);
@@ -339,7 +338,7 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
339 error = gfs2_meta_inode_buffer(ip, &dibh); 338 error = gfs2_meta_inode_buffer(ip, &dibh);
340 339
341 if (!gfs2_assert_withdraw(sdp, !error)) { 340 if (!gfs2_assert_withdraw(sdp, !error)) {
342 gfs2_dinode_out(&ip->i_di, dibh->b_data); 341 gfs2_dinode_out(ip, dibh->b_data);
343 memcpy(dibh->b_data + sizeof(struct gfs2_dinode), symname, 342 memcpy(dibh->b_data + sizeof(struct gfs2_dinode), symname,
344 size); 343 size);
345 brelse(dibh); 344 brelse(dibh);
@@ -379,7 +378,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
379 378
380 gfs2_holder_init(dip->i_gl, 0, 0, ghs); 379 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
381 380
382 inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode); 381 inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode, 0);
383 if (IS_ERR(inode)) { 382 if (IS_ERR(inode)) {
384 gfs2_holder_uninit(ghs); 383 gfs2_holder_uninit(ghs);
385 return PTR_ERR(inode); 384 return PTR_ERR(inode);
@@ -387,10 +386,9 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
387 386
388 ip = ghs[1].gh_gl->gl_object; 387 ip = ghs[1].gh_gl->gl_object;
389 388
390 ip->i_di.di_nlink = 2; 389 ip->i_inode.i_nlink = 2;
391 ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode); 390 ip->i_di.di_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
392 ip->i_di.di_flags |= GFS2_DIF_JDATA; 391 ip->i_di.di_flags |= GFS2_DIF_JDATA;
393 ip->i_di.di_payload_format = GFS2_FORMAT_DE;
394 ip->i_di.di_entries = 2; 392 ip->i_di.di_entries = 2;
395 393
396 error = gfs2_meta_inode_buffer(ip, &dibh); 394 error = gfs2_meta_inode_buffer(ip, &dibh);
@@ -414,7 +412,7 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
414 gfs2_inum_out(&dip->i_num, &dent->de_inum); 412 gfs2_inum_out(&dip->i_num, &dent->de_inum);
415 dent->de_type = cpu_to_be16(DT_DIR); 413 dent->de_type = cpu_to_be16(DT_DIR);
416 414
417 gfs2_dinode_out(&ip->i_di, di); 415 gfs2_dinode_out(ip, di);
418 416
419 brelse(dibh); 417 brelse(dibh);
420 } 418 }
@@ -467,7 +465,7 @@ static int gfs2_rmdir(struct inode *dir, struct dentry *dentry)
467 465
468 if (ip->i_di.di_entries < 2) { 466 if (ip->i_di.di_entries < 2) {
469 if (gfs2_consist_inode(ip)) 467 if (gfs2_consist_inode(ip))
470 gfs2_dinode_print(&ip->i_di); 468 gfs2_dinode_print(ip);
471 error = -EIO; 469 error = -EIO;
472 goto out_gunlock; 470 goto out_gunlock;
473 } 471 }
@@ -504,47 +502,19 @@ out:
504static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode, 502static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
505 dev_t dev) 503 dev_t dev)
506{ 504{
507 struct gfs2_inode *dip = GFS2_I(dir), *ip; 505 struct gfs2_inode *dip = GFS2_I(dir);
508 struct gfs2_sbd *sdp = GFS2_SB(dir); 506 struct gfs2_sbd *sdp = GFS2_SB(dir);
509 struct gfs2_holder ghs[2]; 507 struct gfs2_holder ghs[2];
510 struct inode *inode; 508 struct inode *inode;
511 struct buffer_head *dibh;
512 u32 major = 0, minor = 0;
513 int error;
514
515 switch (mode & S_IFMT) {
516 case S_IFBLK:
517 case S_IFCHR:
518 major = MAJOR(dev);
519 minor = MINOR(dev);
520 break;
521 case S_IFIFO:
522 case S_IFSOCK:
523 break;
524 default:
525 return -EOPNOTSUPP;
526 };
527 509
528 gfs2_holder_init(dip->i_gl, 0, 0, ghs); 510 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
529 511
530 inode = gfs2_createi(ghs, &dentry->d_name, mode); 512 inode = gfs2_createi(ghs, &dentry->d_name, mode, dev);
531 if (IS_ERR(inode)) { 513 if (IS_ERR(inode)) {
532 gfs2_holder_uninit(ghs); 514 gfs2_holder_uninit(ghs);
533 return PTR_ERR(inode); 515 return PTR_ERR(inode);
534 } 516 }
535 517
536 ip = ghs[1].gh_gl->gl_object;
537
538 ip->i_di.di_major = major;
539 ip->i_di.di_minor = minor;
540
541 error = gfs2_meta_inode_buffer(ip, &dibh);
542
543 if (!gfs2_assert_withdraw(sdp, !error)) {
544 gfs2_dinode_out(&ip->i_di, dibh->b_data);
545 brelse(dibh);
546 }
547
548 gfs2_trans_end(sdp); 518 gfs2_trans_end(sdp);
549 if (dip->i_alloc.al_rgd) 519 if (dip->i_alloc.al_rgd)
550 gfs2_inplace_release(dip); 520 gfs2_inplace_release(dip);
@@ -592,11 +562,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
592 562
593 /* Make sure we aren't trying to move a dirctory into it's subdir */ 563 /* Make sure we aren't trying to move a dirctory into it's subdir */
594 564
595 if (S_ISDIR(ip->i_di.di_mode) && odip != ndip) { 565 if (S_ISDIR(ip->i_inode.i_mode) && odip != ndip) {
596 dir_rename = 1; 566 dir_rename = 1;
597 567
598 error = gfs2_glock_nq_init(sdp->sd_rename_gl, 568 error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE, 0,
599 LM_ST_EXCLUSIVE, 0,
600 &r_gh); 569 &r_gh);
601 if (error) 570 if (error)
602 goto out; 571 goto out;
@@ -637,10 +606,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
637 if (error) 606 if (error)
638 goto out_gunlock; 607 goto out_gunlock;
639 608
640 if (S_ISDIR(nip->i_di.di_mode)) { 609 if (S_ISDIR(nip->i_inode.i_mode)) {
641 if (nip->i_di.di_entries < 2) { 610 if (nip->i_di.di_entries < 2) {
642 if (gfs2_consist_inode(nip)) 611 if (gfs2_consist_inode(nip))
643 gfs2_dinode_print(&nip->i_di); 612 gfs2_dinode_print(nip);
644 error = -EIO; 613 error = -EIO;
645 goto out_gunlock; 614 goto out_gunlock;
646 } 615 }
@@ -666,7 +635,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
666 }; 635 };
667 636
668 if (odip != ndip) { 637 if (odip != ndip) {
669 if (!ndip->i_di.di_nlink) { 638 if (!ndip->i_inode.i_nlink) {
670 error = -EINVAL; 639 error = -EINVAL;
671 goto out_gunlock; 640 goto out_gunlock;
672 } 641 }
@@ -674,8 +643,8 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
674 error = -EFBIG; 643 error = -EFBIG;
675 goto out_gunlock; 644 goto out_gunlock;
676 } 645 }
677 if (S_ISDIR(ip->i_di.di_mode) && 646 if (S_ISDIR(ip->i_inode.i_mode) &&
678 ndip->i_di.di_nlink == (u32)-1) { 647 ndip->i_inode.i_nlink == (u32)-1) {
679 error = -EMLINK; 648 error = -EMLINK;
680 goto out_gunlock; 649 goto out_gunlock;
681 } 650 }
@@ -702,8 +671,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
702 if (error) 671 if (error)
703 goto out_alloc; 672 goto out_alloc;
704 673
705 error = gfs2_quota_check(ndip, ndip->i_di.di_uid, 674 error = gfs2_quota_check(ndip, ndip->i_inode.i_uid, ndip->i_inode.i_gid);
706 ndip->i_di.di_gid);
707 if (error) 675 if (error)
708 goto out_gunlock_q; 676 goto out_gunlock_q;
709 677
@@ -729,7 +697,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
729 /* Remove the target file, if it exists */ 697 /* Remove the target file, if it exists */
730 698
731 if (nip) { 699 if (nip) {
732 if (S_ISDIR(nip->i_di.di_mode)) 700 if (S_ISDIR(nip->i_inode.i_mode))
733 error = gfs2_rmdiri(ndip, &ndentry->d_name, nip); 701 error = gfs2_rmdiri(ndip, &ndentry->d_name, nip);
734 else { 702 else {
735 error = gfs2_dir_del(ndip, &ndentry->d_name); 703 error = gfs2_dir_del(ndip, &ndentry->d_name);
@@ -760,9 +728,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
760 error = gfs2_meta_inode_buffer(ip, &dibh); 728 error = gfs2_meta_inode_buffer(ip, &dibh);
761 if (error) 729 if (error)
762 goto out_end_trans; 730 goto out_end_trans;
763 ip->i_di.di_ctime = get_seconds(); 731 ip->i_inode.i_ctime.tv_sec = get_seconds();
764 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 732 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
765 gfs2_dinode_out(&ip->i_di, dibh->b_data); 733 gfs2_dinode_out(ip, dibh->b_data);
766 brelse(dibh); 734 brelse(dibh);
767 } 735 }
768 736
@@ -771,7 +739,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
771 goto out_end_trans; 739 goto out_end_trans;
772 740
773 error = gfs2_dir_add(ndir, &ndentry->d_name, &ip->i_num, 741 error = gfs2_dir_add(ndir, &ndentry->d_name, &ip->i_num,
774 IF2DT(ip->i_di.di_mode)); 742 IF2DT(ip->i_inode.i_mode));
775 if (error) 743 if (error)
776 goto out_end_trans; 744 goto out_end_trans;
777 745
@@ -867,6 +835,10 @@ static void *gfs2_follow_link(struct dentry *dentry, struct nameidata *nd)
867 * @mask: 835 * @mask:
868 * @nd: passed from Linux VFS, ignored by us 836 * @nd: passed from Linux VFS, ignored by us
869 * 837 *
838 * This may be called from the VFS directly, or from within GFS2 with the
839 * inode locked, so we look to see if the glock is already locked and only
840 * lock the glock if its not already been done.
841 *
870 * Returns: errno 842 * Returns: errno
871 */ 843 */
872 844
@@ -875,15 +847,18 @@ static int gfs2_permission(struct inode *inode, int mask, struct nameidata *nd)
875 struct gfs2_inode *ip = GFS2_I(inode); 847 struct gfs2_inode *ip = GFS2_I(inode);
876 struct gfs2_holder i_gh; 848 struct gfs2_holder i_gh;
877 int error; 849 int error;
850 int unlock = 0;
878 851
879 if (ip->i_vn == ip->i_gl->gl_vn) 852 if (gfs2_glock_is_locked_by_me(ip->i_gl) == 0) {
880 return generic_permission(inode, mask, gfs2_check_acl); 853 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
854 if (error)
855 return error;
856 unlock = 1;
857 }
881 858
882 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); 859 error = generic_permission(inode, mask, gfs2_check_acl);
883 if (!error) { 860 if (unlock)
884 error = generic_permission(inode, mask, gfs2_check_acl_locked);
885 gfs2_glock_dq_uninit(&i_gh); 861 gfs2_glock_dq_uninit(&i_gh);
886 }
887 862
888 return error; 863 return error;
889} 864}
@@ -914,8 +889,8 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
914 u32 ouid, ogid, nuid, ngid; 889 u32 ouid, ogid, nuid, ngid;
915 int error; 890 int error;
916 891
917 ouid = ip->i_di.di_uid; 892 ouid = inode->i_uid;
918 ogid = ip->i_di.di_gid; 893 ogid = inode->i_gid;
919 nuid = attr->ia_uid; 894 nuid = attr->ia_uid;
920 ngid = attr->ia_gid; 895 ngid = attr->ia_gid;
921 896
@@ -946,10 +921,9 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
946 921
947 error = inode_setattr(inode, attr); 922 error = inode_setattr(inode, attr);
948 gfs2_assert_warn(sdp, !error); 923 gfs2_assert_warn(sdp, !error);
949 gfs2_inode_attr_out(ip);
950 924
951 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 925 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
952 gfs2_dinode_out(&ip->i_di, dibh->b_data); 926 gfs2_dinode_out(ip, dibh->b_data);
953 brelse(dibh); 927 brelse(dibh);
954 928
955 if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) { 929 if (ouid != NO_QUOTA_CHANGE || ogid != NO_QUOTA_CHANGE) {
@@ -1018,6 +992,12 @@ out:
1018 * @dentry: The dentry to stat 992 * @dentry: The dentry to stat
1019 * @stat: The inode's stats 993 * @stat: The inode's stats
1020 * 994 *
995 * This may be called from the VFS directly, or from within GFS2 with the
996 * inode locked, so we look to see if the glock is already locked and only
997 * lock the glock if its not already been done. Note that its the NFS
998 * readdirplus operation which causes this to be called (from filldir)
999 * with the glock already held.
1000 *
1021 * Returns: errno 1001 * Returns: errno
1022 */ 1002 */
1023 1003
@@ -1028,14 +1008,20 @@ static int gfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
1028 struct gfs2_inode *ip = GFS2_I(inode); 1008 struct gfs2_inode *ip = GFS2_I(inode);
1029 struct gfs2_holder gh; 1009 struct gfs2_holder gh;
1030 int error; 1010 int error;
1011 int unlock = 0;
1031 1012
1032 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh); 1013 if (gfs2_glock_is_locked_by_me(ip->i_gl) == 0) {
1033 if (!error) { 1014 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &gh);
1034 generic_fillattr(inode, stat); 1015 if (error)
1035 gfs2_glock_dq_uninit(&gh); 1016 return error;
1017 unlock = 1;
1036 } 1018 }
1037 1019
1038 return error; 1020 generic_fillattr(inode, stat);
1021 if (unlock);
1022 gfs2_glock_dq_uninit(&gh);
1023
1024 return 0;
1039} 1025}
1040 1026
1041static int gfs2_setxattr(struct dentry *dentry, const char *name, 1027static int gfs2_setxattr(struct dentry *dentry, const char *name,
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c
index b47d9598c047..7685b46f934b 100644
--- a/fs/gfs2/ops_super.c
+++ b/fs/gfs2/ops_super.c
@@ -157,7 +157,8 @@ static void gfs2_write_super(struct super_block *sb)
157static int gfs2_sync_fs(struct super_block *sb, int wait) 157static int gfs2_sync_fs(struct super_block *sb, int wait)
158{ 158{
159 sb->s_dirt = 0; 159 sb->s_dirt = 0;
160 gfs2_log_flush(sb->s_fs_info, NULL); 160 if (wait)
161 gfs2_log_flush(sb->s_fs_info, NULL);
161 return 0; 162 return 0;
162} 163}
163 164
@@ -215,7 +216,7 @@ static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
215{ 216{
216 struct super_block *sb = dentry->d_inode->i_sb; 217 struct super_block *sb = dentry->d_inode->i_sb;
217 struct gfs2_sbd *sdp = sb->s_fs_info; 218 struct gfs2_sbd *sdp = sb->s_fs_info;
218 struct gfs2_statfs_change sc; 219 struct gfs2_statfs_change_host sc;
219 int error; 220 int error;
220 221
221 if (gfs2_tune_get(sdp, gt_statfs_slow)) 222 if (gfs2_tune_get(sdp, gt_statfs_slow))
@@ -293,8 +294,6 @@ static void gfs2_clear_inode(struct inode *inode)
293 */ 294 */
294 if (inode->i_private) { 295 if (inode->i_private) {
295 struct gfs2_inode *ip = GFS2_I(inode); 296 struct gfs2_inode *ip = GFS2_I(inode);
296 gfs2_glock_inode_squish(inode);
297 gfs2_assert(inode->i_sb->s_fs_info, ip->i_gl->gl_state == LM_ST_UNLOCKED);
298 ip->i_gl->gl_object = NULL; 297 ip->i_gl->gl_object = NULL;
299 gfs2_glock_schedule_for_reclaim(ip->i_gl); 298 gfs2_glock_schedule_for_reclaim(ip->i_gl);
300 gfs2_glock_put(ip->i_gl); 299 gfs2_glock_put(ip->i_gl);
@@ -395,7 +394,7 @@ static void gfs2_delete_inode(struct inode *inode)
395 if (!inode->i_private) 394 if (!inode->i_private)
396 goto out; 395 goto out;
397 396
398 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &gh); 397 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB, &gh);
399 if (unlikely(error)) { 398 if (unlikely(error)) {
400 gfs2_glock_dq_uninit(&ip->i_iopen_gh); 399 gfs2_glock_dq_uninit(&ip->i_iopen_gh);
401 goto out; 400 goto out;
@@ -407,7 +406,7 @@ static void gfs2_delete_inode(struct inode *inode)
407 if (error) 406 if (error)
408 goto out_uninit; 407 goto out_uninit;
409 408
410 if (S_ISDIR(ip->i_di.di_mode) && 409 if (S_ISDIR(inode->i_mode) &&
411 (ip->i_di.di_flags & GFS2_DIF_EXHASH)) { 410 (ip->i_di.di_flags & GFS2_DIF_EXHASH)) {
412 error = gfs2_dir_exhash_dealloc(ip); 411 error = gfs2_dir_exhash_dealloc(ip);
413 if (error) 412 if (error)
diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c
index 5453d2947ab3..45a5f11fc39a 100644
--- a/fs/gfs2/ops_vm.c
+++ b/fs/gfs2/ops_vm.c
@@ -76,7 +76,7 @@ static int alloc_page_backing(struct gfs2_inode *ip, struct page *page)
76 if (error) 76 if (error)
77 goto out; 77 goto out;
78 78
79 error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid); 79 error = gfs2_quota_check(ip, ip->i_inode.i_uid, ip->i_inode.i_gid);
80 if (error) 80 if (error)
81 goto out_gunlock_q; 81 goto out_gunlock_q;
82 82
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index a3deae7416c9..d0db881b55d2 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -452,19 +452,19 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
452 if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF) 452 if (sdp->sd_args.ar_quota == GFS2_QUOTA_OFF)
453 return 0; 453 return 0;
454 454
455 error = qdsb_get(sdp, QUOTA_USER, ip->i_di.di_uid, CREATE, qd); 455 error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, CREATE, qd);
456 if (error) 456 if (error)
457 goto out; 457 goto out;
458 al->al_qd_num++; 458 al->al_qd_num++;
459 qd++; 459 qd++;
460 460
461 error = qdsb_get(sdp, QUOTA_GROUP, ip->i_di.di_gid, CREATE, qd); 461 error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, CREATE, qd);
462 if (error) 462 if (error)
463 goto out; 463 goto out;
464 al->al_qd_num++; 464 al->al_qd_num++;
465 qd++; 465 qd++;
466 466
467 if (uid != NO_QUOTA_CHANGE && uid != ip->i_di.di_uid) { 467 if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) {
468 error = qdsb_get(sdp, QUOTA_USER, uid, CREATE, qd); 468 error = qdsb_get(sdp, QUOTA_USER, uid, CREATE, qd);
469 if (error) 469 if (error)
470 goto out; 470 goto out;
@@ -472,7 +472,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
472 qd++; 472 qd++;
473 } 473 }
474 474
475 if (gid != NO_QUOTA_CHANGE && gid != ip->i_di.di_gid) { 475 if (gid != NO_QUOTA_CHANGE && gid != ip->i_inode.i_gid) {
476 error = qdsb_get(sdp, QUOTA_GROUP, gid, CREATE, qd); 476 error = qdsb_get(sdp, QUOTA_GROUP, gid, CREATE, qd);
477 if (error) 477 if (error)
478 goto out; 478 goto out;
@@ -539,8 +539,7 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)
539 qc->qc_id = cpu_to_be32(qd->qd_id); 539 qc->qc_id = cpu_to_be32(qd->qd_id);
540 } 540 }
541 541
542 x = qc->qc_change; 542 x = be64_to_cpu(qc->qc_change) + change;
543 x = be64_to_cpu(x) + change;
544 qc->qc_change = cpu_to_be64(x); 543 qc->qc_change = cpu_to_be64(x);
545 544
546 spin_lock(&sdp->sd_quota_spin); 545 spin_lock(&sdp->sd_quota_spin);
@@ -743,7 +742,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,
743 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; 742 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
744 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode); 743 struct gfs2_inode *ip = GFS2_I(sdp->sd_quota_inode);
745 struct gfs2_holder i_gh; 744 struct gfs2_holder i_gh;
746 struct gfs2_quota q; 745 struct gfs2_quota_host q;
747 char buf[sizeof(struct gfs2_quota)]; 746 char buf[sizeof(struct gfs2_quota)];
748 struct file_ra_state ra_state; 747 struct file_ra_state ra_state;
749 int error; 748 int error;
@@ -1103,7 +1102,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
1103 1102
1104 for (y = 0; y < sdp->sd_qc_per_block && slot < sdp->sd_quota_slots; 1103 for (y = 0; y < sdp->sd_qc_per_block && slot < sdp->sd_quota_slots;
1105 y++, slot++) { 1104 y++, slot++) {
1106 struct gfs2_quota_change qc; 1105 struct gfs2_quota_change_host qc;
1107 struct gfs2_quota_data *qd; 1106 struct gfs2_quota_data *qd;
1108 1107
1109 gfs2_quota_change_in(&qc, bh->b_data + 1108 gfs2_quota_change_in(&qc, bh->b_data +
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 62cd223819b7..d0c806b85c86 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -132,10 +132,11 @@ void gfs2_revoke_clean(struct gfs2_sbd *sdp)
132 */ 132 */
133 133
134static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk, 134static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
135 struct gfs2_log_header *head) 135 struct gfs2_log_header_host *head)
136{ 136{
137 struct buffer_head *bh; 137 struct buffer_head *bh;
138 struct gfs2_log_header lh; 138 struct gfs2_log_header_host lh;
139 const u32 nothing = 0;
139 u32 hash; 140 u32 hash;
140 int error; 141 int error;
141 142
@@ -143,11 +144,11 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
143 if (error) 144 if (error)
144 return error; 145 return error;
145 146
146 memcpy(&lh, bh->b_data, sizeof(struct gfs2_log_header)); 147 hash = crc32_le((u32)~0, bh->b_data, sizeof(struct gfs2_log_header) -
147 lh.lh_hash = 0; 148 sizeof(u32));
148 hash = gfs2_disk_hash((char *)&lh, sizeof(struct gfs2_log_header)); 149 hash = crc32_le(hash, (unsigned char const *)&nothing, sizeof(nothing));
150 hash ^= (u32)~0;
149 gfs2_log_header_in(&lh, bh->b_data); 151 gfs2_log_header_in(&lh, bh->b_data);
150
151 brelse(bh); 152 brelse(bh);
152 153
153 if (lh.lh_header.mh_magic != GFS2_MAGIC || 154 if (lh.lh_header.mh_magic != GFS2_MAGIC ||
@@ -174,7 +175,7 @@ static int get_log_header(struct gfs2_jdesc *jd, unsigned int blk,
174 */ 175 */
175 176
176static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk, 177static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk,
177 struct gfs2_log_header *head) 178 struct gfs2_log_header_host *head)
178{ 179{
179 unsigned int orig_blk = *blk; 180 unsigned int orig_blk = *blk;
180 int error; 181 int error;
@@ -205,10 +206,10 @@ static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk,
205 * Returns: errno 206 * Returns: errno
206 */ 207 */
207 208
208static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head) 209static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
209{ 210{
210 unsigned int blk = head->lh_blkno; 211 unsigned int blk = head->lh_blkno;
211 struct gfs2_log_header lh; 212 struct gfs2_log_header_host lh;
212 int error; 213 int error;
213 214
214 for (;;) { 215 for (;;) {
@@ -245,9 +246,9 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
245 * Returns: errno 246 * Returns: errno
246 */ 247 */
247 248
248int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head) 249int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
249{ 250{
250 struct gfs2_log_header lh_1, lh_m; 251 struct gfs2_log_header_host lh_1, lh_m;
251 u32 blk_1, blk_2, blk_m; 252 u32 blk_1, blk_2, blk_m;
252 int error; 253 int error;
253 254
@@ -320,7 +321,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
320 length = be32_to_cpu(ld->ld_length); 321 length = be32_to_cpu(ld->ld_length);
321 322
322 if (be32_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) { 323 if (be32_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) {
323 struct gfs2_log_header lh; 324 struct gfs2_log_header_host lh;
324 error = get_log_header(jd, start, &lh); 325 error = get_log_header(jd, start, &lh);
325 if (!error) { 326 if (!error) {
326 gfs2_replay_incr_blk(sdp, &start); 327 gfs2_replay_incr_blk(sdp, &start);
@@ -363,7 +364,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
363 * Returns: errno 364 * Returns: errno
364 */ 365 */
365 366
366static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) 367static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head)
367{ 368{
368 struct gfs2_inode *ip = GFS2_I(jd->jd_inode); 369 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
369 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); 370 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
@@ -425,7 +426,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd)
425{ 426{
426 struct gfs2_inode *ip = GFS2_I(jd->jd_inode); 427 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
427 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); 428 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
428 struct gfs2_log_header head; 429 struct gfs2_log_header_host head;
429 struct gfs2_holder j_gh, ji_gh, t_gh; 430 struct gfs2_holder j_gh, ji_gh, t_gh;
430 unsigned long t; 431 unsigned long t;
431 int ro = 0; 432 int ro = 0;
diff --git a/fs/gfs2/recovery.h b/fs/gfs2/recovery.h
index 961feedf4d8b..f7235e61c723 100644
--- a/fs/gfs2/recovery.h
+++ b/fs/gfs2/recovery.h
@@ -26,7 +26,7 @@ int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where);
26void gfs2_revoke_clean(struct gfs2_sbd *sdp); 26void gfs2_revoke_clean(struct gfs2_sbd *sdp);
27 27
28int gfs2_find_jhead(struct gfs2_jdesc *jd, 28int gfs2_find_jhead(struct gfs2_jdesc *jd,
29 struct gfs2_log_header *head); 29 struct gfs2_log_header_host *head);
30int gfs2_recover_journal(struct gfs2_jdesc *gfs2_jd); 30int gfs2_recover_journal(struct gfs2_jdesc *gfs2_jd);
31void gfs2_check_journals(struct gfs2_sbd *sdp); 31void gfs2_check_journals(struct gfs2_sbd *sdp);
32 32
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index b261385c0065..ff0846528d54 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -253,7 +253,7 @@ void gfs2_rgrp_verify(struct gfs2_rgrpd *rgd)
253 253
254} 254}
255 255
256static inline int rgrp_contains_block(struct gfs2_rindex *ri, u64 block) 256static inline int rgrp_contains_block(struct gfs2_rindex_host *ri, u64 block)
257{ 257{
258 u64 first = ri->ri_data0; 258 u64 first = ri->ri_data0;
259 u64 last = first + ri->ri_data; 259 u64 last = first + ri->ri_data;
@@ -1217,7 +1217,7 @@ u64 gfs2_alloc_data(struct gfs2_inode *ip)
1217 al->al_alloced++; 1217 al->al_alloced++;
1218 1218
1219 gfs2_statfs_change(sdp, 0, -1, 0); 1219 gfs2_statfs_change(sdp, 0, -1, 0);
1220 gfs2_quota_change(ip, +1, ip->i_di.di_uid, ip->i_di.di_gid); 1220 gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
1221 1221
1222 spin_lock(&sdp->sd_rindex_spin); 1222 spin_lock(&sdp->sd_rindex_spin);
1223 rgd->rd_free_clone--; 1223 rgd->rd_free_clone--;
@@ -1261,7 +1261,7 @@ u64 gfs2_alloc_meta(struct gfs2_inode *ip)
1261 al->al_alloced++; 1261 al->al_alloced++;
1262 1262
1263 gfs2_statfs_change(sdp, 0, -1, 0); 1263 gfs2_statfs_change(sdp, 0, -1, 0);
1264 gfs2_quota_change(ip, +1, ip->i_di.di_uid, ip->i_di.di_gid); 1264 gfs2_quota_change(ip, +1, ip->i_inode.i_uid, ip->i_inode.i_gid);
1265 gfs2_trans_add_unrevoke(sdp, block); 1265 gfs2_trans_add_unrevoke(sdp, block);
1266 1266
1267 spin_lock(&sdp->sd_rindex_spin); 1267 spin_lock(&sdp->sd_rindex_spin);
@@ -1337,8 +1337,7 @@ void gfs2_free_data(struct gfs2_inode *ip, u64 bstart, u32 blen)
1337 gfs2_trans_add_rg(rgd); 1337 gfs2_trans_add_rg(rgd);
1338 1338
1339 gfs2_statfs_change(sdp, 0, +blen, 0); 1339 gfs2_statfs_change(sdp, 0, +blen, 0);
1340 gfs2_quota_change(ip, -(s64)blen, 1340 gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
1341 ip->i_di.di_uid, ip->i_di.di_gid);
1342} 1341}
1343 1342
1344/** 1343/**
@@ -1366,7 +1365,7 @@ void gfs2_free_meta(struct gfs2_inode *ip, u64 bstart, u32 blen)
1366 gfs2_trans_add_rg(rgd); 1365 gfs2_trans_add_rg(rgd);
1367 1366
1368 gfs2_statfs_change(sdp, 0, +blen, 0); 1367 gfs2_statfs_change(sdp, 0, +blen, 0);
1369 gfs2_quota_change(ip, -(s64)blen, ip->i_di.di_uid, ip->i_di.di_gid); 1368 gfs2_quota_change(ip, -(s64)blen, ip->i_inode.i_uid, ip->i_inode.i_gid);
1370 gfs2_meta_wipe(ip, bstart, blen); 1369 gfs2_meta_wipe(ip, bstart, blen);
1371} 1370}
1372 1371
@@ -1411,7 +1410,7 @@ static void gfs2_free_uninit_di(struct gfs2_rgrpd *rgd, u64 blkno)
1411void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip) 1410void gfs2_free_di(struct gfs2_rgrpd *rgd, struct gfs2_inode *ip)
1412{ 1411{
1413 gfs2_free_uninit_di(rgd, ip->i_num.no_addr); 1412 gfs2_free_uninit_di(rgd, ip->i_num.no_addr);
1414 gfs2_quota_change(ip, -1, ip->i_di.di_uid, ip->i_di.di_gid); 1413 gfs2_quota_change(ip, -1, ip->i_inode.i_uid, ip->i_inode.i_gid);
1415 gfs2_meta_wipe(ip, ip->i_num.no_addr, 1); 1414 gfs2_meta_wipe(ip, ip->i_num.no_addr, 1);
1416} 1415}
1417 1416
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 6a78b1b32e25..43a24f2e5905 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -97,7 +97,7 @@ void gfs2_tune_init(struct gfs2_tune *gt)
97 * changed. 97 * changed.
98 */ 98 */
99 99
100int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent) 100int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb_host *sb, int silent)
101{ 101{
102 unsigned int x; 102 unsigned int x;
103 103
@@ -180,6 +180,24 @@ static int end_bio_io_page(struct bio *bio, unsigned int bytes_done, int error)
180 return 0; 180 return 0;
181} 181}
182 182
183/**
184 * gfs2_read_super - Read the gfs2 super block from disk
185 * @sb: The VFS super block
186 * @sector: The location of the super block
187 *
188 * This uses the bio functions to read the super block from disk
189 * because we want to be 100% sure that we never read cached data.
190 * A super block is read twice only during each GFS2 mount and is
191 * never written to by the filesystem. The first time its read no
192 * locks are held, and the only details which are looked at are those
193 * relating to the locking protocol. Once locking is up and working,
194 * the sb is read again under the lock to establish the location of
195 * the master directory (contains pointers to journals etc) and the
196 * root directory.
197 *
198 * Returns: A page containing the sb or NULL
199 */
200
183struct page *gfs2_read_super(struct super_block *sb, sector_t sector) 201struct page *gfs2_read_super(struct super_block *sb, sector_t sector)
184{ 202{
185 struct page *page; 203 struct page *page;
@@ -199,7 +217,7 @@ struct page *gfs2_read_super(struct super_block *sb, sector_t sector)
199 return NULL; 217 return NULL;
200 } 218 }
201 219
202 bio->bi_sector = sector; 220 bio->bi_sector = sector * (sb->s_blocksize >> 9);
203 bio->bi_bdev = sb->s_bdev; 221 bio->bi_bdev = sb->s_bdev;
204 bio_add_page(bio, page, PAGE_SIZE, 0); 222 bio_add_page(bio, page, PAGE_SIZE, 0);
205 223
@@ -508,7 +526,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
508 struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode); 526 struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
509 struct gfs2_glock *j_gl = ip->i_gl; 527 struct gfs2_glock *j_gl = ip->i_gl;
510 struct gfs2_holder t_gh; 528 struct gfs2_holder t_gh;
511 struct gfs2_log_header head; 529 struct gfs2_log_header_host head;
512 int error; 530 int error;
513 531
514 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, 532 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
@@ -517,7 +535,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
517 return error; 535 return error;
518 536
519 gfs2_meta_cache_flush(ip); 537 gfs2_meta_cache_flush(ip);
520 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA); 538 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
521 539
522 error = gfs2_find_jhead(sdp->sd_jdesc, &head); 540 error = gfs2_find_jhead(sdp->sd_jdesc, &head);
523 if (error) 541 if (error)
@@ -587,9 +605,9 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
587int gfs2_statfs_init(struct gfs2_sbd *sdp) 605int gfs2_statfs_init(struct gfs2_sbd *sdp)
588{ 606{
589 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); 607 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
590 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master; 608 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
591 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); 609 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
592 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; 610 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
593 struct buffer_head *m_bh, *l_bh; 611 struct buffer_head *m_bh, *l_bh;
594 struct gfs2_holder gh; 612 struct gfs2_holder gh;
595 int error; 613 int error;
@@ -634,7 +652,7 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
634 s64 dinodes) 652 s64 dinodes)
635{ 653{
636 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); 654 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
637 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; 655 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
638 struct buffer_head *l_bh; 656 struct buffer_head *l_bh;
639 int error; 657 int error;
640 658
@@ -660,8 +678,8 @@ int gfs2_statfs_sync(struct gfs2_sbd *sdp)
660{ 678{
661 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); 679 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
662 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); 680 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
663 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master; 681 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
664 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; 682 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
665 struct gfs2_holder gh; 683 struct gfs2_holder gh;
666 struct buffer_head *m_bh, *l_bh; 684 struct buffer_head *m_bh, *l_bh;
667 int error; 685 int error;
@@ -727,10 +745,10 @@ out:
727 * Returns: errno 745 * Returns: errno
728 */ 746 */
729 747
730int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc) 748int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
731{ 749{
732 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master; 750 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
733 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; 751 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
734 752
735 spin_lock(&sdp->sd_statfs_spin); 753 spin_lock(&sdp->sd_statfs_spin);
736 754
@@ -760,7 +778,7 @@ int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
760 */ 778 */
761 779
762static int statfs_slow_fill(struct gfs2_rgrpd *rgd, 780static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
763 struct gfs2_statfs_change *sc) 781 struct gfs2_statfs_change_host *sc)
764{ 782{
765 gfs2_rgrp_verify(rgd); 783 gfs2_rgrp_verify(rgd);
766 sc->sc_total += rgd->rd_ri.ri_data; 784 sc->sc_total += rgd->rd_ri.ri_data;
@@ -782,7 +800,7 @@ static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
782 * Returns: errno 800 * Returns: errno
783 */ 801 */
784 802
785int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc) 803int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
786{ 804{
787 struct gfs2_holder ri_gh; 805 struct gfs2_holder ri_gh;
788 struct gfs2_rgrpd *rgd_next; 806 struct gfs2_rgrpd *rgd_next;
@@ -792,7 +810,7 @@ int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
792 int done; 810 int done;
793 int error = 0, err; 811 int error = 0, err;
794 812
795 memset(sc, 0, sizeof(struct gfs2_statfs_change)); 813 memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
796 gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL); 814 gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
797 if (!gha) 815 if (!gha)
798 return -ENOMEM; 816 return -ENOMEM;
@@ -873,7 +891,7 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,
873 struct gfs2_jdesc *jd; 891 struct gfs2_jdesc *jd;
874 struct lfcc *lfcc; 892 struct lfcc *lfcc;
875 LIST_HEAD(list); 893 LIST_HEAD(list);
876 struct gfs2_log_header lh; 894 struct gfs2_log_header_host lh;
877 int error; 895 int error;
878 896
879 error = gfs2_jindex_hold(sdp, &ji_gh); 897 error = gfs2_jindex_hold(sdp, &ji_gh);
diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h
index 5bb443ae0f59..e590b2df11dc 100644
--- a/fs/gfs2/super.h
+++ b/fs/gfs2/super.h
@@ -14,7 +14,7 @@
14 14
15void gfs2_tune_init(struct gfs2_tune *gt); 15void gfs2_tune_init(struct gfs2_tune *gt);
16 16
17int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent); 17int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb_host *sb, int silent);
18int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent); 18int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent);
19struct page *gfs2_read_super(struct super_block *sb, sector_t sector); 19struct page *gfs2_read_super(struct super_block *sb, sector_t sector);
20 20
@@ -45,8 +45,8 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp);
45void gfs2_statfs_change(struct gfs2_sbd *sdp, 45void gfs2_statfs_change(struct gfs2_sbd *sdp,
46 s64 total, s64 free, s64 dinodes); 46 s64 total, s64 free, s64 dinodes);
47int gfs2_statfs_sync(struct gfs2_sbd *sdp); 47int gfs2_statfs_sync(struct gfs2_sbd *sdp);
48int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc); 48int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc);
49int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc); 49int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc);
50 50
51int gfs2_freeze_fs(struct gfs2_sbd *sdp); 51int gfs2_freeze_fs(struct gfs2_sbd *sdp);
52void gfs2_unfreeze_fs(struct gfs2_sbd *sdp); 52void gfs2_unfreeze_fs(struct gfs2_sbd *sdp);
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 0e0ec988f731..983eaf1e06be 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -426,9 +426,6 @@ static ssize_t name##_store(struct gfs2_sbd *sdp, const char *buf, size_t len)\
426} \ 426} \
427TUNE_ATTR_2(name, name##_store) 427TUNE_ATTR_2(name, name##_store)
428 428
429TUNE_ATTR(ilimit, 0);
430TUNE_ATTR(ilimit_tries, 0);
431TUNE_ATTR(ilimit_min, 0);
432TUNE_ATTR(demote_secs, 0); 429TUNE_ATTR(demote_secs, 0);
433TUNE_ATTR(incore_log_blocks, 0); 430TUNE_ATTR(incore_log_blocks, 0);
434TUNE_ATTR(log_flush_secs, 0); 431TUNE_ATTR(log_flush_secs, 0);
@@ -447,7 +444,6 @@ TUNE_ATTR(quota_simul_sync, 1);
447TUNE_ATTR(quota_cache_secs, 1); 444TUNE_ATTR(quota_cache_secs, 1);
448TUNE_ATTR(max_atomic_write, 1); 445TUNE_ATTR(max_atomic_write, 1);
449TUNE_ATTR(stall_secs, 1); 446TUNE_ATTR(stall_secs, 1);
450TUNE_ATTR(entries_per_readdir, 1);
451TUNE_ATTR(greedy_default, 1); 447TUNE_ATTR(greedy_default, 1);
452TUNE_ATTR(greedy_quantum, 1); 448TUNE_ATTR(greedy_quantum, 1);
453TUNE_ATTR(greedy_max, 1); 449TUNE_ATTR(greedy_max, 1);
@@ -459,9 +455,6 @@ TUNE_ATTR_DAEMON(quotad_secs, quotad_process);
459TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store); 455TUNE_ATTR_3(quota_scale, quota_scale_show, quota_scale_store);
460 456
461static struct attribute *tune_attrs[] = { 457static struct attribute *tune_attrs[] = {
462 &tune_attr_ilimit.attr,
463 &tune_attr_ilimit_tries.attr,
464 &tune_attr_ilimit_min.attr,
465 &tune_attr_demote_secs.attr, 458 &tune_attr_demote_secs.attr,
466 &tune_attr_incore_log_blocks.attr, 459 &tune_attr_incore_log_blocks.attr,
467 &tune_attr_log_flush_secs.attr, 460 &tune_attr_log_flush_secs.attr,
@@ -478,7 +471,6 @@ static struct attribute *tune_attrs[] = {
478 &tune_attr_quota_cache_secs.attr, 471 &tune_attr_quota_cache_secs.attr,
479 &tune_attr_max_atomic_write.attr, 472 &tune_attr_max_atomic_write.attr,
480 &tune_attr_stall_secs.attr, 473 &tune_attr_stall_secs.attr,
481 &tune_attr_entries_per_readdir.attr,
482 &tune_attr_greedy_default.attr, 474 &tune_attr_greedy_default.attr,
483 &tune_attr_greedy_quantum.attr, 475 &tune_attr_greedy_quantum.attr,
484 &tune_attr_greedy_max.attr, 476 &tune_attr_greedy_max.attr,
diff --git a/fs/gfs2/util.c b/fs/gfs2/util.c
index 196c604faadc..e5707a9f78c2 100644
--- a/fs/gfs2/util.c
+++ b/fs/gfs2/util.c
@@ -23,9 +23,9 @@
23#include "lm.h" 23#include "lm.h"
24#include "util.h" 24#include "util.h"
25 25
26kmem_cache_t *gfs2_glock_cachep __read_mostly; 26struct kmem_cache *gfs2_glock_cachep __read_mostly;
27kmem_cache_t *gfs2_inode_cachep __read_mostly; 27struct kmem_cache *gfs2_inode_cachep __read_mostly;
28kmem_cache_t *gfs2_bufdata_cachep __read_mostly; 28struct kmem_cache *gfs2_bufdata_cachep __read_mostly;
29 29
30void gfs2_assert_i(struct gfs2_sbd *sdp) 30void gfs2_assert_i(struct gfs2_sbd *sdp)
31{ 31{
diff --git a/fs/gfs2/util.h b/fs/gfs2/util.h
index 76a50899fe9e..28938a46cf47 100644
--- a/fs/gfs2/util.h
+++ b/fs/gfs2/util.h
@@ -83,8 +83,7 @@ static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp,
83 char *file, unsigned int line) 83 char *file, unsigned int line)
84{ 84{
85 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; 85 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
86 u32 magic = mh->mh_magic; 86 u32 magic = be32_to_cpu(mh->mh_magic);
87 magic = be32_to_cpu(magic);
88 if (unlikely(magic != GFS2_MAGIC)) 87 if (unlikely(magic != GFS2_MAGIC))
89 return gfs2_meta_check_ii(sdp, bh, "magic number", function, 88 return gfs2_meta_check_ii(sdp, bh, "magic number", function,
90 file, line); 89 file, line);
@@ -107,9 +106,8 @@ static inline int gfs2_metatype_check_i(struct gfs2_sbd *sdp,
107 char *file, unsigned int line) 106 char *file, unsigned int line)
108{ 107{
109 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; 108 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
110 u32 magic = mh->mh_magic; 109 u32 magic = be32_to_cpu(mh->mh_magic);
111 u16 t = be32_to_cpu(mh->mh_type); 110 u16 t = be32_to_cpu(mh->mh_type);
112 magic = be32_to_cpu(magic);
113 if (unlikely(magic != GFS2_MAGIC)) 111 if (unlikely(magic != GFS2_MAGIC))
114 return gfs2_meta_check_ii(sdp, bh, "magic number", function, 112 return gfs2_meta_check_ii(sdp, bh, "magic number", function,
115 file, line); 113 file, line);
@@ -146,9 +144,9 @@ int gfs2_io_error_bh_i(struct gfs2_sbd *sdp, struct buffer_head *bh,
146gfs2_io_error_bh_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__); 144gfs2_io_error_bh_i((sdp), (bh), __FUNCTION__, __FILE__, __LINE__);
147 145
148 146
149extern kmem_cache_t *gfs2_glock_cachep; 147extern struct kmem_cache *gfs2_glock_cachep;
150extern kmem_cache_t *gfs2_inode_cachep; 148extern struct kmem_cache *gfs2_inode_cachep;
151extern kmem_cache_t *gfs2_bufdata_cachep; 149extern struct kmem_cache *gfs2_bufdata_cachep;
152 150
153static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt, 151static inline unsigned int gfs2_tune_get_i(struct gfs2_tune *gt,
154 unsigned int *p) 152 unsigned int *p)
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 85b17b3fa4a0..a36987966004 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -24,7 +24,7 @@
24#include "hfs_fs.h" 24#include "hfs_fs.h"
25#include "btree.h" 25#include "btree.h"
26 26
27static kmem_cache_t *hfs_inode_cachep; 27static struct kmem_cache *hfs_inode_cachep;
28 28
29MODULE_LICENSE("GPL"); 29MODULE_LICENSE("GPL");
30 30
@@ -145,7 +145,7 @@ static struct inode *hfs_alloc_inode(struct super_block *sb)
145{ 145{
146 struct hfs_inode_info *i; 146 struct hfs_inode_info *i;
147 147
148 i = kmem_cache_alloc(hfs_inode_cachep, SLAB_KERNEL); 148 i = kmem_cache_alloc(hfs_inode_cachep, GFP_KERNEL);
149 return i ? &i->vfs_inode : NULL; 149 return i ? &i->vfs_inode : NULL;
150} 150}
151 151
@@ -430,7 +430,7 @@ static struct file_system_type hfs_fs_type = {
430 .fs_flags = FS_REQUIRES_DEV, 430 .fs_flags = FS_REQUIRES_DEV,
431}; 431};
432 432
433static void hfs_init_once(void *p, kmem_cache_t *cachep, unsigned long flags) 433static void hfs_init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
434{ 434{
435 struct hfs_inode_info *i = p; 435 struct hfs_inode_info *i = p;
436 436
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index 194eede52fa4..0f513c6bf843 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -434,13 +434,13 @@ MODULE_AUTHOR("Brad Boyer");
434MODULE_DESCRIPTION("Extended Macintosh Filesystem"); 434MODULE_DESCRIPTION("Extended Macintosh Filesystem");
435MODULE_LICENSE("GPL"); 435MODULE_LICENSE("GPL");
436 436
437static kmem_cache_t *hfsplus_inode_cachep; 437static struct kmem_cache *hfsplus_inode_cachep;
438 438
439static struct inode *hfsplus_alloc_inode(struct super_block *sb) 439static struct inode *hfsplus_alloc_inode(struct super_block *sb)
440{ 440{
441 struct hfsplus_inode_info *i; 441 struct hfsplus_inode_info *i;
442 442
443 i = kmem_cache_alloc(hfsplus_inode_cachep, SLAB_KERNEL); 443 i = kmem_cache_alloc(hfsplus_inode_cachep, GFP_KERNEL);
444 return i ? &i->vfs_inode : NULL; 444 return i ? &i->vfs_inode : NULL;
445} 445}
446 446
@@ -467,7 +467,7 @@ static struct file_system_type hfsplus_fs_type = {
467 .fs_flags = FS_REQUIRES_DEV, 467 .fs_flags = FS_REQUIRES_DEV,
468}; 468};
469 469
470static void hfsplus_init_once(void *p, kmem_cache_t *cachep, unsigned long flags) 470static void hfsplus_init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
471{ 471{
472 struct hfsplus_inode_info *i = p; 472 struct hfsplus_inode_info *i = p;
473 473
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c
index ecc9180645ae..594f9c428fc2 100644
--- a/fs/hpfs/dir.c
+++ b/fs/hpfs/dir.c
@@ -84,7 +84,8 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
84 } 84 }
85 if (!fno->dirflag) { 85 if (!fno->dirflag) {
86 e = 1; 86 e = 1;
87 hpfs_error(inode->i_sb, "not a directory, fnode %08x",inode->i_ino); 87 hpfs_error(inode->i_sb, "not a directory, fnode %08lx",
88 (unsigned long)inode->i_ino);
88 } 89 }
89 if (hpfs_inode->i_dno != fno->u.external[0].disk_secno) { 90 if (hpfs_inode->i_dno != fno->u.external[0].disk_secno) {
90 e = 1; 91 e = 1;
@@ -144,8 +145,11 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
144 } 145 }
145 if (de->first || de->last) { 146 if (de->first || de->last) {
146 if (hpfs_sb(inode->i_sb)->sb_chk) { 147 if (hpfs_sb(inode->i_sb)->sb_chk) {
147 if (de->first && !de->last && (de->namelen != 2 || de ->name[0] != 1 || de->name[1] != 1)) hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08x", old_pos); 148 if (de->first && !de->last && (de->namelen != 2
148 if (de->last && (de->namelen != 1 || de ->name[0] != 255)) hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08x", old_pos); 149 || de ->name[0] != 1 || de->name[1] != 1))
150 hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", old_pos);
151 if (de->last && (de->namelen != 1 || de ->name[0] != 255))
152 hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", old_pos);
149 } 153 }
150 hpfs_brelse4(&qbh); 154 hpfs_brelse4(&qbh);
151 goto again; 155 goto again;
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c
index 229ff2fb1809..fe83c2b7d2d8 100644
--- a/fs/hpfs/dnode.c
+++ b/fs/hpfs/dnode.c
@@ -533,10 +533,13 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno)
533 struct buffer_head *bh; 533 struct buffer_head *bh;
534 struct dnode *d1; 534 struct dnode *d1;
535 struct quad_buffer_head qbh1; 535 struct quad_buffer_head qbh1;
536 if (hpfs_sb(i->i_sb)->sb_chk) if (up != i->i_ino) { 536 if (hpfs_sb(i->i_sb)->sb_chk)
537 hpfs_error(i->i_sb, "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08x", dno, up, i->i_ino); 537 if (up != i->i_ino) {
538 hpfs_error(i->i_sb,
539 "bad pointer to fnode, dnode %08x, pointing to %08x, should be %08lx",
540 dno, up, (unsigned long)i->i_ino);
538 return; 541 return;
539 } 542 }
540 if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) { 543 if ((d1 = hpfs_map_dnode(i->i_sb, down, &qbh1))) {
541 d1->up = up; 544 d1->up = up;
542 d1->root_dnode = 1; 545 d1->root_dnode = 1;
@@ -851,7 +854,9 @@ struct hpfs_dirent *map_pos_dirent(struct inode *inode, loff_t *posp,
851 /* Going to the next dirent */ 854 /* Going to the next dirent */
852 if ((d = de_next_de(de)) < dnode_end_de(dnode)) { 855 if ((d = de_next_de(de)) < dnode_end_de(dnode)) {
853 if (!(++*posp & 077)) { 856 if (!(++*posp & 077)) {
854 hpfs_error(inode->i_sb, "map_pos_dirent: pos crossed dnode boundary; pos = %08x", *posp); 857 hpfs_error(inode->i_sb,
858 "map_pos_dirent: pos crossed dnode boundary; pos = %08llx",
859 (unsigned long long)*posp);
855 goto bail; 860 goto bail;
856 } 861 }
857 /* We're going down the tree */ 862 /* We're going down the tree */
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c
index 66339dc030e4..547a8384571f 100644
--- a/fs/hpfs/ea.c
+++ b/fs/hpfs/ea.c
@@ -243,8 +243,9 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, char *key, char *data
243 fnode->ea_offs = 0xc4; 243 fnode->ea_offs = 0xc4;
244 } 244 }
245 if (fnode->ea_offs < 0xc4 || fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200) { 245 if (fnode->ea_offs < 0xc4 || fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200) {
246 hpfs_error(s, "fnode %08x: ea_offs == %03x, ea_size_s == %03x", 246 hpfs_error(s, "fnode %08lx: ea_offs == %03x, ea_size_s == %03x",
247 inode->i_ino, fnode->ea_offs, fnode->ea_size_s); 247 (unsigned long)inode->i_ino,
248 fnode->ea_offs, fnode->ea_size_s);
248 return; 249 return;
249 } 250 }
250 if ((fnode->ea_size_s || !fnode->ea_size_l) && 251 if ((fnode->ea_size_s || !fnode->ea_size_l) &&
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 32ab51e42b96..1c07aa82d327 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -317,7 +317,8 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb)
317 317
318/* super.c */ 318/* super.c */
319 319
320void hpfs_error(struct super_block *, char *, ...); 320void hpfs_error(struct super_block *, const char *, ...)
321 __attribute__((format (printf, 2, 3)));
321int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *); 322int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *);
322unsigned hpfs_count_one_bitmap(struct super_block *, secno); 323unsigned hpfs_count_one_bitmap(struct super_block *, secno);
323 324
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 7faef8544f32..85d3e1d9ac00 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -251,7 +251,10 @@ void hpfs_write_inode_nolock(struct inode *i)
251 de->file_size = 0; 251 de->file_size = 0;
252 hpfs_mark_4buffers_dirty(&qbh); 252 hpfs_mark_4buffers_dirty(&qbh);
253 hpfs_brelse4(&qbh); 253 hpfs_brelse4(&qbh);
254 } else hpfs_error(i->i_sb, "directory %08x doesn't have '.' entry", i->i_ino); 254 } else
255 hpfs_error(i->i_sb,
256 "directory %08lx doesn't have '.' entry",
257 (unsigned long)i->i_ino);
255 } 258 }
256 mark_buffer_dirty(bh); 259 mark_buffer_dirty(bh);
257 brelse(bh); 260 brelse(bh);
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c
index 0fecdac22e4e..c4724589b2eb 100644
--- a/fs/hpfs/map.c
+++ b/fs/hpfs/map.c
@@ -126,32 +126,40 @@ struct fnode *hpfs_map_fnode(struct super_block *s, ino_t ino, struct buffer_hea
126 struct extended_attribute *ea; 126 struct extended_attribute *ea;
127 struct extended_attribute *ea_end; 127 struct extended_attribute *ea_end;
128 if (fnode->magic != FNODE_MAGIC) { 128 if (fnode->magic != FNODE_MAGIC) {
129 hpfs_error(s, "bad magic on fnode %08x", ino); 129 hpfs_error(s, "bad magic on fnode %08lx",
130 (unsigned long)ino);
130 goto bail; 131 goto bail;
131 } 132 }
132 if (!fnode->dirflag) { 133 if (!fnode->dirflag) {
133 if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes != 134 if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes !=
134 (fnode->btree.internal ? 12 : 8)) { 135 (fnode->btree.internal ? 12 : 8)) {
135 hpfs_error(s, "bad number of nodes in fnode %08x", ino); 136 hpfs_error(s,
137 "bad number of nodes in fnode %08lx",
138 (unsigned long)ino);
136 goto bail; 139 goto bail;
137 } 140 }
138 if (fnode->btree.first_free != 141 if (fnode->btree.first_free !=
139 8 + fnode->btree.n_used_nodes * (fnode->btree.internal ? 8 : 12)) { 142 8 + fnode->btree.n_used_nodes * (fnode->btree.internal ? 8 : 12)) {
140 hpfs_error(s, "bad first_free pointer in fnode %08x", ino); 143 hpfs_error(s,
144 "bad first_free pointer in fnode %08lx",
145 (unsigned long)ino);
141 goto bail; 146 goto bail;
142 } 147 }
143 } 148 }
144 if (fnode->ea_size_s && ((signed int)fnode->ea_offs < 0xc4 || 149 if (fnode->ea_size_s && ((signed int)fnode->ea_offs < 0xc4 ||
145 (signed int)fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200)) { 150 (signed int)fnode->ea_offs + fnode->acl_size_s + fnode->ea_size_s > 0x200)) {
146 hpfs_error(s, "bad EA info in fnode %08x: ea_offs == %04x ea_size_s == %04x", 151 hpfs_error(s,
147 ino, fnode->ea_offs, fnode->ea_size_s); 152 "bad EA info in fnode %08lx: ea_offs == %04x ea_size_s == %04x",
153 (unsigned long)ino,
154 fnode->ea_offs, fnode->ea_size_s);
148 goto bail; 155 goto bail;
149 } 156 }
150 ea = fnode_ea(fnode); 157 ea = fnode_ea(fnode);
151 ea_end = fnode_end_ea(fnode); 158 ea_end = fnode_end_ea(fnode);
152 while (ea != ea_end) { 159 while (ea != ea_end) {
153 if (ea > ea_end) { 160 if (ea > ea_end) {
154 hpfs_error(s, "bad EA in fnode %08x", ino); 161 hpfs_error(s, "bad EA in fnode %08lx",
162 (unsigned long)ino);
155 goto bail; 163 goto bail;
156 } 164 }
157 ea = next_ea(ea); 165 ea = next_ea(ea);
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 450b5e0b4785..d4abc1a1d566 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -46,21 +46,17 @@ static void unmark_dirty(struct super_block *s)
46} 46}
47 47
48/* Filesystem error... */ 48/* Filesystem error... */
49static char err_buf[1024];
49 50
50#define ERR_BUF_SIZE 1024 51void hpfs_error(struct super_block *s, const char *fmt, ...)
51
52void hpfs_error(struct super_block *s, char *m,...)
53{ 52{
54 char *buf; 53 va_list args;
55 va_list l; 54
56 va_start(l, m); 55 va_start(args, fmt);
57 if (!(buf = kmalloc(ERR_BUF_SIZE, GFP_KERNEL))) 56 vsnprintf(err_buf, sizeof(err_buf), fmt, args);
58 printk("HPFS: No memory for error message '%s'\n",m); 57 va_end(args);
59 else if (vsprintf(buf, m, l) >= ERR_BUF_SIZE) 58
60 printk("HPFS: Grrrr... Kernel memory corrupted ... going on, but it'll crash very soon :-(\n"); 59 printk("HPFS: filesystem error: %s", err_buf);
61 printk("HPFS: filesystem error: ");
62 if (buf) printk("%s", buf);
63 else printk("%s\n",m);
64 if (!hpfs_sb(s)->sb_was_error) { 60 if (!hpfs_sb(s)->sb_was_error) {
65 if (hpfs_sb(s)->sb_err == 2) { 61 if (hpfs_sb(s)->sb_err == 2) {
66 printk("; crashing the system because you wanted it\n"); 62 printk("; crashing the system because you wanted it\n");
@@ -76,7 +72,6 @@ void hpfs_error(struct super_block *s, char *m,...)
76 } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n"); 72 } else if (s->s_flags & MS_RDONLY) printk("; going on - but anything won't be destroyed because it's read-only\n");
77 else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n"); 73 else printk("; corrupted filesystem mounted read/write - your computer will explode within 20 seconds ... but you wanted it so!\n");
78 } else printk("\n"); 74 } else printk("\n");
79 kfree(buf);
80 hpfs_sb(s)->sb_was_error = 1; 75 hpfs_sb(s)->sb_was_error = 1;
81} 76}
82 77
@@ -160,12 +155,12 @@ static int hpfs_statfs(struct dentry *dentry, struct kstatfs *buf)
160 return 0; 155 return 0;
161} 156}
162 157
163static kmem_cache_t * hpfs_inode_cachep; 158static struct kmem_cache * hpfs_inode_cachep;
164 159
165static struct inode *hpfs_alloc_inode(struct super_block *sb) 160static struct inode *hpfs_alloc_inode(struct super_block *sb)
166{ 161{
167 struct hpfs_inode_info *ei; 162 struct hpfs_inode_info *ei;
168 ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, SLAB_NOFS); 163 ei = (struct hpfs_inode_info *)kmem_cache_alloc(hpfs_inode_cachep, GFP_NOFS);
169 if (!ei) 164 if (!ei)
170 return NULL; 165 return NULL;
171 ei->vfs_inode.i_version = 1; 166 ei->vfs_inode.i_version = 1;
@@ -177,7 +172,7 @@ static void hpfs_destroy_inode(struct inode *inode)
177 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); 172 kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode));
178} 173}
179 174
180static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 175static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
181{ 176{
182 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; 177 struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo;
183 178
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 7f4756963d05..0706f5aac6a2 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -513,7 +513,7 @@ static void hugetlbfs_inc_free_inodes(struct hugetlbfs_sb_info *sbinfo)
513} 513}
514 514
515 515
516static kmem_cache_t *hugetlbfs_inode_cachep; 516static struct kmem_cache *hugetlbfs_inode_cachep;
517 517
518static struct inode *hugetlbfs_alloc_inode(struct super_block *sb) 518static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
519{ 519{
@@ -522,7 +522,7 @@ static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)
522 522
523 if (unlikely(!hugetlbfs_dec_free_inodes(sbinfo))) 523 if (unlikely(!hugetlbfs_dec_free_inodes(sbinfo)))
524 return NULL; 524 return NULL;
525 p = kmem_cache_alloc(hugetlbfs_inode_cachep, SLAB_KERNEL); 525 p = kmem_cache_alloc(hugetlbfs_inode_cachep, GFP_KERNEL);
526 if (unlikely(!p)) { 526 if (unlikely(!p)) {
527 hugetlbfs_inc_free_inodes(sbinfo); 527 hugetlbfs_inc_free_inodes(sbinfo);
528 return NULL; 528 return NULL;
@@ -545,7 +545,7 @@ static const struct address_space_operations hugetlbfs_aops = {
545}; 545};
546 546
547 547
548static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 548static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
549{ 549{
550 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo; 550 struct hugetlbfs_inode_info *ei = (struct hugetlbfs_inode_info *)foo;
551 551
diff --git a/fs/inode.c b/fs/inode.c
index 26cdb115ce67..9ecccab7326d 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -97,7 +97,7 @@ static DEFINE_MUTEX(iprune_mutex);
97 */ 97 */
98struct inodes_stat_t inodes_stat; 98struct inodes_stat_t inodes_stat;
99 99
100static kmem_cache_t * inode_cachep __read_mostly; 100static struct kmem_cache * inode_cachep __read_mostly;
101 101
102static struct inode *alloc_inode(struct super_block *sb) 102static struct inode *alloc_inode(struct super_block *sb)
103{ 103{
@@ -109,7 +109,7 @@ static struct inode *alloc_inode(struct super_block *sb)
109 if (sb->s_op->alloc_inode) 109 if (sb->s_op->alloc_inode)
110 inode = sb->s_op->alloc_inode(sb); 110 inode = sb->s_op->alloc_inode(sb);
111 else 111 else
112 inode = (struct inode *) kmem_cache_alloc(inode_cachep, SLAB_KERNEL); 112 inode = (struct inode *) kmem_cache_alloc(inode_cachep, GFP_KERNEL);
113 113
114 if (inode) { 114 if (inode) {
115 struct address_space * const mapping = &inode->i_data; 115 struct address_space * const mapping = &inode->i_data;
@@ -209,7 +209,7 @@ void inode_init_once(struct inode *inode)
209 209
210EXPORT_SYMBOL(inode_init_once); 210EXPORT_SYMBOL(inode_init_once);
211 211
212static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 212static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
213{ 213{
214 struct inode * inode = (struct inode *) foo; 214 struct inode * inode = (struct inode *) foo;
215 215
@@ -1242,9 +1242,6 @@ EXPORT_SYMBOL(inode_needs_sync);
1242 */ 1242 */
1243#ifdef CONFIG_QUOTA 1243#ifdef CONFIG_QUOTA
1244 1244
1245/* Function back in dquot.c */
1246int remove_inode_dquot_ref(struct inode *, int, struct list_head *);
1247
1248void remove_dquot_ref(struct super_block *sb, int type, 1245void remove_dquot_ref(struct super_block *sb, int type,
1249 struct list_head *tofree_head) 1246 struct list_head *tofree_head)
1250{ 1247{
diff --git a/fs/inotify_user.c b/fs/inotify_user.c
index 017cb0f134d6..e1956e6f116c 100644
--- a/fs/inotify_user.c
+++ b/fs/inotify_user.c
@@ -34,8 +34,8 @@
34 34
35#include <asm/ioctls.h> 35#include <asm/ioctls.h>
36 36
37static kmem_cache_t *watch_cachep __read_mostly; 37static struct kmem_cache *watch_cachep __read_mostly;
38static kmem_cache_t *event_cachep __read_mostly; 38static struct kmem_cache *event_cachep __read_mostly;
39 39
40static struct vfsmount *inotify_mnt __read_mostly; 40static struct vfsmount *inotify_mnt __read_mostly;
41 41
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index c34b862cdbf2..ea55b6c469ec 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -57,12 +57,12 @@ static void isofs_put_super(struct super_block *sb)
57static void isofs_read_inode(struct inode *); 57static void isofs_read_inode(struct inode *);
58static int isofs_statfs (struct dentry *, struct kstatfs *); 58static int isofs_statfs (struct dentry *, struct kstatfs *);
59 59
60static kmem_cache_t *isofs_inode_cachep; 60static struct kmem_cache *isofs_inode_cachep;
61 61
62static struct inode *isofs_alloc_inode(struct super_block *sb) 62static struct inode *isofs_alloc_inode(struct super_block *sb)
63{ 63{
64 struct iso_inode_info *ei; 64 struct iso_inode_info *ei;
65 ei = kmem_cache_alloc(isofs_inode_cachep, SLAB_KERNEL); 65 ei = kmem_cache_alloc(isofs_inode_cachep, GFP_KERNEL);
66 if (!ei) 66 if (!ei)
67 return NULL; 67 return NULL;
68 return &ei->vfs_inode; 68 return &ei->vfs_inode;
@@ -73,7 +73,7 @@ static void isofs_destroy_inode(struct inode *inode)
73 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); 73 kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
74} 74}
75 75
76static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) 76static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
77{ 77{
78 struct iso_inode_info *ei = foo; 78 struct iso_inode_info *ei = foo;
79 79
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index b85c686b60db..10fff9443938 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -31,7 +31,7 @@
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/suspend.h> 34#include <linux/freezer.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/poison.h> 37#include <linux/poison.h>
@@ -1630,7 +1630,7 @@ void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
1630#define JBD_MAX_SLABS 5 1630#define JBD_MAX_SLABS 5
1631#define JBD_SLAB_INDEX(size) (size >> 11) 1631#define JBD_SLAB_INDEX(size) (size >> 11)
1632 1632
1633static kmem_cache_t *jbd_slab[JBD_MAX_SLABS]; 1633static struct kmem_cache *jbd_slab[JBD_MAX_SLABS];
1634static const char *jbd_slab_names[JBD_MAX_SLABS] = { 1634static const char *jbd_slab_names[JBD_MAX_SLABS] = {
1635 "jbd_1k", "jbd_2k", "jbd_4k", NULL, "jbd_8k" 1635 "jbd_1k", "jbd_2k", "jbd_4k", NULL, "jbd_8k"
1636}; 1636};
@@ -1693,7 +1693,7 @@ void jbd_slab_free(void *ptr, size_t size)
1693/* 1693/*
1694 * Journal_head storage management 1694 * Journal_head storage management
1695 */ 1695 */
1696static kmem_cache_t *journal_head_cache; 1696static struct kmem_cache *journal_head_cache;
1697#ifdef CONFIG_JBD_DEBUG 1697#ifdef CONFIG_JBD_DEBUG
1698static atomic_t nr_journal_heads = ATOMIC_INIT(0); 1698static atomic_t nr_journal_heads = ATOMIC_INIT(0);
1699#endif 1699#endif
@@ -1996,7 +1996,7 @@ static void __exit remove_jbd_proc_entry(void)
1996 1996
1997#endif 1997#endif
1998 1998
1999kmem_cache_t *jbd_handle_cache; 1999struct kmem_cache *jbd_handle_cache;
2000 2000
2001static int __init journal_init_handle_cache(void) 2001static int __init journal_init_handle_cache(void)
2002{ 2002{
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c
index c532429d8d9b..d204ab394f36 100644
--- a/fs/jbd/revoke.c
+++ b/fs/jbd/revoke.c
@@ -70,8 +70,8 @@
70#include <linux/init.h> 70#include <linux/init.h>
71#endif 71#endif
72 72
73static kmem_cache_t *revoke_record_cache; 73static struct kmem_cache *revoke_record_cache;
74static kmem_cache_t *revoke_table_cache; 74static struct kmem_cache *revoke_table_cache;
75 75
76/* Each revoke record represents one single revoked block. During 76/* Each revoke record represents one single revoked block. During
77 journal replay, this involves recording the transaction ID of the 77 journal replay, this involves recording the transaction ID of the
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 4f82bcd63e48..d38e0d575e48 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -27,6 +27,8 @@
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/highmem.h> 28#include <linux/highmem.h>
29 29
30static void __journal_temp_unlink_buffer(struct journal_head *jh);
31
30/* 32/*
31 * get_transaction: obtain a new transaction_t object. 33 * get_transaction: obtain a new transaction_t object.
32 * 34 *
@@ -1499,7 +1501,7 @@ __blist_del_buffer(struct journal_head **list, struct journal_head *jh)
1499 * 1501 *
1500 * Called under j_list_lock. The journal may not be locked. 1502 * Called under j_list_lock. The journal may not be locked.
1501 */ 1503 */
1502void __journal_temp_unlink_buffer(struct journal_head *jh) 1504static void __journal_temp_unlink_buffer(struct journal_head *jh)
1503{ 1505{
1504 struct journal_head **list = NULL; 1506 struct journal_head **list = NULL;
1505 transaction_t *transaction; 1507 transaction_t *transaction;
diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index 70b2ae1ef281..6bd8005e3d34 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -248,8 +248,12 @@ write_out_data:
248 bufs = 0; 248 bufs = 0;
249 goto write_out_data; 249 goto write_out_data;
250 } 250 }
251 } 251 } else if (!locked && buffer_locked(bh)) {
252 else { 252 __jbd2_journal_file_buffer(jh, commit_transaction,
253 BJ_Locked);
254 jbd_unlock_bh_state(bh);
255 put_bh(bh);
256 } else {
253 BUFFER_TRACE(bh, "writeout complete: unfile"); 257 BUFFER_TRACE(bh, "writeout complete: unfile");
254 __jbd2_journal_unfile_buffer(jh); 258 __jbd2_journal_unfile_buffer(jh);
255 jbd_unlock_bh_state(bh); 259 jbd_unlock_bh_state(bh);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index c60f378b0f76..44fc32bfd7f1 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -31,7 +31,7 @@
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/mm.h> 33#include <linux/mm.h>
34#include <linux/suspend.h> 34#include <linux/freezer.h>
35#include <linux/pagemap.h> 35#include <linux/pagemap.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/poison.h> 37#include <linux/poison.h>
@@ -1641,7 +1641,7 @@ void * __jbd2_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
1641#define JBD_MAX_SLABS 5 1641#define JBD_MAX_SLABS 5
1642#define JBD_SLAB_INDEX(size) (size >> 11) 1642#define JBD_SLAB_INDEX(size) (size >> 11)
1643 1643
1644static kmem_cache_t *jbd_slab[JBD_MAX_SLABS]; 1644static struct kmem_cache *jbd_slab[JBD_MAX_SLABS];
1645static const char *jbd_slab_names[JBD_MAX_SLABS] = { 1645static const char *jbd_slab_names[JBD_MAX_SLABS] = {
1646 "jbd2_1k", "jbd2_2k", "jbd2_4k", NULL, "jbd2_8k" 1646 "jbd2_1k", "jbd2_2k", "jbd2_4k", NULL, "jbd2_8k"
1647}; 1647};
@@ -1704,7 +1704,7 @@ void jbd2_slab_free(void *ptr, size_t size)
1704/* 1704/*
1705 * Journal_head storage management 1705 * Journal_head storage management
1706 */ 1706 */
1707static kmem_cache_t *jbd2_journal_head_cache; 1707static struct kmem_cache *jbd2_journal_head_cache;
1708#ifdef CONFIG_JBD_DEBUG 1708#ifdef CONFIG_JBD_DEBUG
1709static atomic_t nr_journal_heads = ATOMIC_INIT(0); 1709static atomic_t nr_journal_heads = ATOMIC_INIT(0);
1710#endif 1710#endif
@@ -2007,7 +2007,7 @@ static void __exit jbd2_remove_jbd_proc_entry(void)
2007 2007
2008#endif 2008#endif
2009 2009
2010kmem_cache_t *jbd2_handle_cache; 2010struct kmem_cache *jbd2_handle_cache;
2011 2011
2012static int __init journal_init_handle_cache(void) 2012static int __init journal_init_handle_cache(void)
2013{ 2013{
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c
index 380d19917f37..f506646ad0ff 100644
--- a/fs/jbd2/revoke.c
+++ b/fs/jbd2/revoke.c
@@ -70,8 +70,8 @@
70#include <linux/init.h> 70#include <linux/init.h>
71#endif 71#endif
72 72
73static kmem_cache_t *jbd2_revoke_record_cache; 73static struct kmem_cache *jbd2_revoke_record_cache;
74static kmem_cache_t *jbd2_revoke_table_cache; 74static struct kmem_cache *jbd2_revoke_table_cache;
75 75
76/* Each revoke record represents one single revoked block. During 76/* Each revoke record represents one single revoked block. During
77 journal replay, this involves recording the transaction ID of the 77 journal replay, this involves recording the transaction ID of the
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index c051a94c8a97..3a8700153cb0 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -27,6 +27,8 @@
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/highmem.h> 28#include <linux/highmem.h>
29 29
30static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
31
30/* 32/*
31 * jbd2_get_transaction: obtain a new transaction_t object. 33 * jbd2_get_transaction: obtain a new transaction_t object.
32 * 34 *
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
index 3f7899ea4cba..9f15bce92022 100644
--- a/fs/jffs/inode-v23.c
+++ b/fs/jffs/inode-v23.c
@@ -61,8 +61,8 @@ static const struct file_operations jffs_dir_operations;
61static struct inode_operations jffs_dir_inode_operations; 61static struct inode_operations jffs_dir_inode_operations;
62static const struct address_space_operations jffs_address_operations; 62static const struct address_space_operations jffs_address_operations;
63 63
64kmem_cache_t *node_cache = NULL; 64struct kmem_cache *node_cache = NULL;
65kmem_cache_t *fm_cache = NULL; 65struct kmem_cache *fm_cache = NULL;
66 66
67/* Called by the VFS at mount time to initialize the whole file system. */ 67/* Called by the VFS at mount time to initialize the whole file system. */
68static int jffs_fill_super(struct super_block *sb, void *data, int silent) 68static int jffs_fill_super(struct super_block *sb, void *data, int silent)
diff --git a/fs/jffs/intrep.c b/fs/jffs/intrep.c
index 4a543e114970..d0e783f199ea 100644
--- a/fs/jffs/intrep.c
+++ b/fs/jffs/intrep.c
@@ -66,6 +66,7 @@
66#include <linux/smp_lock.h> 66#include <linux/smp_lock.h>
67#include <linux/time.h> 67#include <linux/time.h>
68#include <linux/ctype.h> 68#include <linux/ctype.h>
69#include <linux/freezer.h>
69 70
70#include "intrep.h" 71#include "intrep.h"
71#include "jffs_fm.h" 72#include "jffs_fm.h"
@@ -591,7 +592,7 @@ jffs_add_virtual_root(struct jffs_control *c)
591 D2(printk("jffs_add_virtual_root(): " 592 D2(printk("jffs_add_virtual_root(): "
592 "Creating a virtual root directory.\n")); 593 "Creating a virtual root directory.\n"));
593 594
594 if (!(root = kmalloc(sizeof(struct jffs_file), GFP_KERNEL))) { 595 if (!(root = kzalloc(sizeof(struct jffs_file), GFP_KERNEL))) {
595 return -ENOMEM; 596 return -ENOMEM;
596 } 597 }
597 no_jffs_file++; 598 no_jffs_file++;
@@ -603,7 +604,6 @@ jffs_add_virtual_root(struct jffs_control *c)
603 DJM(no_jffs_node++); 604 DJM(no_jffs_node++);
604 memset(node, 0, sizeof(struct jffs_node)); 605 memset(node, 0, sizeof(struct jffs_node));
605 node->ino = JFFS_MIN_INO; 606 node->ino = JFFS_MIN_INO;
606 memset(root, 0, sizeof(struct jffs_file));
607 root->ino = JFFS_MIN_INO; 607 root->ino = JFFS_MIN_INO;
608 root->mode = S_IFDIR | S_IRWXU | S_IRGRP 608 root->mode = S_IFDIR | S_IRWXU | S_IRGRP
609 | S_IXGRP | S_IROTH | S_IXOTH; 609 | S_IXGRP | S_IROTH | S_IXOTH;
diff --git a/fs/jffs/jffs_fm.c b/fs/jffs/jffs_fm.c
index 29b68d939bd9..077258b2103e 100644
--- a/fs/jffs/jffs_fm.c
+++ b/fs/jffs/jffs_fm.c
@@ -29,8 +29,8 @@ static int jffs_mark_obsolete(struct jffs_fmcontrol *fmc, __u32 fm_offset);
29static struct jffs_fm *jffs_alloc_fm(void); 29static struct jffs_fm *jffs_alloc_fm(void);
30static void jffs_free_fm(struct jffs_fm *n); 30static void jffs_free_fm(struct jffs_fm *n);
31 31
32extern kmem_cache_t *fm_cache; 32extern struct kmem_cache *fm_cache;
33extern kmem_cache_t *node_cache; 33extern struct kmem_cache *node_cache;
34 34
35#if CONFIG_JFFS_FS_VERBOSE > 0 35#if CONFIG_JFFS_FS_VERBOSE > 0
36void 36void
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
index ff2a872e80e7..6eb3daebd563 100644
--- a/fs/jffs2/background.c
+++ b/fs/jffs2/background.c
@@ -16,6 +16,7 @@
16#include <linux/mtd/mtd.h> 16#include <linux/mtd/mtd.h>
17#include <linux/completion.h> 17#include <linux/completion.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/freezer.h>
19#include "nodelist.h" 20#include "nodelist.h"
20 21
21 22
diff --git a/fs/jffs2/malloc.c b/fs/jffs2/malloc.c
index 33f291005012..83f9881ec4cc 100644
--- a/fs/jffs2/malloc.c
+++ b/fs/jffs2/malloc.c
@@ -19,16 +19,16 @@
19 19
20/* These are initialised to NULL in the kernel startup code. 20/* These are initialised to NULL in the kernel startup code.
21 If you're porting to other operating systems, beware */ 21 If you're porting to other operating systems, beware */
22static kmem_cache_t *full_dnode_slab; 22static struct kmem_cache *full_dnode_slab;
23static kmem_cache_t *raw_dirent_slab; 23static struct kmem_cache *raw_dirent_slab;
24static kmem_cache_t *raw_inode_slab; 24static struct kmem_cache *raw_inode_slab;
25static kmem_cache_t *tmp_dnode_info_slab; 25static struct kmem_cache *tmp_dnode_info_slab;
26static kmem_cache_t *raw_node_ref_slab; 26static struct kmem_cache *raw_node_ref_slab;
27static kmem_cache_t *node_frag_slab; 27static struct kmem_cache *node_frag_slab;
28static kmem_cache_t *inode_cache_slab; 28static struct kmem_cache *inode_cache_slab;
29#ifdef CONFIG_JFFS2_FS_XATTR 29#ifdef CONFIG_JFFS2_FS_XATTR
30static kmem_cache_t *xattr_datum_cache; 30static struct kmem_cache *xattr_datum_cache;
31static kmem_cache_t *xattr_ref_cache; 31static struct kmem_cache *xattr_ref_cache;
32#endif 32#endif
33 33
34int __init jffs2_create_slab_caches(void) 34int __init jffs2_create_slab_caches(void)
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index bc4b8106a490..7deb78254021 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -28,12 +28,12 @@
28 28
29static void jffs2_put_super(struct super_block *); 29static void jffs2_put_super(struct super_block *);
30 30
31static kmem_cache_t *jffs2_inode_cachep; 31static struct kmem_cache *jffs2_inode_cachep;
32 32
33static struct inode *jffs2_alloc_inode(struct super_block *sb) 33static struct inode *jffs2_alloc_inode(struct super_block *sb)
34{ 34{
35 struct jffs2_inode_info *ei; 35 struct jffs2_inode_info *ei;
36 ei = (struct jffs2_inode_info *)kmem_cache_alloc(jffs2_inode_cachep, SLAB_KERNEL); 36 ei = (struct jffs2_inode_info *)kmem_cache_alloc(jffs2_inode_cachep, GFP_KERNEL);
37 if (!ei) 37 if (!ei)
38 return NULL; 38 return NULL;
39 return &ei->vfs_inode; 39 return &ei->vfs_inode;
@@ -44,7 +44,7 @@ static void jffs2_destroy_inode(struct inode *inode)
44 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); 44 kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode));
45} 45}
46 46
47static void jffs2_i_init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 47static void jffs2_i_init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
48{ 48{
49 struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo; 49 struct jffs2_inode_info *ei = (struct jffs2_inode_info *) foo;
50 50
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index b89c9aba0466..5065baa530b6 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -67,7 +67,7 @@
67#include <linux/kthread.h> 67#include <linux/kthread.h>
68#include <linux/buffer_head.h> /* for sync_blockdev() */ 68#include <linux/buffer_head.h> /* for sync_blockdev() */
69#include <linux/bio.h> 69#include <linux/bio.h>
70#include <linux/suspend.h> 70#include <linux/freezer.h>
71#include <linux/delay.h> 71#include <linux/delay.h>
72#include <linux/mutex.h> 72#include <linux/mutex.h>
73#include "jfs_incore.h" 73#include "jfs_incore.h"
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 0cccd1c39d75..b1a1c7296014 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -74,7 +74,7 @@ static inline void lock_metapage(struct metapage *mp)
74} 74}
75 75
76#define METAPOOL_MIN_PAGES 32 76#define METAPOOL_MIN_PAGES 32
77static kmem_cache_t *metapage_cache; 77static struct kmem_cache *metapage_cache;
78static mempool_t *metapage_mempool; 78static mempool_t *metapage_mempool;
79 79
80#define MPS_PER_PAGE (PAGE_CACHE_SIZE >> L2PSIZE) 80#define MPS_PER_PAGE (PAGE_CACHE_SIZE >> L2PSIZE)
@@ -180,7 +180,7 @@ static inline void remove_metapage(struct page *page, struct metapage *mp)
180 180
181#endif 181#endif
182 182
183static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 183static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
184{ 184{
185 struct metapage *mp = (struct metapage *)foo; 185 struct metapage *mp = (struct metapage *)foo;
186 186
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index 81f6f04af192..d558e51b0df8 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -46,7 +46,7 @@
46#include <linux/vmalloc.h> 46#include <linux/vmalloc.h>
47#include <linux/smp_lock.h> 47#include <linux/smp_lock.h>
48#include <linux/completion.h> 48#include <linux/completion.h>
49#include <linux/suspend.h> 49#include <linux/freezer.h>
50#include <linux/module.h> 50#include <linux/module.h>
51#include <linux/moduleparam.h> 51#include <linux/moduleparam.h>
52#include <linux/kthread.h> 52#include <linux/kthread.h>
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 9c1c6e0e633d..846ac8f34513 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -44,7 +44,7 @@ MODULE_DESCRIPTION("The Journaled Filesystem (JFS)");
44MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM"); 44MODULE_AUTHOR("Steve Best/Dave Kleikamp/Barry Arndt, IBM");
45MODULE_LICENSE("GPL"); 45MODULE_LICENSE("GPL");
46 46
47static kmem_cache_t * jfs_inode_cachep; 47static struct kmem_cache * jfs_inode_cachep;
48 48
49static struct super_operations jfs_super_operations; 49static struct super_operations jfs_super_operations;
50static struct export_operations jfs_export_operations; 50static struct export_operations jfs_export_operations;
@@ -93,7 +93,7 @@ void jfs_error(struct super_block *sb, const char * function, ...)
93 va_list args; 93 va_list args;
94 94
95 va_start(args, function); 95 va_start(args, function);
96 vsprintf(error_buf, function, args); 96 vsnprintf(error_buf, sizeof(error_buf), function, args);
97 va_end(args); 97 va_end(args);
98 98
99 printk(KERN_ERR "ERROR: (device %s): %s\n", sb->s_id, error_buf); 99 printk(KERN_ERR "ERROR: (device %s): %s\n", sb->s_id, error_buf);
@@ -748,7 +748,7 @@ static struct file_system_type jfs_fs_type = {
748 .fs_flags = FS_REQUIRES_DEV, 748 .fs_flags = FS_REQUIRES_DEV,
749}; 749};
750 750
751static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) 751static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
752{ 752{
753 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo; 753 struct jfs_inode_info *jfs_ip = (struct jfs_inode_info *) foo;
754 754
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 41c983a05294..497c3cd59d52 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -13,6 +13,7 @@
13#include <linux/nfs_fs.h> 13#include <linux/nfs_fs.h>
14#include <linux/utsname.h> 14#include <linux/utsname.h>
15#include <linux/smp_lock.h> 15#include <linux/smp_lock.h>
16#include <linux/freezer.h>
16#include <linux/sunrpc/clnt.h> 17#include <linux/sunrpc/clnt.h>
17#include <linux/sunrpc/svc.h> 18#include <linux/sunrpc/svc.h>
18#include <linux/lockd/lockd.h> 19#include <linux/lockd/lockd.h>
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index fb24a9730345..3d4610c2a266 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -36,34 +36,14 @@ static DEFINE_MUTEX(nlm_host_mutex);
36static void nlm_gc_hosts(void); 36static void nlm_gc_hosts(void);
37static struct nsm_handle * __nsm_find(const struct sockaddr_in *, 37static struct nsm_handle * __nsm_find(const struct sockaddr_in *,
38 const char *, int, int); 38 const char *, int, int);
39 39static struct nsm_handle * nsm_find(const struct sockaddr_in *sin,
40/* 40 const char *hostname,
41 * Find an NLM server handle in the cache. If there is none, create it. 41 int hostname_len);
42 */
43struct nlm_host *
44nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
45 const char *hostname, int hostname_len)
46{
47 return nlm_lookup_host(0, sin, proto, version,
48 hostname, hostname_len);
49}
50
51/*
52 * Find an NLM client handle in the cache. If there is none, create it.
53 */
54struct nlm_host *
55nlmsvc_lookup_host(struct svc_rqst *rqstp,
56 const char *hostname, int hostname_len)
57{
58 return nlm_lookup_host(1, &rqstp->rq_addr,
59 rqstp->rq_prot, rqstp->rq_vers,
60 hostname, hostname_len);
61}
62 42
63/* 43/*
64 * Common host lookup routine for server & client 44 * Common host lookup routine for server & client
65 */ 45 */
66struct nlm_host * 46static struct nlm_host *
67nlm_lookup_host(int server, const struct sockaddr_in *sin, 47nlm_lookup_host(int server, const struct sockaddr_in *sin,
68 int proto, int version, 48 int proto, int version,
69 const char *hostname, 49 const char *hostname,
@@ -195,6 +175,29 @@ nlm_destroy_host(struct nlm_host *host)
195} 175}
196 176
197/* 177/*
178 * Find an NLM server handle in the cache. If there is none, create it.
179 */
180struct nlm_host *
181nlmclnt_lookup_host(const struct sockaddr_in *sin, int proto, int version,
182 const char *hostname, int hostname_len)
183{
184 return nlm_lookup_host(0, sin, proto, version,
185 hostname, hostname_len);
186}
187
188/*
189 * Find an NLM client handle in the cache. If there is none, create it.
190 */
191struct nlm_host *
192nlmsvc_lookup_host(struct svc_rqst *rqstp,
193 const char *hostname, int hostname_len)
194{
195 return nlm_lookup_host(1, &rqstp->rq_addr,
196 rqstp->rq_prot, rqstp->rq_vers,
197 hostname, hostname_len);
198}
199
200/*
198 * Create the NLM RPC client for an NLM peer 201 * Create the NLM RPC client for an NLM peer
199 */ 202 */
200struct rpc_clnt * 203struct rpc_clnt *
@@ -495,7 +498,7 @@ out:
495 return nsm; 498 return nsm;
496} 499}
497 500
498struct nsm_handle * 501static struct nsm_handle *
499nsm_find(const struct sockaddr_in *sin, const char *hostname, int hostname_len) 502nsm_find(const struct sockaddr_in *sin, const char *hostname, int hostname_len)
500{ 503{
501 return __nsm_find(sin, hostname, hostname_len, 1); 504 return __nsm_find(sin, hostname, hostname_len, 1);
diff --git a/fs/locks.c b/fs/locks.c
index e0b6a80649a0..1cb0c57fedbd 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -142,12 +142,12 @@ int lease_break_time = 45;
142static LIST_HEAD(file_lock_list); 142static LIST_HEAD(file_lock_list);
143static LIST_HEAD(blocked_list); 143static LIST_HEAD(blocked_list);
144 144
145static kmem_cache_t *filelock_cache __read_mostly; 145static struct kmem_cache *filelock_cache __read_mostly;
146 146
147/* Allocate an empty lock structure. */ 147/* Allocate an empty lock structure. */
148static struct file_lock *locks_alloc_lock(void) 148static struct file_lock *locks_alloc_lock(void)
149{ 149{
150 return kmem_cache_alloc(filelock_cache, SLAB_KERNEL); 150 return kmem_cache_alloc(filelock_cache, GFP_KERNEL);
151} 151}
152 152
153static void locks_release_private(struct file_lock *fl) 153static void locks_release_private(struct file_lock *fl)
@@ -199,7 +199,7 @@ EXPORT_SYMBOL(locks_init_lock);
199 * Initialises the fields of the file lock which are invariant for 199 * Initialises the fields of the file lock which are invariant for
200 * free file_locks. 200 * free file_locks.
201 */ 201 */
202static void init_once(void *foo, kmem_cache_t *cache, unsigned long flags) 202static void init_once(void *foo, struct kmem_cache *cache, unsigned long flags)
203{ 203{
204 struct file_lock *lock = (struct file_lock *) foo; 204 struct file_lock *lock = (struct file_lock *) foo;
205 205
diff --git a/fs/mbcache.c b/fs/mbcache.c
index 0ff71256e65b..deeb9dc062d9 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -85,7 +85,7 @@ struct mb_cache {
85#ifndef MB_CACHE_INDEXES_COUNT 85#ifndef MB_CACHE_INDEXES_COUNT
86 int c_indexes_count; 86 int c_indexes_count;
87#endif 87#endif
88 kmem_cache_t *c_entry_cache; 88 struct kmem_cache *c_entry_cache;
89 struct list_head *c_block_hash; 89 struct list_head *c_block_hash;
90 struct list_head *c_indexes_hash[0]; 90 struct list_head *c_indexes_hash[0];
91}; 91};
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 1e36bae4d0eb..629e09b38c5c 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -51,12 +51,12 @@ static void minix_put_super(struct super_block *sb)
51 return; 51 return;
52} 52}
53 53
54static kmem_cache_t * minix_inode_cachep; 54static struct kmem_cache * minix_inode_cachep;
55 55
56static struct inode *minix_alloc_inode(struct super_block *sb) 56static struct inode *minix_alloc_inode(struct super_block *sb)
57{ 57{
58 struct minix_inode_info *ei; 58 struct minix_inode_info *ei;
59 ei = (struct minix_inode_info *)kmem_cache_alloc(minix_inode_cachep, SLAB_KERNEL); 59 ei = (struct minix_inode_info *)kmem_cache_alloc(minix_inode_cachep, GFP_KERNEL);
60 if (!ei) 60 if (!ei)
61 return NULL; 61 return NULL;
62 return &ei->vfs_inode; 62 return &ei->vfs_inode;
@@ -67,7 +67,7 @@ static void minix_destroy_inode(struct inode *inode)
67 kmem_cache_free(minix_inode_cachep, minix_i(inode)); 67 kmem_cache_free(minix_inode_cachep, minix_i(inode));
68} 68}
69 69
70static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 70static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
71{ 71{
72 struct minix_inode_info *ei = (struct minix_inode_info *) foo; 72 struct minix_inode_info *ei = (struct minix_inode_info *) foo;
73 73
diff --git a/fs/namei.c b/fs/namei.c
index 28d49b301d55..db1bca26d88c 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -249,9 +249,11 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
249 249
250 /* 250 /*
251 * MAY_EXEC on regular files requires special handling: We override 251 * MAY_EXEC on regular files requires special handling: We override
252 * filesystem execute permissions if the mode bits aren't set. 252 * filesystem execute permissions if the mode bits aren't set or
253 * the fs is mounted with the "noexec" flag.
253 */ 254 */
254 if ((mask & MAY_EXEC) && S_ISREG(mode) && !(mode & S_IXUGO)) 255 if ((mask & MAY_EXEC) && S_ISREG(mode) && (!(mode & S_IXUGO) ||
256 (nd && nd->mnt && (nd->mnt->mnt_flags & MNT_NOEXEC))))
255 return -EACCES; 257 return -EACCES;
256 258
257 /* Ordinary permission routines do not understand MAY_APPEND. */ 259 /* Ordinary permission routines do not understand MAY_APPEND. */
@@ -1996,8 +1998,7 @@ asmlinkage long sys_mkdir(const char __user *pathname, int mode)
1996void dentry_unhash(struct dentry *dentry) 1998void dentry_unhash(struct dentry *dentry)
1997{ 1999{
1998 dget(dentry); 2000 dget(dentry);
1999 if (atomic_read(&dentry->d_count)) 2001 shrink_dcache_parent(dentry);
2000 shrink_dcache_parent(dentry);
2001 spin_lock(&dcache_lock); 2002 spin_lock(&dcache_lock);
2002 spin_lock(&dentry->d_lock); 2003 spin_lock(&dentry->d_lock);
2003 if (atomic_read(&dentry->d_count) == 2) 2004 if (atomic_read(&dentry->d_count) == 2)
diff --git a/fs/namespace.c b/fs/namespace.c
index 55442a6cf221..b00ac84ebbdd 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -36,7 +36,7 @@ static int event;
36 36
37static struct list_head *mount_hashtable __read_mostly; 37static struct list_head *mount_hashtable __read_mostly;
38static int hash_mask __read_mostly, hash_bits __read_mostly; 38static int hash_mask __read_mostly, hash_bits __read_mostly;
39static kmem_cache_t *mnt_cache __read_mostly; 39static struct kmem_cache *mnt_cache __read_mostly;
40static struct rw_semaphore namespace_sem; 40static struct rw_semaphore namespace_sem;
41 41
42/* /sys/fs */ 42/* /sys/fs */
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 72dad552aa00..fae53243bb92 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -40,12 +40,12 @@ static void ncp_delete_inode(struct inode *);
40static void ncp_put_super(struct super_block *); 40static void ncp_put_super(struct super_block *);
41static int ncp_statfs(struct dentry *, struct kstatfs *); 41static int ncp_statfs(struct dentry *, struct kstatfs *);
42 42
43static kmem_cache_t * ncp_inode_cachep; 43static struct kmem_cache * ncp_inode_cachep;
44 44
45static struct inode *ncp_alloc_inode(struct super_block *sb) 45static struct inode *ncp_alloc_inode(struct super_block *sb)
46{ 46{
47 struct ncp_inode_info *ei; 47 struct ncp_inode_info *ei;
48 ei = (struct ncp_inode_info *)kmem_cache_alloc(ncp_inode_cachep, SLAB_KERNEL); 48 ei = (struct ncp_inode_info *)kmem_cache_alloc(ncp_inode_cachep, GFP_KERNEL);
49 if (!ei) 49 if (!ei)
50 return NULL; 50 return NULL;
51 return &ei->vfs_inode; 51 return &ei->vfs_inode;
@@ -56,7 +56,7 @@ static void ncp_destroy_inode(struct inode *inode)
56 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); 56 kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode));
57} 57}
58 58
59static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 59static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
60{ 60{
61 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo; 61 struct ncp_inode_info *ei = (struct ncp_inode_info *) foo;
62 62
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 784bbb54e6c1..f9d678f4ae06 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -58,7 +58,7 @@
58 58
59#define NFSDBG_FACILITY NFSDBG_VFS 59#define NFSDBG_FACILITY NFSDBG_VFS
60 60
61static kmem_cache_t *nfs_direct_cachep; 61static struct kmem_cache *nfs_direct_cachep;
62 62
63/* 63/*
64 * This represents a set of asynchronous requests that we're waiting on 64 * This represents a set of asynchronous requests that we're waiting on
@@ -143,7 +143,7 @@ static inline struct nfs_direct_req *nfs_direct_req_alloc(void)
143{ 143{
144 struct nfs_direct_req *dreq; 144 struct nfs_direct_req *dreq;
145 145
146 dreq = kmem_cache_alloc(nfs_direct_cachep, SLAB_KERNEL); 146 dreq = kmem_cache_alloc(nfs_direct_cachep, GFP_KERNEL);
147 if (!dreq) 147 if (!dreq)
148 return NULL; 148 return NULL;
149 149
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 7c32187f953e..36680d1061b0 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -55,7 +55,7 @@ static int nfs_update_inode(struct inode *, struct nfs_fattr *);
55 55
56static void nfs_zap_acl_cache(struct inode *); 56static void nfs_zap_acl_cache(struct inode *);
57 57
58static kmem_cache_t * nfs_inode_cachep; 58static struct kmem_cache * nfs_inode_cachep;
59 59
60static inline unsigned long 60static inline unsigned long
61nfs_fattr_to_ino_t(struct nfs_fattr *fattr) 61nfs_fattr_to_ino_t(struct nfs_fattr *fattr)
@@ -1080,7 +1080,7 @@ void nfs4_clear_inode(struct inode *inode)
1080struct inode *nfs_alloc_inode(struct super_block *sb) 1080struct inode *nfs_alloc_inode(struct super_block *sb)
1081{ 1081{
1082 struct nfs_inode *nfsi; 1082 struct nfs_inode *nfsi;
1083 nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, SLAB_KERNEL); 1083 nfsi = (struct nfs_inode *)kmem_cache_alloc(nfs_inode_cachep, GFP_KERNEL);
1084 if (!nfsi) 1084 if (!nfsi)
1085 return NULL; 1085 return NULL;
1086 nfsi->flags = 0UL; 1086 nfsi->flags = 0UL;
@@ -1111,7 +1111,7 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)
1111#endif 1111#endif
1112} 1112}
1113 1113
1114static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 1114static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
1115{ 1115{
1116 struct nfs_inode *nfsi = (struct nfs_inode *) foo; 1116 struct nfs_inode *nfsi = (struct nfs_inode *) foo;
1117 1117
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index bc9fab68b29c..ca4b1d4ff42b 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -21,13 +21,13 @@
21 21
22#define NFS_PARANOIA 1 22#define NFS_PARANOIA 1
23 23
24static kmem_cache_t *nfs_page_cachep; 24static struct kmem_cache *nfs_page_cachep;
25 25
26static inline struct nfs_page * 26static inline struct nfs_page *
27nfs_page_alloc(void) 27nfs_page_alloc(void)
28{ 28{
29 struct nfs_page *p; 29 struct nfs_page *p;
30 p = kmem_cache_alloc(nfs_page_cachep, SLAB_KERNEL); 30 p = kmem_cache_alloc(nfs_page_cachep, GFP_KERNEL);
31 if (p) { 31 if (p) {
32 memset(p, 0, sizeof(*p)); 32 memset(p, 0, sizeof(*p));
33 INIT_LIST_HEAD(&p->wb_list); 33 INIT_LIST_HEAD(&p->wb_list);
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 05cca6609977..a9c26521a9e2 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -39,7 +39,7 @@ static int nfs_pagein_one(struct list_head *, struct inode *);
39static const struct rpc_call_ops nfs_read_partial_ops; 39static const struct rpc_call_ops nfs_read_partial_ops;
40static const struct rpc_call_ops nfs_read_full_ops; 40static const struct rpc_call_ops nfs_read_full_ops;
41 41
42static kmem_cache_t *nfs_rdata_cachep; 42static struct kmem_cache *nfs_rdata_cachep;
43static mempool_t *nfs_rdata_mempool; 43static mempool_t *nfs_rdata_mempool;
44 44
45#define MIN_POOL_READ (32) 45#define MIN_POOL_READ (32)
@@ -47,7 +47,7 @@ static mempool_t *nfs_rdata_mempool;
47struct nfs_read_data *nfs_readdata_alloc(size_t len) 47struct nfs_read_data *nfs_readdata_alloc(size_t len)
48{ 48{
49 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; 49 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
50 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, SLAB_NOFS); 50 struct nfs_read_data *p = mempool_alloc(nfs_rdata_mempool, GFP_NOFS);
51 51
52 if (p) { 52 if (p) {
53 memset(p, 0, sizeof(*p)); 53 memset(p, 0, sizeof(*p));
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 7f3844d2bf36..594eb16879ef 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -85,7 +85,7 @@ static const struct rpc_call_ops nfs_write_partial_ops;
85static const struct rpc_call_ops nfs_write_full_ops; 85static const struct rpc_call_ops nfs_write_full_ops;
86static const struct rpc_call_ops nfs_commit_ops; 86static const struct rpc_call_ops nfs_commit_ops;
87 87
88static kmem_cache_t *nfs_wdata_cachep; 88static struct kmem_cache *nfs_wdata_cachep;
89static mempool_t *nfs_wdata_mempool; 89static mempool_t *nfs_wdata_mempool;
90static mempool_t *nfs_commit_mempool; 90static mempool_t *nfs_commit_mempool;
91 91
@@ -93,7 +93,7 @@ static DECLARE_WAIT_QUEUE_HEAD(nfs_write_congestion);
93 93
94struct nfs_write_data *nfs_commit_alloc(void) 94struct nfs_write_data *nfs_commit_alloc(void)
95{ 95{
96 struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, SLAB_NOFS); 96 struct nfs_write_data *p = mempool_alloc(nfs_commit_mempool, GFP_NOFS);
97 97
98 if (p) { 98 if (p) {
99 memset(p, 0, sizeof(*p)); 99 memset(p, 0, sizeof(*p));
@@ -118,7 +118,7 @@ void nfs_commit_free(struct nfs_write_data *wdata)
118struct nfs_write_data *nfs_writedata_alloc(size_t len) 118struct nfs_write_data *nfs_writedata_alloc(size_t len)
119{ 119{
120 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; 120 unsigned int pagecount = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
121 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, SLAB_NOFS); 121 struct nfs_write_data *p = mempool_alloc(nfs_wdata_mempool, GFP_NOFS);
122 122
123 if (p) { 123 if (p) {
124 memset(p, 0, sizeof(*p)); 124 memset(p, 0, sizeof(*p));
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index b4baca3053c3..277df40f098d 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -24,10 +24,6 @@
24 24
25#define NFSDDBG_FACILITY NFSDDBG_XDR 25#define NFSDDBG_FACILITY NFSDDBG_XDR
26 26
27#ifdef NFSD_OPTIMIZE_SPACE
28# define inline
29#endif
30
31 27
32/* 28/*
33 * Mapping of S_IF* types to NFS file types 29 * Mapping of S_IF* types to NFS file types
@@ -42,14 +38,14 @@ static u32 nfs3_ftypes[] = {
42/* 38/*
43 * XDR functions for basic NFS types 39 * XDR functions for basic NFS types
44 */ 40 */
45static inline __be32 * 41static __be32 *
46encode_time3(__be32 *p, struct timespec *time) 42encode_time3(__be32 *p, struct timespec *time)
47{ 43{
48 *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec); 44 *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec);
49 return p; 45 return p;
50} 46}
51 47
52static inline __be32 * 48static __be32 *
53decode_time3(__be32 *p, struct timespec *time) 49decode_time3(__be32 *p, struct timespec *time)
54{ 50{
55 time->tv_sec = ntohl(*p++); 51 time->tv_sec = ntohl(*p++);
@@ -57,7 +53,7 @@ decode_time3(__be32 *p, struct timespec *time)
57 return p; 53 return p;
58} 54}
59 55
60static inline __be32 * 56static __be32 *
61decode_fh(__be32 *p, struct svc_fh *fhp) 57decode_fh(__be32 *p, struct svc_fh *fhp)
62{ 58{
63 unsigned int size; 59 unsigned int size;
@@ -77,7 +73,7 @@ __be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp)
77 return decode_fh(p, fhp); 73 return decode_fh(p, fhp);
78} 74}
79 75
80static inline __be32 * 76static __be32 *
81encode_fh(__be32 *p, struct svc_fh *fhp) 77encode_fh(__be32 *p, struct svc_fh *fhp)
82{ 78{
83 unsigned int size = fhp->fh_handle.fh_size; 79 unsigned int size = fhp->fh_handle.fh_size;
@@ -91,7 +87,7 @@ encode_fh(__be32 *p, struct svc_fh *fhp)
91 * Decode a file name and make sure that the path contains 87 * Decode a file name and make sure that the path contains
92 * no slashes or null bytes. 88 * no slashes or null bytes.
93 */ 89 */
94static inline __be32 * 90static __be32 *
95decode_filename(__be32 *p, char **namp, int *lenp) 91decode_filename(__be32 *p, char **namp, int *lenp)
96{ 92{
97 char *name; 93 char *name;
@@ -107,7 +103,7 @@ decode_filename(__be32 *p, char **namp, int *lenp)
107 return p; 103 return p;
108} 104}
109 105
110static inline __be32 * 106static __be32 *
111decode_sattr3(__be32 *p, struct iattr *iap) 107decode_sattr3(__be32 *p, struct iattr *iap)
112{ 108{
113 u32 tmp; 109 u32 tmp;
@@ -153,7 +149,7 @@ decode_sattr3(__be32 *p, struct iattr *iap)
153 return p; 149 return p;
154} 150}
155 151
156static inline __be32 * 152static __be32 *
157encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, 153encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
158 struct kstat *stat) 154 struct kstat *stat)
159{ 155{
@@ -186,7 +182,7 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
186 return p; 182 return p;
187} 183}
188 184
189static inline __be32 * 185static __be32 *
190encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) 186encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
191{ 187{
192 struct inode *inode = fhp->fh_dentry->d_inode; 188 struct inode *inode = fhp->fh_dentry->d_inode;
@@ -776,7 +772,7 @@ nfs3svc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p,
776 return xdr_ressize_check(rqstp, p); 772 return xdr_ressize_check(rqstp, p);
777} 773}
778 774
779static inline __be32 * 775static __be32 *
780encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, 776encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
781 int namlen, ino_t ino) 777 int namlen, ino_t ino)
782{ 778{
@@ -790,7 +786,7 @@ encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
790 return p; 786 return p;
791} 787}
792 788
793static inline __be32 * 789static __be32 *
794encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, 790encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p,
795 struct svc_fh *fhp) 791 struct svc_fh *fhp)
796{ 792{
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index e431e93ab503..640c92b2a9f7 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -84,10 +84,10 @@ static void nfs4_set_recdir(char *recdir);
84 */ 84 */
85static DEFINE_MUTEX(client_mutex); 85static DEFINE_MUTEX(client_mutex);
86 86
87static kmem_cache_t *stateowner_slab = NULL; 87static struct kmem_cache *stateowner_slab = NULL;
88static kmem_cache_t *file_slab = NULL; 88static struct kmem_cache *file_slab = NULL;
89static kmem_cache_t *stateid_slab = NULL; 89static struct kmem_cache *stateid_slab = NULL;
90static kmem_cache_t *deleg_slab = NULL; 90static struct kmem_cache *deleg_slab = NULL;
91 91
92void 92void
93nfs4_lock_state(void) 93nfs4_lock_state(void)
@@ -1003,7 +1003,7 @@ alloc_init_file(struct inode *ino)
1003} 1003}
1004 1004
1005static void 1005static void
1006nfsd4_free_slab(kmem_cache_t **slab) 1006nfsd4_free_slab(struct kmem_cache **slab)
1007{ 1007{
1008 if (*slab == NULL) 1008 if (*slab == NULL)
1009 return; 1009 return;
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index 56ebb1443e0e..f5243f943996 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -18,11 +18,6 @@
18 18
19#define NFSDDBG_FACILITY NFSDDBG_XDR 19#define NFSDDBG_FACILITY NFSDDBG_XDR
20 20
21
22#ifdef NFSD_OPTIMIZE_SPACE
23# define inline
24#endif
25
26/* 21/*
27 * Mapping of S_IF* types to NFS file types 22 * Mapping of S_IF* types to NFS file types
28 */ 23 */
@@ -55,7 +50,7 @@ __be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp)
55 return decode_fh(p, fhp); 50 return decode_fh(p, fhp);
56} 51}
57 52
58static inline __be32 * 53static __be32 *
59encode_fh(__be32 *p, struct svc_fh *fhp) 54encode_fh(__be32 *p, struct svc_fh *fhp)
60{ 55{
61 memcpy(p, &fhp->fh_handle.fh_base, NFS_FHSIZE); 56 memcpy(p, &fhp->fh_handle.fh_base, NFS_FHSIZE);
@@ -66,7 +61,7 @@ encode_fh(__be32 *p, struct svc_fh *fhp)
66 * Decode a file name and make sure that the path contains 61 * Decode a file name and make sure that the path contains
67 * no slashes or null bytes. 62 * no slashes or null bytes.
68 */ 63 */
69static inline __be32 * 64static __be32 *
70decode_filename(__be32 *p, char **namp, int *lenp) 65decode_filename(__be32 *p, char **namp, int *lenp)
71{ 66{
72 char *name; 67 char *name;
@@ -82,7 +77,7 @@ decode_filename(__be32 *p, char **namp, int *lenp)
82 return p; 77 return p;
83} 78}
84 79
85static inline __be32 * 80static __be32 *
86decode_pathname(__be32 *p, char **namp, int *lenp) 81decode_pathname(__be32 *p, char **namp, int *lenp)
87{ 82{
88 char *name; 83 char *name;
@@ -98,7 +93,7 @@ decode_pathname(__be32 *p, char **namp, int *lenp)
98 return p; 93 return p;
99} 94}
100 95
101static inline __be32 * 96static __be32 *
102decode_sattr(__be32 *p, struct iattr *iap) 97decode_sattr(__be32 *p, struct iattr *iap)
103{ 98{
104 u32 tmp, tmp1; 99 u32 tmp, tmp1;
diff --git a/fs/nls/nls_cp936.c b/fs/nls/nls_cp936.c
index 046fde8170ea..65e640c61c8b 100644
--- a/fs/nls/nls_cp936.c
+++ b/fs/nls/nls_cp936.c
@@ -4421,6 +4421,73 @@ static wchar_t *page_charset2uni[256] = {
4421 c2u_F8, c2u_F9, c2u_FA, c2u_FB, c2u_FC, c2u_FD, c2u_FE, NULL, 4421 c2u_F8, c2u_F9, c2u_FA, c2u_FB, c2u_FC, c2u_FD, c2u_FE, NULL,
4422}; 4422};
4423 4423
4424static unsigned char u2c_00[512] = {
4425 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */
4426 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */
4427 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0B */
4428 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x0C-0x0F */
4429 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x13 */
4430 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x14-0x17 */
4431 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1B */
4432 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x1C-0x1F */
4433 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x23 */
4434 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x24-0x27 */
4435 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2B */
4436 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x2C-0x2F */
4437 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x33 */
4438 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x34-0x37 */
4439 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3B */
4440 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x3C-0x3F */
4441 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x43 */
4442 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x44-0x47 */
4443 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4B */
4444 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x4C-0x4F */
4445 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x53 */
4446 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x54-0x57 */
4447 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5B */
4448 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x5C-0x5F */
4449 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x63 */
4450 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x64-0x67 */
4451 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6B */
4452 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x6C-0x6F */
4453 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x73 */
4454 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x74-0x77 */
4455 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7B */
4456 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x7C-0x7F */
4457 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x83 */
4458 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x84-0x87 */
4459 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8B */
4460 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x8C-0x8F */
4461 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x93 */
4462 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x94-0x97 */
4463 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9B */
4464 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x9C-0x9F */
4465 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA0-0xA3 */
4466 0xA1, 0xE8, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xEC, /* 0xA4-0xA7 */
4467 0xA1, 0xA7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xA8-0xAB */
4468 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xAC-0xAF */
4469 0xA1, 0xE3, 0xA1, 0xC0, 0x00, 0x00, 0x00, 0x00, /* 0xB0-0xB3 */
4470 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xA4, /* 0xB4-0xB7 */
4471 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xB8-0xBB */
4472 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xBC-0xBF */
4473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC0-0xC3 */
4474 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC4-0xC7 */
4475 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xC8-0xCB */
4476 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xCC-0xCF */
4477 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD0-0xD3 */
4478 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xC1, /* 0xD4-0xD7 */
4479 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xD8-0xDB */
4480 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xDC-0xDF */
4481 0xA8, 0xA4, 0xA8, 0xA2, 0x00, 0x00, 0x00, 0x00, /* 0xE0-0xE3 */
4482 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xE4-0xE7 */
4483 0xA8, 0xA8, 0xA8, 0xA6, 0xA8, 0xBA, 0x00, 0x00, /* 0xE8-0xEB */
4484 0xA8, 0xAC, 0xA8, 0xAA, 0x00, 0x00, 0x00, 0x00, /* 0xEC-0xEF */
4485 0x00, 0x00, 0x00, 0x00, 0xA8, 0xB0, 0xA8, 0xAE, /* 0xF0-0xF3 */
4486 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA1, 0xC2, /* 0xF4-0xF7 */
4487 0x00, 0x00, 0xA8, 0xB4, 0xA8, 0xB2, 0x00, 0x00, /* 0xF8-0xFB */
4488 0xA8, 0xB9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xFC-0xFF */
4489};
4490
4424static unsigned char u2c_01[512] = { 4491static unsigned char u2c_01[512] = {
4425 0xA8, 0xA1, 0xA8, 0xA1, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */ 4492 0xA8, 0xA1, 0xA8, 0xA1, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x03 */
4426 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */ 4493 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x04-0x07 */
@@ -10825,7 +10892,7 @@ static unsigned char u2c_FF[512] = {
10825}; 10892};
10826 10893
10827static unsigned char *page_uni2charset[256] = { 10894static unsigned char *page_uni2charset[256] = {
10828 NULL, u2c_01, u2c_02, u2c_03, u2c_04, NULL, NULL, NULL, 10895 u2c_00, u2c_01, u2c_02, u2c_03, u2c_04, NULL, NULL, NULL,
10829 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10896 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
10830 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10897 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
10831 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10898 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@@ -10936,11 +11003,34 @@ static int uni2char(const wchar_t uni,
10936 unsigned char *uni2charset; 11003 unsigned char *uni2charset;
10937 unsigned char cl = uni&0xFF; 11004 unsigned char cl = uni&0xFF;
10938 unsigned char ch = (uni>>8)&0xFF; 11005 unsigned char ch = (uni>>8)&0xFF;
10939 int n; 11006 unsigned char out0,out1;
10940 11007
10941 if (boundlen <= 0) 11008 if (boundlen <= 0)
10942 return -ENAMETOOLONG; 11009 return -ENAMETOOLONG;
10943 11010
11011 if (uni == 0x20ac) {/* Euro symbol.The only exception with a non-ascii unicode */
11012 out[0] = 0x80;
11013 return 1;
11014 }
11015
11016 if (ch == 0) { /* handle the U00 plane*/
11017 /* if (cl == 0) return -EINVAL;*/ /*U0000 is legal in cp936*/
11018 out0 = u2c_00[cl*2];
11019 out1 = u2c_00[cl*2+1];
11020 if (out0 == 0x00 && out1 == 0x00) {
11021 if (cl<0x80) {
11022 out[0] = cl;
11023 return 1;
11024 }
11025 return -EINVAL;
11026 } else {
11027 if (boundlen <= 1)
11028 return -ENAMETOOLONG;
11029 out[0] = out0;
11030 out[1] = out1;
11031 return 2;
11032 }
11033 }
10944 11034
10945 uni2charset = page_uni2charset[ch]; 11035 uni2charset = page_uni2charset[ch];
10946 if (uni2charset) { 11036 if (uni2charset) {
@@ -10950,15 +11040,10 @@ static int uni2char(const wchar_t uni,
10950 out[1] = uni2charset[cl*2+1]; 11040 out[1] = uni2charset[cl*2+1];
10951 if (out[0] == 0x00 && out[1] == 0x00) 11041 if (out[0] == 0x00 && out[1] == 0x00)
10952 return -EINVAL; 11042 return -EINVAL;
10953 n = 2; 11043 return 2;
10954 } else if (ch==0 && cl) {
10955 out[0] = cl;
10956 n = 1;
10957 } 11044 }
10958 else 11045 else
10959 return -EINVAL; 11046 return -EINVAL;
10960
10961 return n;
10962} 11047}
10963 11048
10964static int char2uni(const unsigned char *rawstring, int boundlen, 11049static int char2uni(const unsigned char *rawstring, int boundlen,
@@ -10972,7 +11057,11 @@ static int char2uni(const unsigned char *rawstring, int boundlen,
10972 return -ENAMETOOLONG; 11057 return -ENAMETOOLONG;
10973 11058
10974 if (boundlen == 1) { 11059 if (boundlen == 1) {
10975 *uni = rawstring[0]; 11060 if (rawstring[0]==0x80) { /* Euro symbol.The only exception with a non-ascii unicode */
11061 *uni = 0x20ac;
11062 } else {
11063 *uni = rawstring[0];
11064 }
10976 return 1; 11065 return 1;
10977 } 11066 }
10978 11067
@@ -10986,7 +11075,11 @@ static int char2uni(const unsigned char *rawstring, int boundlen,
10986 return -EINVAL; 11075 return -EINVAL;
10987 n = 2; 11076 n = 2;
10988 } else{ 11077 } else{
10989 *uni = ch; 11078 if (ch==0x80) {/* Euro symbol.The only exception with a non-ascii unicode */
11079 *uni = 0x20ac;
11080 } else {
11081 *uni = ch;
11082 }
10990 n = 1; 11083 n = 1;
10991 } 11084 }
10992 return n; 11085 return n;
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 9f08e851cfb6..c577d8e1bd95 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -1272,7 +1272,7 @@ ntfs_attr_search_ctx *ntfs_attr_get_search_ctx(ntfs_inode *ni, MFT_RECORD *mrec)
1272{ 1272{
1273 ntfs_attr_search_ctx *ctx; 1273 ntfs_attr_search_ctx *ctx;
1274 1274
1275 ctx = kmem_cache_alloc(ntfs_attr_ctx_cache, SLAB_NOFS); 1275 ctx = kmem_cache_alloc(ntfs_attr_ctx_cache, GFP_NOFS);
1276 if (ctx) 1276 if (ctx)
1277 ntfs_attr_init_search_ctx(ctx, ni, mrec); 1277 ntfs_attr_init_search_ctx(ctx, ni, mrec);
1278 return ctx; 1278 return ctx;
diff --git a/fs/ntfs/index.c b/fs/ntfs/index.c
index e32cde486362..2194eff49743 100644
--- a/fs/ntfs/index.c
+++ b/fs/ntfs/index.c
@@ -38,7 +38,7 @@ ntfs_index_context *ntfs_index_ctx_get(ntfs_inode *idx_ni)
38{ 38{
39 ntfs_index_context *ictx; 39 ntfs_index_context *ictx;
40 40
41 ictx = kmem_cache_alloc(ntfs_index_ctx_cache, SLAB_NOFS); 41 ictx = kmem_cache_alloc(ntfs_index_ctx_cache, GFP_NOFS);
42 if (ictx) 42 if (ictx)
43 *ictx = (ntfs_index_context){ .idx_ni = idx_ni }; 43 *ictx = (ntfs_index_context){ .idx_ni = idx_ni };
44 return ictx; 44 return ictx;
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 2d3de9c89818..247989891b4b 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -324,7 +324,7 @@ struct inode *ntfs_alloc_big_inode(struct super_block *sb)
324 ntfs_inode *ni; 324 ntfs_inode *ni;
325 325
326 ntfs_debug("Entering."); 326 ntfs_debug("Entering.");
327 ni = kmem_cache_alloc(ntfs_big_inode_cache, SLAB_NOFS); 327 ni = kmem_cache_alloc(ntfs_big_inode_cache, GFP_NOFS);
328 if (likely(ni != NULL)) { 328 if (likely(ni != NULL)) {
329 ni->state = 0; 329 ni->state = 0;
330 return VFS_I(ni); 330 return VFS_I(ni);
@@ -349,7 +349,7 @@ static inline ntfs_inode *ntfs_alloc_extent_inode(void)
349 ntfs_inode *ni; 349 ntfs_inode *ni;
350 350
351 ntfs_debug("Entering."); 351 ntfs_debug("Entering.");
352 ni = kmem_cache_alloc(ntfs_inode_cache, SLAB_NOFS); 352 ni = kmem_cache_alloc(ntfs_inode_cache, GFP_NOFS);
353 if (likely(ni != NULL)) { 353 if (likely(ni != NULL)) {
354 ni->state = 0; 354 ni->state = 0;
355 return ni; 355 return ni;
diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c
index 6a495f7369f9..005ca4b0f132 100644
--- a/fs/ntfs/unistr.c
+++ b/fs/ntfs/unistr.c
@@ -266,7 +266,7 @@ int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins,
266 266
267 /* We do not trust outside sources. */ 267 /* We do not trust outside sources. */
268 if (likely(ins)) { 268 if (likely(ins)) {
269 ucs = kmem_cache_alloc(ntfs_name_cache, SLAB_NOFS); 269 ucs = kmem_cache_alloc(ntfs_name_cache, GFP_NOFS);
270 if (likely(ucs)) { 270 if (likely(ucs)) {
271 for (i = o = 0; i < ins_len; i += wc_len) { 271 for (i = o = 0; i < ins_len; i += wc_len) {
272 wc_len = nls->char2uni(ins + i, ins_len - i, 272 wc_len = nls->char2uni(ins + i, ins_len - i,
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index 16b8d1ba7066..941acf14e61f 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -66,7 +66,7 @@ static struct file_operations dlmfs_file_operations;
66static struct inode_operations dlmfs_dir_inode_operations; 66static struct inode_operations dlmfs_dir_inode_operations;
67static struct inode_operations dlmfs_root_inode_operations; 67static struct inode_operations dlmfs_root_inode_operations;
68static struct inode_operations dlmfs_file_inode_operations; 68static struct inode_operations dlmfs_file_inode_operations;
69static kmem_cache_t *dlmfs_inode_cache; 69static struct kmem_cache *dlmfs_inode_cache;
70 70
71struct workqueue_struct *user_dlm_worker; 71struct workqueue_struct *user_dlm_worker;
72 72
@@ -257,7 +257,7 @@ static ssize_t dlmfs_file_write(struct file *filp,
257} 257}
258 258
259static void dlmfs_init_once(void *foo, 259static void dlmfs_init_once(void *foo,
260 kmem_cache_t *cachep, 260 struct kmem_cache *cachep,
261 unsigned long flags) 261 unsigned long flags)
262{ 262{
263 struct dlmfs_inode_private *ip = 263 struct dlmfs_inode_private *ip =
@@ -276,7 +276,7 @@ static struct inode *dlmfs_alloc_inode(struct super_block *sb)
276{ 276{
277 struct dlmfs_inode_private *ip; 277 struct dlmfs_inode_private *ip;
278 278
279 ip = kmem_cache_alloc(dlmfs_inode_cache, SLAB_NOFS); 279 ip = kmem_cache_alloc(dlmfs_inode_cache, GFP_NOFS);
280 if (!ip) 280 if (!ip)
281 return NULL; 281 return NULL;
282 282
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index f784177b6241..856012b4fa49 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(dlm_dump_all_mles);
221#endif /* 0 */ 221#endif /* 0 */
222 222
223 223
224static kmem_cache_t *dlm_mle_cache = NULL; 224static struct kmem_cache *dlm_mle_cache = NULL;
225 225
226 226
227static void dlm_mle_release(struct kref *kref); 227static void dlm_mle_release(struct kref *kref);
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index fcd4475d1f89..80ac69f11d9f 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -61,7 +61,7 @@ struct ocfs2_em_insert_context {
61 struct ocfs2_extent_map_entry *right_ent; 61 struct ocfs2_extent_map_entry *right_ent;
62}; 62};
63 63
64static kmem_cache_t *ocfs2_em_ent_cachep = NULL; 64static struct kmem_cache *ocfs2_em_ent_cachep = NULL;
65 65
66 66
67static struct ocfs2_extent_map_entry * 67static struct ocfs2_extent_map_entry *
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index 46a378fbc40b..1a7dd2945b34 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -106,7 +106,7 @@ static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode)
106#define INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags & OCFS2_INODE_JOURNAL) 106#define INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags & OCFS2_INODE_JOURNAL)
107#define SET_INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags |= OCFS2_INODE_JOURNAL) 107#define SET_INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags |= OCFS2_INODE_JOURNAL)
108 108
109extern kmem_cache_t *ocfs2_inode_cache; 109extern struct kmem_cache *ocfs2_inode_cache;
110 110
111extern const struct address_space_operations ocfs2_aops; 111extern const struct address_space_operations ocfs2_aops;
112 112
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index d9b4214a12da..4bf39540e652 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -68,7 +68,7 @@
68 68
69#include "buffer_head_io.h" 69#include "buffer_head_io.h"
70 70
71static kmem_cache_t *ocfs2_inode_cachep = NULL; 71static struct kmem_cache *ocfs2_inode_cachep = NULL;
72 72
73/* OCFS2 needs to schedule several differnt types of work which 73/* OCFS2 needs to schedule several differnt types of work which
74 * require cluster locking, disk I/O, recovery waits, etc. Since these 74 * require cluster locking, disk I/O, recovery waits, etc. Since these
@@ -303,7 +303,7 @@ static struct inode *ocfs2_alloc_inode(struct super_block *sb)
303{ 303{
304 struct ocfs2_inode_info *oi; 304 struct ocfs2_inode_info *oi;
305 305
306 oi = kmem_cache_alloc(ocfs2_inode_cachep, SLAB_NOFS); 306 oi = kmem_cache_alloc(ocfs2_inode_cachep, GFP_NOFS);
307 if (!oi) 307 if (!oi)
308 return NULL; 308 return NULL;
309 309
@@ -914,7 +914,7 @@ bail:
914} 914}
915 915
916static void ocfs2_inode_init_once(void *data, 916static void ocfs2_inode_init_once(void *data,
917 kmem_cache_t *cachep, 917 struct kmem_cache *cachep,
918 unsigned long flags) 918 unsigned long flags)
919{ 919{
920 struct ocfs2_inode_info *oi = data; 920 struct ocfs2_inode_info *oi = data;
@@ -1674,7 +1674,7 @@ void __ocfs2_error(struct super_block *sb,
1674 va_list args; 1674 va_list args;
1675 1675
1676 va_start(args, fmt); 1676 va_start(args, fmt);
1677 vsprintf(error_buf, fmt, args); 1677 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1678 va_end(args); 1678 va_end(args);
1679 1679
1680 /* Not using mlog here because we want to show the actual 1680 /* Not using mlog here because we want to show the actual
@@ -1695,7 +1695,7 @@ void __ocfs2_abort(struct super_block* sb,
1695 va_list args; 1695 va_list args;
1696 1696
1697 va_start(args, fmt); 1697 va_start(args, fmt);
1698 vsprintf(error_buf, fmt, args); 1698 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1699 va_end(args); 1699 va_end(args);
1700 1700
1701 printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n", 1701 printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n",
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c
index 9707ed7a3206..39814b900fc0 100644
--- a/fs/ocfs2/uptodate.c
+++ b/fs/ocfs2/uptodate.c
@@ -69,7 +69,7 @@ struct ocfs2_meta_cache_item {
69 sector_t c_block; 69 sector_t c_block;
70}; 70};
71 71
72static kmem_cache_t *ocfs2_uptodate_cachep = NULL; 72static struct kmem_cache *ocfs2_uptodate_cachep = NULL;
73 73
74void ocfs2_metadata_cache_init(struct inode *inode) 74void ocfs2_metadata_cache_init(struct inode *inode)
75{ 75{
diff --git a/fs/openpromfs/inode.c b/fs/openpromfs/inode.c
index 592a6402e851..26f44e0074ec 100644
--- a/fs/openpromfs/inode.c
+++ b/fs/openpromfs/inode.c
@@ -330,13 +330,13 @@ out:
330 return 0; 330 return 0;
331} 331}
332 332
333static kmem_cache_t *op_inode_cachep; 333static struct kmem_cache *op_inode_cachep;
334 334
335static struct inode *openprom_alloc_inode(struct super_block *sb) 335static struct inode *openprom_alloc_inode(struct super_block *sb)
336{ 336{
337 struct op_inode_info *oi; 337 struct op_inode_info *oi;
338 338
339 oi = kmem_cache_alloc(op_inode_cachep, SLAB_KERNEL); 339 oi = kmem_cache_alloc(op_inode_cachep, GFP_KERNEL);
340 if (!oi) 340 if (!oi)
341 return NULL; 341 return NULL;
342 342
@@ -415,7 +415,7 @@ static struct file_system_type openprom_fs_type = {
415 .kill_sb = kill_anon_super, 415 .kill_sb = kill_anon_super,
416}; 416};
417 417
418static void op_inode_init_once(void *data, kmem_cache_t * cachep, unsigned long flags) 418static void op_inode_init_once(void *data, struct kmem_cache * cachep, unsigned long flags)
419{ 419{
420 struct op_inode_info *oi = (struct op_inode_info *) data; 420 struct op_inode_info *oi = (struct op_inode_info *) data;
421 421
diff --git a/fs/partitions/amiga.c b/fs/partitions/amiga.c
index 3068528890a6..9917a8c360f2 100644
--- a/fs/partitions/amiga.c
+++ b/fs/partitions/amiga.c
@@ -43,6 +43,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
43 if (warn_no_part) 43 if (warn_no_part)
44 printk("Dev %s: unable to read RDB block %d\n", 44 printk("Dev %s: unable to read RDB block %d\n",
45 bdevname(bdev, b), blk); 45 bdevname(bdev, b), blk);
46 res = -1;
46 goto rdb_done; 47 goto rdb_done;
47 } 48 }
48 if (*(__be32 *)data != cpu_to_be32(IDNAME_RIGIDDISK)) 49 if (*(__be32 *)data != cpu_to_be32(IDNAME_RIGIDDISK))
@@ -79,6 +80,7 @@ amiga_partition(struct parsed_partitions *state, struct block_device *bdev)
79 if (warn_no_part) 80 if (warn_no_part)
80 printk("Dev %s: unable to read partition block %d\n", 81 printk("Dev %s: unable to read partition block %d\n",
81 bdevname(bdev, b), blk); 82 bdevname(bdev, b), blk);
83 res = -1;
82 goto rdb_done; 84 goto rdb_done;
83 } 85 }
84 pb = (struct PartitionBlock *)data; 86 pb = (struct PartitionBlock *)data;
diff --git a/fs/partitions/atari.c b/fs/partitions/atari.c
index 192a6adfdefd..1f3572d5b755 100644
--- a/fs/partitions/atari.c
+++ b/fs/partitions/atari.c
@@ -88,7 +88,7 @@ int atari_partition(struct parsed_partitions *state, struct block_device *bdev)
88 if (!xrs) { 88 if (!xrs) {
89 printk (" block %ld read failed\n", partsect); 89 printk (" block %ld read failed\n", partsect);
90 put_dev_sector(sect); 90 put_dev_sector(sect);
91 return 0; 91 return -1;
92 } 92 }
93 93
94 /* ++roman: sanity check: bit 0 of flg field must be set */ 94 /* ++roman: sanity check: bit 0 of flg field must be set */
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 6fb4b6150d77..1901137f4eca 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -153,7 +153,7 @@ static struct parsed_partitions *
153check_partition(struct gendisk *hd, struct block_device *bdev) 153check_partition(struct gendisk *hd, struct block_device *bdev)
154{ 154{
155 struct parsed_partitions *state; 155 struct parsed_partitions *state;
156 int i, res; 156 int i, res, err;
157 157
158 state = kmalloc(sizeof(struct parsed_partitions), GFP_KERNEL); 158 state = kmalloc(sizeof(struct parsed_partitions), GFP_KERNEL);
159 if (!state) 159 if (!state)
@@ -165,19 +165,30 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
165 sprintf(state->name, "p"); 165 sprintf(state->name, "p");
166 166
167 state->limit = hd->minors; 167 state->limit = hd->minors;
168 i = res = 0; 168 i = res = err = 0;
169 while (!res && check_part[i]) { 169 while (!res && check_part[i]) {
170 memset(&state->parts, 0, sizeof(state->parts)); 170 memset(&state->parts, 0, sizeof(state->parts));
171 res = check_part[i++](state, bdev); 171 res = check_part[i++](state, bdev);
172 if (res < 0) {
173 /* We have hit an I/O error which we don't report now.
174 * But record it, and let the others do their job.
175 */
176 err = res;
177 res = 0;
178 }
179
172 } 180 }
173 if (res > 0) 181 if (res > 0)
174 return state; 182 return state;
183 if (!err)
184 /* The partition is unrecognized. So report I/O errors if there were any */
185 res = err;
175 if (!res) 186 if (!res)
176 printk(" unknown partition table\n"); 187 printk(" unknown partition table\n");
177 else if (warn_no_part) 188 else if (warn_no_part)
178 printk(" unable to read partition table\n"); 189 printk(" unable to read partition table\n");
179 kfree(state); 190 kfree(state);
180 return NULL; 191 return ERR_PTR(res);
181} 192}
182 193
183/* 194/*
@@ -494,6 +505,8 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
494 disk->fops->revalidate_disk(disk); 505 disk->fops->revalidate_disk(disk);
495 if (!get_capacity(disk) || !(state = check_partition(disk, bdev))) 506 if (!get_capacity(disk) || !(state = check_partition(disk, bdev)))
496 return 0; 507 return 0;
508 if (IS_ERR(state)) /* I/O error reading the partition table */
509 return PTR_ERR(state);
497 for (p = 1; p < state->limit; p++) { 510 for (p = 1; p < state->limit; p++) {
498 sector_t size = state->parts[p].size; 511 sector_t size = state->parts[p].size;
499 sector_t from = state->parts[p].from; 512 sector_t from = state->parts[p].from;
diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c
index d352a7381fed..9f7ad4244f63 100644
--- a/fs/partitions/ibm.c
+++ b/fs/partitions/ibm.c
@@ -43,7 +43,7 @@ cchhb2blk (struct vtoc_cchhb *ptr, struct hd_geometry *geo) {
43int 43int
44ibm_partition(struct parsed_partitions *state, struct block_device *bdev) 44ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
45{ 45{
46 int blocksize, offset, size; 46 int blocksize, offset, size,res;
47 loff_t i_size; 47 loff_t i_size;
48 dasd_information_t *info; 48 dasd_information_t *info;
49 struct hd_geometry *geo; 49 struct hd_geometry *geo;
@@ -56,15 +56,16 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
56 unsigned char *data; 56 unsigned char *data;
57 Sector sect; 57 Sector sect;
58 58
59 res = 0;
59 blocksize = bdev_hardsect_size(bdev); 60 blocksize = bdev_hardsect_size(bdev);
60 if (blocksize <= 0) 61 if (blocksize <= 0)
61 return 0; 62 goto out_exit;
62 i_size = i_size_read(bdev->bd_inode); 63 i_size = i_size_read(bdev->bd_inode);
63 if (i_size == 0) 64 if (i_size == 0)
64 return 0; 65 goto out_exit;
65 66
66 if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL) 67 if ((info = kmalloc(sizeof(dasd_information_t), GFP_KERNEL)) == NULL)
67 goto out_noinfo; 68 goto out_exit;
68 if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL) 69 if ((geo = kmalloc(sizeof(struct hd_geometry), GFP_KERNEL)) == NULL)
69 goto out_nogeo; 70 goto out_nogeo;
70 if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL) 71 if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL)
@@ -72,7 +73,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
72 73
73 if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 || 74 if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 ||
74 ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0) 75 ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0)
75 goto out_noioctl; 76 goto out_freeall;
76 77
77 /* 78 /*
78 * Get volume label, extract name and type. 79 * Get volume label, extract name and type.
@@ -92,6 +93,8 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
92 EBCASC(type, 4); 93 EBCASC(type, 4);
93 EBCASC(name, 6); 94 EBCASC(name, 6);
94 95
96 res = 1;
97
95 /* 98 /*
96 * Three different types: CMS1, VOL1 and LNX1/unlabeled 99 * Three different types: CMS1, VOL1 and LNX1/unlabeled
97 */ 100 */
@@ -156,6 +159,9 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
156 counter++; 159 counter++;
157 blk++; 160 blk++;
158 } 161 }
162 if (!data)
163 /* Are we not supposed to report this ? */
164 goto out_readerr;
159 } else { 165 } else {
160 /* 166 /*
161 * Old style LNX1 or unlabeled disk 167 * Old style LNX1 or unlabeled disk
@@ -171,18 +177,17 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
171 } 177 }
172 178
173 printk("\n"); 179 printk("\n");
174 kfree(label); 180 goto out_freeall;
175 kfree(geo); 181
176 kfree(info);
177 return 1;
178 182
179out_readerr: 183out_readerr:
180out_noioctl: 184 res = -1;
185out_freeall:
181 kfree(label); 186 kfree(label);
182out_nolab: 187out_nolab:
183 kfree(geo); 188 kfree(geo);
184out_nogeo: 189out_nogeo:
185 kfree(info); 190 kfree(info);
186out_noinfo: 191out_exit:
187 return 0; 192 return res;
188} 193}
diff --git a/fs/pipe.c b/fs/pipe.c
index b1626f269a34..ae36b89b1a37 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -830,7 +830,14 @@ void free_pipe_info(struct inode *inode)
830static struct vfsmount *pipe_mnt __read_mostly; 830static struct vfsmount *pipe_mnt __read_mostly;
831static int pipefs_delete_dentry(struct dentry *dentry) 831static int pipefs_delete_dentry(struct dentry *dentry)
832{ 832{
833 return 1; 833 /*
834 * At creation time, we pretended this dentry was hashed
835 * (by clearing DCACHE_UNHASHED bit in d_flags)
836 * At delete time, we restore the truth : not hashed.
837 * (so that dput() can proceed correctly)
838 */
839 dentry->d_flags |= DCACHE_UNHASHED;
840 return 0;
834} 841}
835 842
836static struct dentry_operations pipefs_dentry_operations = { 843static struct dentry_operations pipefs_dentry_operations = {
@@ -891,17 +898,22 @@ struct file *create_write_pipe(void)
891 if (!inode) 898 if (!inode)
892 goto err_file; 899 goto err_file;
893 900
894 sprintf(name, "[%lu]", inode->i_ino); 901 this.len = sprintf(name, "[%lu]", inode->i_ino);
895 this.name = name; 902 this.name = name;
896 this.len = strlen(name); 903 this.hash = 0;
897 this.hash = inode->i_ino; /* will go */
898 err = -ENOMEM; 904 err = -ENOMEM;
899 dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this); 905 dentry = d_alloc(pipe_mnt->mnt_sb->s_root, &this);
900 if (!dentry) 906 if (!dentry)
901 goto err_inode; 907 goto err_inode;
902 908
903 dentry->d_op = &pipefs_dentry_operations; 909 dentry->d_op = &pipefs_dentry_operations;
904 d_add(dentry, inode); 910 /*
911 * We dont want to publish this dentry into global dentry hash table.
912 * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
913 * This permits a working /proc/$pid/fd/XXX on pipes
914 */
915 dentry->d_flags &= ~DCACHE_UNHASHED;
916 d_instantiate(dentry, inode);
905 f->f_vfsmnt = mntget(pipe_mnt); 917 f->f_vfsmnt = mntget(pipe_mnt);
906 f->f_dentry = dentry; 918 f->f_dentry = dentry;
907 f->f_mapping = inode->i_mapping; 919 f->f_mapping = inode->i_mapping;
diff --git a/fs/proc/Makefile b/fs/proc/Makefile
index 7431d7ba2d09..f6c776272572 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 kmsg.o proc_tty.o proc_misc.o 11 proc_tty.o proc_misc.o
12 12
13proc-$(CONFIG_PROC_KCORE) += kcore.o 13proc-$(CONFIG_PROC_KCORE) += kcore.o
14proc-$(CONFIG_PROC_VMCORE) += vmcore.o 14proc-$(CONFIG_PROC_VMCORE) += vmcore.o
15proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o 15proc-$(CONFIG_PROC_DEVICETREE) += proc_devtree.o
16proc-$(CONFIG_PRINTK) += kmsg.o
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 795319c54f72..b859fc749c07 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -683,8 +683,6 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
683 char buffer[PROC_NUMBUF], *end; 683 char buffer[PROC_NUMBUF], *end;
684 int oom_adjust; 684 int oom_adjust;
685 685
686 if (!capable(CAP_SYS_RESOURCE))
687 return -EPERM;
688 memset(buffer, 0, sizeof(buffer)); 686 memset(buffer, 0, sizeof(buffer));
689 if (count > sizeof(buffer) - 1) 687 if (count > sizeof(buffer) - 1)
690 count = sizeof(buffer) - 1; 688 count = sizeof(buffer) - 1;
@@ -699,6 +697,10 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
699 task = get_proc_task(file->f_dentry->d_inode); 697 task = get_proc_task(file->f_dentry->d_inode);
700 if (!task) 698 if (!task)
701 return -ESRCH; 699 return -ESRCH;
700 if (oom_adjust < task->oomkilladj && !capable(CAP_SYS_RESOURCE)) {
701 put_task_struct(task);
702 return -EACCES;
703 }
702 task->oomkilladj = oom_adjust; 704 task->oomkilladj = oom_adjust;
703 put_task_struct(task); 705 put_task_struct(task);
704 if (end - buffer == 0) 706 if (end - buffer == 0)
@@ -1883,8 +1885,9 @@ out:
1883 return; 1885 return;
1884} 1886}
1885 1887
1886struct dentry *proc_pid_instantiate(struct inode *dir, 1888static struct dentry *proc_pid_instantiate(struct inode *dir,
1887 struct dentry * dentry, struct task_struct *task, void *ptr) 1889 struct dentry * dentry,
1890 struct task_struct *task, void *ptr)
1888{ 1891{
1889 struct dentry *error = ERR_PTR(-ENOENT); 1892 struct dentry *error = ERR_PTR(-ENOENT);
1890 struct inode *inode; 1893 struct inode *inode;
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 49dfb2ab783e..e26945ba685b 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -81,14 +81,14 @@ static void proc_read_inode(struct inode * inode)
81 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 81 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
82} 82}
83 83
84static kmem_cache_t * proc_inode_cachep; 84static struct kmem_cache * proc_inode_cachep;
85 85
86static struct inode *proc_alloc_inode(struct super_block *sb) 86static struct inode *proc_alloc_inode(struct super_block *sb)
87{ 87{
88 struct proc_inode *ei; 88 struct proc_inode *ei;
89 struct inode *inode; 89 struct inode *inode;
90 90
91 ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, SLAB_KERNEL); 91 ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, GFP_KERNEL);
92 if (!ei) 92 if (!ei)
93 return NULL; 93 return NULL;
94 ei->pid = NULL; 94 ei->pid = NULL;
@@ -105,7 +105,7 @@ static void proc_destroy_inode(struct inode *inode)
105 kmem_cache_free(proc_inode_cachep, PROC_I(inode)); 105 kmem_cache_free(proc_inode_cachep, PROC_I(inode));
106} 106}
107 107
108static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 108static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
109{ 109{
110 struct proc_inode *ei = (struct proc_inode *) foo; 110 struct proc_inode *ei = (struct proc_inode *) foo;
111 111
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 1294eda4acae..1be73082edd3 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -22,6 +22,7 @@
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23#include <asm/io.h> 23#include <asm/io.h>
24 24
25#define CORE_STR "CORE"
25 26
26static int open_kcore(struct inode * inode, struct file * filp) 27static int open_kcore(struct inode * inode, struct file * filp)
27{ 28{
@@ -82,10 +83,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
82 } 83 }
83 *elf_buflen = sizeof(struct elfhdr) + 84 *elf_buflen = sizeof(struct elfhdr) +
84 (*nphdr + 2)*sizeof(struct elf_phdr) + 85 (*nphdr + 2)*sizeof(struct elf_phdr) +
85 3 * (sizeof(struct elf_note) + 4) + 86 3 * ((sizeof(struct elf_note)) +
86 sizeof(struct elf_prstatus) + 87 roundup(sizeof(CORE_STR), 4)) +
87 sizeof(struct elf_prpsinfo) + 88 roundup(sizeof(struct elf_prstatus), 4) +
88 sizeof(struct task_struct); 89 roundup(sizeof(struct elf_prpsinfo), 4) +
90 roundup(sizeof(struct task_struct), 4);
89 *elf_buflen = PAGE_ALIGN(*elf_buflen); 91 *elf_buflen = PAGE_ALIGN(*elf_buflen);
90 return size + *elf_buflen; 92 return size + *elf_buflen;
91} 93}
@@ -210,7 +212,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
210 nhdr->p_offset = offset; 212 nhdr->p_offset = offset;
211 213
212 /* set up the process status */ 214 /* set up the process status */
213 notes[0].name = "CORE"; 215 notes[0].name = CORE_STR;
214 notes[0].type = NT_PRSTATUS; 216 notes[0].type = NT_PRSTATUS;
215 notes[0].datasz = sizeof(struct elf_prstatus); 217 notes[0].datasz = sizeof(struct elf_prstatus);
216 notes[0].data = &prstatus; 218 notes[0].data = &prstatus;
@@ -221,7 +223,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
221 bufp = storenote(&notes[0], bufp); 223 bufp = storenote(&notes[0], bufp);
222 224
223 /* set up the process info */ 225 /* set up the process info */
224 notes[1].name = "CORE"; 226 notes[1].name = CORE_STR;
225 notes[1].type = NT_PRPSINFO; 227 notes[1].type = NT_PRPSINFO;
226 notes[1].datasz = sizeof(struct elf_prpsinfo); 228 notes[1].datasz = sizeof(struct elf_prpsinfo);
227 notes[1].data = &prpsinfo; 229 notes[1].data = &prpsinfo;
@@ -238,7 +240,7 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
238 bufp = storenote(&notes[1], bufp); 240 bufp = storenote(&notes[1], bufp);
239 241
240 /* set up the task structure */ 242 /* set up the task structure */
241 notes[2].name = "CORE"; 243 notes[2].name = CORE_STR;
242 notes[2].type = NT_TASKSTRUCT; 244 notes[2].type = NT_TASKSTRUCT;
243 notes[2].datasz = sizeof(struct task_struct); 245 notes[2].datasz = sizeof(struct task_struct);
244 notes[2].data = current; 246 notes[2].data = current;
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 93c43b676e59..51815cece6f3 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -696,9 +696,11 @@ void __init proc_misc_init(void)
696 proc_symlink("mounts", NULL, "self/mounts"); 696 proc_symlink("mounts", NULL, "self/mounts");
697 697
698 /* And now for trickier ones */ 698 /* And now for trickier ones */
699#ifdef CONFIG_PRINTK
699 entry = create_proc_entry("kmsg", S_IRUSR, &proc_root); 700 entry = create_proc_entry("kmsg", S_IRUSR, &proc_root);
700 if (entry) 701 if (entry)
701 entry->proc_fops = &proc_kmsg_operations; 702 entry->proc_fops = &proc_kmsg_operations;
703#endif
702 create_seq_entry("devices", 0, &proc_devinfo_operations); 704 create_seq_entry("devices", 0, &proc_devinfo_operations);
703 create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations); 705 create_seq_entry("cpuinfo", 0, &proc_cpuinfo_operations);
704#ifdef CONFIG_BLOCK 706#ifdef CONFIG_BLOCK
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 5a41db2a218d..c047dc654d5c 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -515,12 +515,12 @@ static void qnx4_read_inode(struct inode *inode)
515 brelse(bh); 515 brelse(bh);
516} 516}
517 517
518static kmem_cache_t *qnx4_inode_cachep; 518static struct kmem_cache *qnx4_inode_cachep;
519 519
520static struct inode *qnx4_alloc_inode(struct super_block *sb) 520static struct inode *qnx4_alloc_inode(struct super_block *sb)
521{ 521{
522 struct qnx4_inode_info *ei; 522 struct qnx4_inode_info *ei;
523 ei = kmem_cache_alloc(qnx4_inode_cachep, SLAB_KERNEL); 523 ei = kmem_cache_alloc(qnx4_inode_cachep, GFP_KERNEL);
524 if (!ei) 524 if (!ei)
525 return NULL; 525 return NULL;
526 return &ei->vfs_inode; 526 return &ei->vfs_inode;
@@ -531,7 +531,7 @@ static void qnx4_destroy_inode(struct inode *inode)
531 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); 531 kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode));
532} 532}
533 533
534static void init_once(void *foo, kmem_cache_t * cachep, 534static void init_once(void *foo, struct kmem_cache * cachep,
535 unsigned long flags) 535 unsigned long flags)
536{ 536{
537 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo; 537 struct qnx4_inode_info *ei = (struct qnx4_inode_info *) foo;
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index ac14318c81ba..373d862c3f87 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -317,12 +317,11 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
317 /* area filled with zeroes, to supply as list of zero blocknumbers 317 /* area filled with zeroes, to supply as list of zero blocknumbers
318 We allocate it outside of loop just in case loop would spin for 318 We allocate it outside of loop just in case loop would spin for
319 several iterations. */ 319 several iterations. */
320 char *zeros = kmalloc(to_paste * UNFM_P_SIZE, GFP_ATOMIC); // We cannot insert more than MAX_ITEM_LEN bytes anyway. 320 char *zeros = kzalloc(to_paste * UNFM_P_SIZE, GFP_ATOMIC); // We cannot insert more than MAX_ITEM_LEN bytes anyway.
321 if (!zeros) { 321 if (!zeros) {
322 res = -ENOMEM; 322 res = -ENOMEM;
323 goto error_exit_free_blocks; 323 goto error_exit_free_blocks;
324 } 324 }
325 memset(zeros, 0, to_paste * UNFM_P_SIZE);
326 do { 325 do {
327 to_paste = 326 to_paste =
328 min_t(__u64, hole_size, 327 min_t(__u64, hole_size,
@@ -407,6 +406,8 @@ static int reiserfs_allocate_blocks_for_region(struct reiserfs_transaction_handl
407 we restart it. This will also free the path. */ 406 we restart it. This will also free the path. */
408 if (journal_transaction_should_end 407 if (journal_transaction_should_end
409 (th, th->t_blocks_allocated)) { 408 (th, th->t_blocks_allocated)) {
409 inode->i_size = cpu_key_k_offset(&key) +
410 (to_paste << inode->i_blkbits);
410 res = 411 res =
411 restart_transaction(th, inode, 412 restart_transaction(th, inode,
412 &path); 413 &path);
@@ -1045,6 +1046,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1045 char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0); 1046 char *kaddr = kmap_atomic(prepared_pages[0], KM_USER0);
1046 memset(kaddr, 0, from); 1047 memset(kaddr, 0, from);
1047 kunmap_atomic(kaddr, KM_USER0); 1048 kunmap_atomic(kaddr, KM_USER0);
1049 flush_dcache_page(prepared_pages[0]);
1048 } 1050 }
1049 if (to != PAGE_CACHE_SIZE) { /* Last page needs to be partially zeroed */ 1051 if (to != PAGE_CACHE_SIZE) { /* Last page needs to be partially zeroed */
1050 char *kaddr = 1052 char *kaddr =
@@ -1052,6 +1054,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1052 KM_USER0); 1054 KM_USER0);
1053 memset(kaddr + to, 0, PAGE_CACHE_SIZE - to); 1055 memset(kaddr + to, 0, PAGE_CACHE_SIZE - to);
1054 kunmap_atomic(kaddr, KM_USER0); 1056 kunmap_atomic(kaddr, KM_USER0);
1057 flush_dcache_page(prepared_pages[num_pages - 1]);
1055 } 1058 }
1056 1059
1057 /* Since all blocks are new - use already calculated value */ 1060 /* Since all blocks are new - use already calculated value */
@@ -1185,6 +1188,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1185 memset(kaddr + block_start, 0, 1188 memset(kaddr + block_start, 0,
1186 from - block_start); 1189 from - block_start);
1187 kunmap_atomic(kaddr, KM_USER0); 1190 kunmap_atomic(kaddr, KM_USER0);
1191 flush_dcache_page(prepared_pages[0]);
1188 set_buffer_uptodate(bh); 1192 set_buffer_uptodate(bh);
1189 } 1193 }
1190 } 1194 }
@@ -1222,6 +1226,7 @@ static int reiserfs_prepare_file_region_for_write(struct inode *inode
1222 KM_USER0); 1226 KM_USER0);
1223 memset(kaddr + to, 0, block_end - to); 1227 memset(kaddr + to, 0, block_end - to);
1224 kunmap_atomic(kaddr, KM_USER0); 1228 kunmap_atomic(kaddr, KM_USER0);
1229 flush_dcache_page(prepared_pages[num_pages - 1]);
1225 set_buffer_uptodate(bh); 1230 set_buffer_uptodate(bh);
1226 } 1231 }
1227 } 1232 }
@@ -1307,56 +1312,8 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
1307 count = MAX_NON_LFS - (unsigned long)*ppos; 1312 count = MAX_NON_LFS - (unsigned long)*ppos;
1308 } 1313 }
1309 1314
1310 if (file->f_flags & O_DIRECT) { // Direct IO needs treatment 1315 if (file->f_flags & O_DIRECT)
1311 ssize_t result, after_file_end = 0; 1316 return do_sync_write(file, buf, count, ppos);
1312 if ((*ppos + count >= inode->i_size)
1313 || (file->f_flags & O_APPEND)) {
1314 /* If we are appending a file, we need to put this savelink in here.
1315 If we will crash while doing direct io, finish_unfinished will
1316 cut the garbage from the file end. */
1317 reiserfs_write_lock(inode->i_sb);
1318 err =
1319 journal_begin(&th, inode->i_sb,
1320 JOURNAL_PER_BALANCE_CNT);
1321 if (err) {
1322 reiserfs_write_unlock(inode->i_sb);
1323 return err;
1324 }
1325 reiserfs_update_inode_transaction(inode);
1326 add_save_link(&th, inode, 1 /* Truncate */ );
1327 after_file_end = 1;
1328 err =
1329 journal_end(&th, inode->i_sb,
1330 JOURNAL_PER_BALANCE_CNT);
1331 reiserfs_write_unlock(inode->i_sb);
1332 if (err)
1333 return err;
1334 }
1335 result = do_sync_write(file, buf, count, ppos);
1336
1337 if (after_file_end) { /* Now update i_size and remove the savelink */
1338 struct reiserfs_transaction_handle th;
1339 reiserfs_write_lock(inode->i_sb);
1340 err = journal_begin(&th, inode->i_sb, 1);
1341 if (err) {
1342 reiserfs_write_unlock(inode->i_sb);
1343 return err;
1344 }
1345 reiserfs_update_inode_transaction(inode);
1346 mark_inode_dirty(inode);
1347 err = journal_end(&th, inode->i_sb, 1);
1348 if (err) {
1349 reiserfs_write_unlock(inode->i_sb);
1350 return err;
1351 }
1352 err = remove_save_link(inode, 1 /* truncate */ );
1353 reiserfs_write_unlock(inode->i_sb);
1354 if (err)
1355 return err;
1356 }
1357
1358 return result;
1359 }
1360 1317
1361 if (unlikely((ssize_t) count < 0)) 1318 if (unlikely((ssize_t) count < 0))
1362 return -EINVAL; 1319 return -EINVAL;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 9c69bcacad22..254239e6f9e3 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -216,11 +216,12 @@ static int file_capable(struct inode *inode, long block)
216 BUG_ON(!th->t_trans_id); 216 BUG_ON(!th->t_trans_id);
217 BUG_ON(!th->t_refcount); 217 BUG_ON(!th->t_refcount);
218 218
219 pathrelse(path);
220
219 /* we cannot restart while nested */ 221 /* we cannot restart while nested */
220 if (th->t_refcount > 1) { 222 if (th->t_refcount > 1) {
221 return 0; 223 return 0;
222 } 224 }
223 pathrelse(path);
224 reiserfs_update_sd(th, inode); 225 reiserfs_update_sd(th, inode);
225 err = journal_end(th, s, len); 226 err = journal_end(th, s, len);
226 if (!err) { 227 if (!err) {
@@ -928,15 +929,12 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
928 if (blocks_needed == 1) { 929 if (blocks_needed == 1) {
929 un = &unf_single; 930 un = &unf_single;
930 } else { 931 } else {
931 un = kmalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_ATOMIC); // We need to avoid scheduling. 932 un = kzalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_ATOMIC); // We need to avoid scheduling.
932 if (!un) { 933 if (!un) {
933 un = &unf_single; 934 un = &unf_single;
934 blocks_needed = 1; 935 blocks_needed = 1;
935 max_to_insert = 0; 936 max_to_insert = 0;
936 } else 937 }
937 memset(un, 0,
938 UNFM_P_SIZE * min(blocks_needed,
939 max_to_insert));
940 } 938 }
941 if (blocks_needed <= max_to_insert) { 939 if (blocks_needed <= max_to_insert) {
942 /* we are going to add target block to the file. Use allocated 940 /* we are going to add target block to the file. Use allocated
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 17249994110f..7fb5fb036f90 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -490,13 +490,13 @@ static void reiserfs_put_super(struct super_block *s)
490 return; 490 return;
491} 491}
492 492
493static kmem_cache_t *reiserfs_inode_cachep; 493static struct kmem_cache *reiserfs_inode_cachep;
494 494
495static struct inode *reiserfs_alloc_inode(struct super_block *sb) 495static struct inode *reiserfs_alloc_inode(struct super_block *sb)
496{ 496{
497 struct reiserfs_inode_info *ei; 497 struct reiserfs_inode_info *ei;
498 ei = (struct reiserfs_inode_info *) 498 ei = (struct reiserfs_inode_info *)
499 kmem_cache_alloc(reiserfs_inode_cachep, SLAB_KERNEL); 499 kmem_cache_alloc(reiserfs_inode_cachep, GFP_KERNEL);
500 if (!ei) 500 if (!ei)
501 return NULL; 501 return NULL;
502 return &ei->vfs_inode; 502 return &ei->vfs_inode;
@@ -507,7 +507,7 @@ static void reiserfs_destroy_inode(struct inode *inode)
507 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); 507 kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode));
508} 508}
509 509
510static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) 510static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
511{ 511{
512 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo; 512 struct reiserfs_inode_info *ei = (struct reiserfs_inode_info *)foo;
513 513
@@ -1549,13 +1549,12 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent)
1549 struct reiserfs_sb_info *sbi; 1549 struct reiserfs_sb_info *sbi;
1550 int errval = -EINVAL; 1550 int errval = -EINVAL;
1551 1551
1552 sbi = kmalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL); 1552 sbi = kzalloc(sizeof(struct reiserfs_sb_info), GFP_KERNEL);
1553 if (!sbi) { 1553 if (!sbi) {
1554 errval = -ENOMEM; 1554 errval = -ENOMEM;
1555 goto error; 1555 goto error;
1556 } 1556 }
1557 s->s_fs_info = sbi; 1557 s->s_fs_info = sbi;
1558 memset(sbi, 0, sizeof(struct reiserfs_sb_info));
1559 /* Set default values for options: non-aggressive tails, RO on errors */ 1558 /* Set default values for options: non-aggressive tails, RO on errors */
1560 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL); 1559 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL);
1561 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO); 1560 REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO);
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index ddcd9e1ef282..c5af088d4a4c 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -550,12 +550,12 @@ romfs_read_inode(struct inode *i)
550 } 550 }
551} 551}
552 552
553static kmem_cache_t * romfs_inode_cachep; 553static struct kmem_cache * romfs_inode_cachep;
554 554
555static struct inode *romfs_alloc_inode(struct super_block *sb) 555static struct inode *romfs_alloc_inode(struct super_block *sb)
556{ 556{
557 struct romfs_inode_info *ei; 557 struct romfs_inode_info *ei;
558 ei = (struct romfs_inode_info *)kmem_cache_alloc(romfs_inode_cachep, SLAB_KERNEL); 558 ei = (struct romfs_inode_info *)kmem_cache_alloc(romfs_inode_cachep, GFP_KERNEL);
559 if (!ei) 559 if (!ei)
560 return NULL; 560 return NULL;
561 return &ei->vfs_inode; 561 return &ei->vfs_inode;
@@ -566,7 +566,7 @@ static void romfs_destroy_inode(struct inode *inode)
566 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); 566 kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode));
567} 567}
568 568
569static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 569static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
570{ 570{
571 struct romfs_inode_info *ei = (struct romfs_inode_info *) foo; 571 struct romfs_inode_info *ei = (struct romfs_inode_info *) foo;
572 572
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 555b9ac04c25..10690aa401c7 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -26,7 +26,7 @@
26 * ERR_PTR(error). In the end of sequence they return %NULL. ->show() 26 * ERR_PTR(error). In the end of sequence they return %NULL. ->show()
27 * returns 0 in case of success and negative number in case of error. 27 * returns 0 in case of success and negative number in case of error.
28 */ 28 */
29int seq_open(struct file *file, struct seq_operations *op) 29int seq_open(struct file *file, const struct seq_operations *op)
30{ 30{
31 struct seq_file *p = file->private_data; 31 struct seq_file *p = file->private_data;
32 32
@@ -408,7 +408,7 @@ EXPORT_SYMBOL(single_open);
408 408
409int single_release(struct inode *inode, struct file *file) 409int single_release(struct inode *inode, struct file *file)
410{ 410{
411 struct seq_operations *op = ((struct seq_file *)file->private_data)->op; 411 const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
412 int res = seq_release(inode, file); 412 int res = seq_release(inode, file);
413 kfree(op); 413 kfree(op);
414 return res; 414 return res;
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 2c122ee83adb..4af4cd729a5a 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -50,12 +50,12 @@ static void smb_put_super(struct super_block *);
50static int smb_statfs(struct dentry *, struct kstatfs *); 50static int smb_statfs(struct dentry *, struct kstatfs *);
51static int smb_show_options(struct seq_file *, struct vfsmount *); 51static int smb_show_options(struct seq_file *, struct vfsmount *);
52 52
53static kmem_cache_t *smb_inode_cachep; 53static struct kmem_cache *smb_inode_cachep;
54 54
55static struct inode *smb_alloc_inode(struct super_block *sb) 55static struct inode *smb_alloc_inode(struct super_block *sb)
56{ 56{
57 struct smb_inode_info *ei; 57 struct smb_inode_info *ei;
58 ei = (struct smb_inode_info *)kmem_cache_alloc(smb_inode_cachep, SLAB_KERNEL); 58 ei = (struct smb_inode_info *)kmem_cache_alloc(smb_inode_cachep, GFP_KERNEL);
59 if (!ei) 59 if (!ei)
60 return NULL; 60 return NULL;
61 return &ei->vfs_inode; 61 return &ei->vfs_inode;
@@ -66,7 +66,7 @@ static void smb_destroy_inode(struct inode *inode)
66 kmem_cache_free(smb_inode_cachep, SMB_I(inode)); 66 kmem_cache_free(smb_inode_cachep, SMB_I(inode));
67} 67}
68 68
69static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 69static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
70{ 70{
71 struct smb_inode_info *ei = (struct smb_inode_info *) foo; 71 struct smb_inode_info *ei = (struct smb_inode_info *) foo;
72 unsigned long flagmask = SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR; 72 unsigned long flagmask = SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR;
diff --git a/fs/smbfs/request.c b/fs/smbfs/request.c
index 0fb74697abc4..a4bcae8a9aff 100644
--- a/fs/smbfs/request.c
+++ b/fs/smbfs/request.c
@@ -25,7 +25,7 @@
25#define ROUND_UP(x) (((x)+3) & ~3) 25#define ROUND_UP(x) (((x)+3) & ~3)
26 26
27/* cache for request structures */ 27/* cache for request structures */
28static kmem_cache_t *req_cachep; 28static struct kmem_cache *req_cachep;
29 29
30static int smb_request_send_req(struct smb_request *req); 30static int smb_request_send_req(struct smb_request *req);
31 31
@@ -61,7 +61,7 @@ static struct smb_request *smb_do_alloc_request(struct smb_sb_info *server,
61 struct smb_request *req; 61 struct smb_request *req;
62 unsigned char *buf = NULL; 62 unsigned char *buf = NULL;
63 63
64 req = kmem_cache_alloc(req_cachep, SLAB_KERNEL); 64 req = kmem_cache_alloc(req_cachep, GFP_KERNEL);
65 VERBOSE("allocating request: %p\n", req); 65 VERBOSE("allocating request: %p\n", req);
66 if (!req) 66 if (!req)
67 goto out; 67 goto out;
diff --git a/fs/stat.c b/fs/stat.c
index bca07eb2003c..a0ebfc7f8a64 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -51,13 +51,6 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
51 return inode->i_op->getattr(mnt, dentry, stat); 51 return inode->i_op->getattr(mnt, dentry, stat);
52 52
53 generic_fillattr(inode, stat); 53 generic_fillattr(inode, stat);
54 if (!stat->blksize) {
55 struct super_block *s = inode->i_sb;
56 unsigned blocks;
57 blocks = (stat->size+s->s_blocksize-1) >> s->s_blocksize_bits;
58 stat->blocks = (s->s_blocksize / 512) * blocks;
59 stat->blksize = s->s_blocksize;
60 }
61 return 0; 54 return 0;
62} 55}
63 56
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 20551a1b8a56..e503f858fba8 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -16,7 +16,7 @@
16 16
17struct vfsmount *sysfs_mount; 17struct vfsmount *sysfs_mount;
18struct super_block * sysfs_sb = NULL; 18struct super_block * sysfs_sb = NULL;
19kmem_cache_t *sysfs_dir_cachep; 19struct kmem_cache *sysfs_dir_cachep;
20 20
21static struct super_operations sysfs_ops = { 21static struct super_operations sysfs_ops = {
22 .statfs = simple_statfs, 22 .statfs = simple_statfs,
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 6f3d6bd52887..bd7cec295dab 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -1,6 +1,6 @@
1 1
2extern struct vfsmount * sysfs_mount; 2extern struct vfsmount * sysfs_mount;
3extern kmem_cache_t *sysfs_dir_cachep; 3extern struct kmem_cache *sysfs_dir_cachep;
4 4
5extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *); 5extern struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent *);
6extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *)); 6extern int sysfs_create(struct dentry *, int mode, int (*init)(struct inode *));
diff --git a/fs/sysv/CHANGES b/fs/sysv/CHANGES
deleted file mode 100644
index 66ea6e92be66..000000000000
--- a/fs/sysv/CHANGES
+++ /dev/null
@@ -1,60 +0,0 @@
1Mon, 15 Dec 1997 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
2 * namei.c: struct sysv_dir_inode_operations updated to use dentries.
3
4Fri, 23 Jan 1998 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
5 * inode.c: corrected 1 track offset setting (in sb->sv_block_base).
6 Originally it was overridden (by setting to zero)
7 in detected_[xenix,sysv4,sysv2,coherent]. Thanks
8 to Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
9 for identifying the problem.
10
11Tue, 27 Jan 1998 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
12 * inode.c: added 2048-byte block support to SystemV FS.
13 Merged detected_bs[512,1024,2048]() into one function:
14 void detected_bs (u_char type, struct super_block *sb).
15 Thanks to Andrzej Krzysztofowicz <ankry@mif.pg.gda.pl>
16 for the patch.
17
18Wed, 4 Feb 1998 Krzysztof G. Baranowski <kgb@manjak.knm.org.pl>
19 * namei.c: removed static subdir(); is_subdir() from dcache.c
20 is used instead. Cosmetic changes.
21
22Thu, 3 Dec 1998 Al Viro (viro@parcelfarce.linux.theplanet.co.uk)
23 * namei.c (sysv_rmdir):
24 Bugectomy: old check for victim being busy
25 (inode->i_count) wasn't replaced (with checking
26 dentry->d_count) and escaped Linus in the last round
27 of changes. Shot and buried.
28
29Wed, 9 Dec 1998 AV
30 * namei.c (do_sysv_rename):
31 Fixed incorrect check for other owners + race.
32 Removed checks that went to VFS.
33 * namei.c (sysv_unlink):
34 Removed checks that went to VFS.
35
36Thu, 10 Dec 1998 AV
37 * namei.c (do_mknod):
38 Removed dead code - mknod is never asked to
39 create a symlink or directory. Incidentially,
40 it wouldn't do it right if it would be called.
41
42Sat, 26 Dec 1998 KGB
43 * inode.c (detect_sysv4):
44 Added detection of expanded s_type field (0x10,
45 0x20 and 0x30). Forced read-only access in this case.
46
47Sun, 21 Mar 1999 AV
48 * namei.c (sysv_link):
49 Fixed i_count usage that resulted in dcache corruption.
50 * inode.c:
51 Filled ->delete_inode() method with sysv_delete_inode().
52 sysv_put_inode() is gone, as it tried to do ->delete_
53 _inode()'s job.
54 * ialloc.c: (sysv_free_inode):
55 Fixed race.
56
57Sun, 30 Apr 1999 AV
58 * namei.c (sysv_mknod):
59 Removed dead code (S_IFREG case is now passed to
60 ->create() by VFS).
diff --git a/fs/sysv/ChangeLog b/fs/sysv/ChangeLog
deleted file mode 100644
index f403f8b91b80..000000000000
--- a/fs/sysv/ChangeLog
+++ /dev/null
@@ -1,106 +0,0 @@
1Thu Feb 14 2002 Andrew Morton <akpm@zip.com.au>
2
3 * dir_commit_chunk(): call writeout_one_page() as well as
4 waitfor_one_page() for IS_SYNC directories, so that we
5 actually do sync the directory. (forward-port from 2.4).
6
7Thu Feb 7 2002 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
8
9 * super.c: switched to ->get_sb()
10 * ChangeLog: fixed dates ;-)
11
122002-01-24 David S. Miller <davem@redhat.com>
13
14 * inode.c: Include linux/init.h
15
16Mon Jan 21 2002 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
17 * ialloc.c (sysv_new_inode): zero SYSV_I(inode)->i_data out.
18 * i_vnode renamed to vfs_inode. Sorry, but let's keep that
19 consistent.
20
21Sat Jan 19 2002 Christoph Hellwig <hch@infradead.org>
22
23 * include/linux/sysv_fs.h (SYSV_I): Get fs-private inode data using
24 list_entry() instead of inode->u.
25 * include/linux/sysv_fs_i.h: Add 'struct inode i_vnode' field to
26 sysv_inode_info structure.
27 * inode.c: Include <linux/slab.h>, implement alloc_inode/destroy_inode
28 sop methods, add infrastructure for per-fs inode slab cache.
29 * super.c (init_sysv_fs): Initialize inode cache, recover properly
30 in the case of failed register_filesystem for V7.
31 (exit_sysv_fs): Destroy inode cache.
32
33Sat Jan 19 2002 Christoph Hellwig <hch@infradead.org>
34
35 * include/linux/sysv_fs.h: Include <linux/sysv_fs_i.h>, declare SYSV_I().
36 * dir.c (sysv_find_entry): Use SYSV_I() instead of ->u.sysv_i to
37 access fs-private inode data.
38 * ialloc.c (sysv_new_inode): Likewise.
39 * inode.c (sysv_read_inode): Likewise.
40 (sysv_update_inode): Likewise.
41 * itree.c (get_branch): Likewise.
42 (sysv_truncate): Likewise.
43 * symlink.c (sysv_readlink): Likewise.
44 (sysv_follow_link): Likewise.
45
46Fri Jan 4 2002 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
47
48 * ialloc.c (sysv_free_inode): Use sb->s_id instead of bdevname().
49 * inode.c (sysv_read_inode): Likewise.
50 (sysv_update_inode): Likewise.
51 (sysv_sync_inode): Likewise.
52 * super.c (detect_sysv): Likewise.
53 (complete_read_super): Likewise.
54 (sysv_read_super): Likewise.
55 (v7_read_super): Likewise.
56
57Sun Dec 30 2001 Manfred Spraul <manfred@colorfullife.com>
58
59 * dir.c (dir_commit_chunk): Do not set dir->i_version.
60 (sysv_readdir): Likewise.
61
62Thu Dec 27 2001 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
63
64 * itree.c (get_block): Use map_bh() to fill out bh_result.
65
66Tue Dec 25 2001 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
67
68 * super.c (sysv_read_super): Use sb_set_blocksize() to set blocksize.
69 (v7_read_super): Likewise.
70
71Tue Nov 27 2001 Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk>
72
73 * itree.c (get_block): Change type for iblock argument to sector_t.
74 * super.c (sysv_read_super): Set s_blocksize early.
75 (v7_read_super): Likewise.
76 * balloc.c (sysv_new_block): Use sb_bread(). instead of bread().
77 (sysv_count_free_blocks): Likewise.
78 * ialloc.c (sysv_raw_inode): Likewise.
79 * itree.c (get_branch): Likewise.
80 (free_branches): Likewise.
81 * super.c (sysv_read_super): Likewise.
82 (v7_read_super): Likewise.
83
84Sat Dec 15 2001 Christoph Hellwig <hch@infradead.org>
85
86 * inode.c (sysv_read_inode): Mark inode as bad in case of failure.
87 * super.c (complete_read_super): Check for bad root inode.
88
89Wed Nov 21 2001 Andrew Morton <andrewm@uow.edu.au>
90
91 * file.c (sysv_sync_file): Call fsync_inode_data_buffers.
92
93Fri Oct 26 2001 Christoph Hellwig <hch@infradead.org>
94
95 * dir.c, ialloc.c, namei.c, include/linux/sysv_fs_i.h:
96 Implement per-Inode lookup offset cache.
97 Modelled after Ted's ext2 patch.
98
99Fri Oct 26 2001 Christoph Hellwig <hch@infradead.org>
100
101 * inode.c, super.c, include/linux/sysv_fs.h,
102 include/linux/sysv_fs_sb.h:
103 Remove symlink faking. Noone really wants to use these as
104 linux filesystems and native OSes don't support it anyway.
105
106
diff --git a/fs/sysv/INTRO b/fs/sysv/INTRO
deleted file mode 100644
index de4e4d17cac6..000000000000
--- a/fs/sysv/INTRO
+++ /dev/null
@@ -1,182 +0,0 @@
1This is the implementation of the SystemV/Coherent filesystem for Linux.
2It grew out of separate filesystem implementations
3
4 Xenix FS Doug Evans <dje@cygnus.com> June 1992
5 SystemV FS Paul B. Monday <pmonday@eecs.wsu.edu> March-June 1993
6 Coherent FS B. Haible <haible@ma2s2.mathematik.uni-karlsruhe.de> June 1993
7
8and was merged together in July 1993.
9
10These filesystems are rather similar. Here is a comparison with Minix FS:
11
12* Linux fdisk reports on partitions
13 - Minix FS 0x81 Linux/Minix
14 - Xenix FS ??
15 - SystemV FS ??
16 - Coherent FS 0x08 AIX bootable
17
18* Size of a block or zone (data allocation unit on disk)
19 - Minix FS 1024
20 - Xenix FS 1024 (also 512 ??)
21 - SystemV FS 1024 (also 512 and 2048)
22 - Coherent FS 512
23
24* General layout: all have one boot block, one super block and
25 separate areas for inodes and for directories/data.
26 On SystemV Release 2 FS (e.g. Microport) the first track is reserved and
27 all the block numbers (including the super block) are offset by one track.
28
29* Byte ordering of "short" (16 bit entities) on disk:
30 - Minix FS little endian 0 1
31 - Xenix FS little endian 0 1
32 - SystemV FS little endian 0 1
33 - Coherent FS little endian 0 1
34 Of course, this affects only the file system, not the data of files on it!
35
36* Byte ordering of "long" (32 bit entities) on disk:
37 - Minix FS little endian 0 1 2 3
38 - Xenix FS little endian 0 1 2 3
39 - SystemV FS little endian 0 1 2 3
40 - Coherent FS PDP-11 2 3 0 1
41 Of course, this affects only the file system, not the data of files on it!
42
43* Inode on disk: "short", 0 means non-existent, the root dir ino is:
44 - Minix FS 1
45 - Xenix FS, SystemV FS, Coherent FS 2
46
47* Maximum number of hard links to a file:
48 - Minix FS 250
49 - Xenix FS ??
50 - SystemV FS ??
51 - Coherent FS >=10000
52
53* Free inode management:
54 - Minix FS a bitmap
55 - Xenix FS, SystemV FS, Coherent FS
56 There is a cache of a certain number of free inodes in the super-block.
57 When it is exhausted, new free inodes are found using a linear search.
58
59* Free block management:
60 - Minix FS a bitmap
61 - Xenix FS, SystemV FS, Coherent FS
62 Free blocks are organized in a "free list". Maybe a misleading term,
63 since it is not true that every free block contains a pointer to
64 the next free block. Rather, the free blocks are organized in chunks
65 of limited size, and every now and then a free block contains pointers
66 to the free blocks pertaining to the next chunk; the first of these
67 contains pointers and so on. The list terminates with a "block number"
68 0 on Xenix FS and SystemV FS, with a block zeroed out on Coherent FS.
69
70* Super-block location:
71 - Minix FS block 1 = bytes 1024..2047
72 - Xenix FS block 1 = bytes 1024..2047
73 - SystemV FS bytes 512..1023
74 - Coherent FS block 1 = bytes 512..1023
75
76* Super-block layout:
77 - Minix FS
78 unsigned short s_ninodes;
79 unsigned short s_nzones;
80 unsigned short s_imap_blocks;
81 unsigned short s_zmap_blocks;
82 unsigned short s_firstdatazone;
83 unsigned short s_log_zone_size;
84 unsigned long s_max_size;
85 unsigned short s_magic;
86 - Xenix FS, SystemV FS, Coherent FS
87 unsigned short s_firstdatazone;
88 unsigned long s_nzones;
89 unsigned short s_fzone_count;
90 unsigned long s_fzones[NICFREE];
91 unsigned short s_finode_count;
92 unsigned short s_finodes[NICINOD];
93 char s_flock;
94 char s_ilock;
95 char s_modified;
96 char s_rdonly;
97 unsigned long s_time;
98 short s_dinfo[4]; -- SystemV FS only
99 unsigned long s_free_zones;
100 unsigned short s_free_inodes;
101 short s_dinfo[4]; -- Xenix FS only
102 unsigned short s_interleave_m,s_interleave_n; -- Coherent FS only
103 char s_fname[6];
104 char s_fpack[6];
105 then they differ considerably:
106 Xenix FS
107 char s_clean;
108 char s_fill[371];
109 long s_magic;
110 long s_type;
111 SystemV FS
112 long s_fill[12 or 14];
113 long s_state;
114 long s_magic;
115 long s_type;
116 Coherent FS
117 unsigned long s_unique;
118 Note that Coherent FS has no magic.
119
120* Inode layout:
121 - Minix FS
122 unsigned short i_mode;
123 unsigned short i_uid;
124 unsigned long i_size;
125 unsigned long i_time;
126 unsigned char i_gid;
127 unsigned char i_nlinks;
128 unsigned short i_zone[7+1+1];
129 - Xenix FS, SystemV FS, Coherent FS
130 unsigned short i_mode;
131 unsigned short i_nlink;
132 unsigned short i_uid;
133 unsigned short i_gid;
134 unsigned long i_size;
135 unsigned char i_zone[3*(10+1+1+1)];
136 unsigned long i_atime;
137 unsigned long i_mtime;
138 unsigned long i_ctime;
139
140* Regular file data blocks are organized as
141 - Minix FS
142 7 direct blocks
143 1 indirect block (pointers to blocks)
144 1 double-indirect block (pointer to pointers to blocks)
145 - Xenix FS, SystemV FS, Coherent FS
146 10 direct blocks
147 1 indirect block (pointers to blocks)
148 1 double-indirect block (pointer to pointers to blocks)
149 1 triple-indirect block (pointer to pointers to pointers to blocks)
150
151* Inode size, inodes per block
152 - Minix FS 32 32
153 - Xenix FS 64 16
154 - SystemV FS 64 16
155 - Coherent FS 64 8
156
157* Directory entry on disk
158 - Minix FS
159 unsigned short inode;
160 char name[14/30];
161 - Xenix FS, SystemV FS, Coherent FS
162 unsigned short inode;
163 char name[14];
164
165* Dir entry size, dir entries per block
166 - Minix FS 16/32 64/32
167 - Xenix FS 16 64
168 - SystemV FS 16 64
169 - Coherent FS 16 32
170
171* How to implement symbolic links such that the host fsck doesn't scream:
172 - Minix FS normal
173 - Xenix FS kludge: as regular files with chmod 1000
174 - SystemV FS ??
175 - Coherent FS kludge: as regular files with chmod 1000
176
177
178Notation: We often speak of a "block" but mean a zone (the allocation unit)
179and not the disk driver's notion of "block".
180
181
182Bruno Haible <haible@ma2s2.mathematik.uni-karlsruhe.de>
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index d63c5e48b050..ead9864567e3 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -301,13 +301,13 @@ static void sysv_delete_inode(struct inode *inode)
301 unlock_kernel(); 301 unlock_kernel();
302} 302}
303 303
304static kmem_cache_t *sysv_inode_cachep; 304static struct kmem_cache *sysv_inode_cachep;
305 305
306static struct inode *sysv_alloc_inode(struct super_block *sb) 306static struct inode *sysv_alloc_inode(struct super_block *sb)
307{ 307{
308 struct sysv_inode_info *si; 308 struct sysv_inode_info *si;
309 309
310 si = kmem_cache_alloc(sysv_inode_cachep, SLAB_KERNEL); 310 si = kmem_cache_alloc(sysv_inode_cachep, GFP_KERNEL);
311 if (!si) 311 if (!si)
312 return NULL; 312 return NULL;
313 return &si->vfs_inode; 313 return &si->vfs_inode;
@@ -318,7 +318,7 @@ static void sysv_destroy_inode(struct inode *inode)
318 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); 318 kmem_cache_free(sysv_inode_cachep, SYSV_I(inode));
319} 319}
320 320
321static void init_once(void *p, kmem_cache_t *cachep, unsigned long flags) 321static void init_once(void *p, struct kmem_cache *cachep, unsigned long flags)
322{ 322{
323 struct sysv_inode_info *si = (struct sysv_inode_info *)p; 323 struct sysv_inode_info *si = (struct sysv_inode_info *)p;
324 324
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 1aea6a4f9a4a..1dbc2955f02e 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -107,12 +107,12 @@ static struct file_system_type udf_fstype = {
107 .fs_flags = FS_REQUIRES_DEV, 107 .fs_flags = FS_REQUIRES_DEV,
108}; 108};
109 109
110static kmem_cache_t * udf_inode_cachep; 110static struct kmem_cache * udf_inode_cachep;
111 111
112static struct inode *udf_alloc_inode(struct super_block *sb) 112static struct inode *udf_alloc_inode(struct super_block *sb)
113{ 113{
114 struct udf_inode_info *ei; 114 struct udf_inode_info *ei;
115 ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, SLAB_KERNEL); 115 ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL);
116 if (!ei) 116 if (!ei)
117 return NULL; 117 return NULL;
118 118
@@ -130,7 +130,7 @@ static void udf_destroy_inode(struct inode *inode)
130 kmem_cache_free(udf_inode_cachep, UDF_I(inode)); 130 kmem_cache_free(udf_inode_cachep, UDF_I(inode));
131} 131}
132 132
133static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 133static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
134{ 134{
135 struct udf_inode_info *ei = (struct udf_inode_info *) foo; 135 struct udf_inode_info *ei = (struct udf_inode_info *) foo;
136 136
@@ -1709,7 +1709,7 @@ void udf_error(struct super_block *sb, const char *function,
1709 sb->s_dirt = 1; 1709 sb->s_dirt = 1;
1710 } 1710 }
1711 va_start(args, fmt); 1711 va_start(args, fmt);
1712 vsprintf(error_buf, fmt, args); 1712 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1713 va_end(args); 1713 va_end(args);
1714 printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n", 1714 printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
1715 sb->s_id, function, error_buf); 1715 sb->s_id, function, error_buf);
@@ -1721,7 +1721,7 @@ void udf_warning(struct super_block *sb, const char *function,
1721 va_list args; 1721 va_list args;
1722 1722
1723 va_start (args, fmt); 1723 va_start (args, fmt);
1724 vsprintf(error_buf, fmt, args); 1724 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1725 va_end(args); 1725 va_end(args);
1726 printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n", 1726 printk(KERN_WARNING "UDF-fs warning (device %s): %s: %s\n",
1727 sb->s_id, function, error_buf); 1727 sb->s_id, function, error_buf);
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index ec79e3091d1b..8a8e9382ec09 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -224,7 +224,7 @@ void ufs_error (struct super_block * sb, const char * function,
224 sb->s_flags |= MS_RDONLY; 224 sb->s_flags |= MS_RDONLY;
225 } 225 }
226 va_start (args, fmt); 226 va_start (args, fmt);
227 vsprintf (error_buf, fmt, args); 227 vsnprintf (error_buf, sizeof(error_buf), fmt, args);
228 va_end (args); 228 va_end (args);
229 switch (UFS_SB(sb)->s_mount_opt & UFS_MOUNT_ONERROR) { 229 switch (UFS_SB(sb)->s_mount_opt & UFS_MOUNT_ONERROR) {
230 case UFS_MOUNT_ONERROR_PANIC: 230 case UFS_MOUNT_ONERROR_PANIC:
@@ -255,7 +255,7 @@ void ufs_panic (struct super_block * sb, const char * function,
255 sb->s_dirt = 1; 255 sb->s_dirt = 1;
256 } 256 }
257 va_start (args, fmt); 257 va_start (args, fmt);
258 vsprintf (error_buf, fmt, args); 258 vsnprintf (error_buf, sizeof(error_buf), fmt, args);
259 va_end (args); 259 va_end (args);
260 sb->s_flags |= MS_RDONLY; 260 sb->s_flags |= MS_RDONLY;
261 printk (KERN_CRIT "UFS-fs panic (device %s): %s: %s\n", 261 printk (KERN_CRIT "UFS-fs panic (device %s): %s: %s\n",
@@ -268,7 +268,7 @@ void ufs_warning (struct super_block * sb, const char * function,
268 va_list args; 268 va_list args;
269 269
270 va_start (args, fmt); 270 va_start (args, fmt);
271 vsprintf (error_buf, fmt, args); 271 vsnprintf (error_buf, sizeof(error_buf), fmt, args);
272 va_end (args); 272 va_end (args);
273 printk (KERN_WARNING "UFS-fs warning (device %s): %s: %s\n", 273 printk (KERN_WARNING "UFS-fs warning (device %s): %s: %s\n",
274 sb->s_id, function, error_buf); 274 sb->s_id, function, error_buf);
@@ -1204,12 +1204,12 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
1204 return 0; 1204 return 0;
1205} 1205}
1206 1206
1207static kmem_cache_t * ufs_inode_cachep; 1207static struct kmem_cache * ufs_inode_cachep;
1208 1208
1209static struct inode *ufs_alloc_inode(struct super_block *sb) 1209static struct inode *ufs_alloc_inode(struct super_block *sb)
1210{ 1210{
1211 struct ufs_inode_info *ei; 1211 struct ufs_inode_info *ei;
1212 ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, SLAB_KERNEL); 1212 ei = (struct ufs_inode_info *)kmem_cache_alloc(ufs_inode_cachep, GFP_KERNEL);
1213 if (!ei) 1213 if (!ei)
1214 return NULL; 1214 return NULL;
1215 ei->vfs_inode.i_version = 1; 1215 ei->vfs_inode.i_version = 1;
@@ -1221,7 +1221,7 @@ static void ufs_destroy_inode(struct inode *inode)
1221 kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); 1221 kmem_cache_free(ufs_inode_cachep, UFS_I(inode));
1222} 1222}
1223 1223
1224static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 1224static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
1225{ 1225{
1226 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo; 1226 struct ufs_inode_info *ei = (struct ufs_inode_info *) foo;
1227 1227
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index 28fce6c239b5..7dd12bb1d62b 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -299,7 +299,7 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,
299 299
300#define ubh_get_addr16(ubh,begin) \ 300#define ubh_get_addr16(ubh,begin) \
301 (((__fs16*)((ubh)->bh[(begin) >> (uspi->s_fshift-1)]->b_data)) + \ 301 (((__fs16*)((ubh)->bh[(begin) >> (uspi->s_fshift-1)]->b_data)) + \
302 ((begin) & (uspi->fsize>>1) - 1))) 302 ((begin) & ((uspi->fsize>>1) - 1)))
303 303
304#define ubh_get_addr32(ubh,begin) \ 304#define ubh_get_addr32(ubh,begin) \
305 (((__fs32*)((ubh)->bh[(begin) >> (uspi->s_fshift-2)]->b_data)) + \ 305 (((__fs32*)((ubh)->bh[(begin) >> (uspi->s_fshift-2)]->b_data)) + \
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index eef4a0ba11e9..4fb01ffdfd1a 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -32,6 +32,7 @@
32#include <linux/kthread.h> 32#include <linux/kthread.h>
33#include <linux/migrate.h> 33#include <linux/migrate.h>
34#include <linux/backing-dev.h> 34#include <linux/backing-dev.h>
35#include <linux/freezer.h>
35 36
36STATIC kmem_zone_t *xfs_buf_zone; 37STATIC kmem_zone_t *xfs_buf_zone;
37STATIC kmem_shaker_t xfs_buf_shake; 38STATIC kmem_shaker_t xfs_buf_shake;
@@ -1826,11 +1827,11 @@ xfs_buf_init(void)
1826 if (!xfs_buf_zone) 1827 if (!xfs_buf_zone)
1827 goto out_free_trace_buf; 1828 goto out_free_trace_buf;
1828 1829
1829 xfslogd_workqueue = create_workqueue("xfslogd"); 1830 xfslogd_workqueue = create_freezeable_workqueue("xfslogd");
1830 if (!xfslogd_workqueue) 1831 if (!xfslogd_workqueue)
1831 goto out_free_buf_zone; 1832 goto out_free_buf_zone;
1832 1833
1833 xfsdatad_workqueue = create_workqueue("xfsdatad"); 1834 xfsdatad_workqueue = create_freezeable_workqueue("xfsdatad");
1834 if (!xfsdatad_workqueue) 1835 if (!xfsdatad_workqueue)
1835 goto out_destroy_xfslogd_workqueue; 1836 goto out_destroy_xfslogd_workqueue;
1836 1837
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index de05abbbe7fd..b93265b7c79c 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -56,6 +56,7 @@
56#include <linux/mempool.h> 56#include <linux/mempool.h>
57#include <linux/writeback.h> 57#include <linux/writeback.h>
58#include <linux/kthread.h> 58#include <linux/kthread.h>
59#include <linux/freezer.h>
59 60
60STATIC struct quotactl_ops xfs_quotactl_operations; 61STATIC struct quotactl_ops xfs_quotactl_operations;
61STATIC struct super_operations xfs_super_operations; 62STATIC struct super_operations xfs_super_operations;
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index 47faf27913a5..7f1e92930b62 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -64,7 +64,7 @@
64/* Host-dependent types and defines */ 64/* Host-dependent types and defines */
65 65
66#define ACPI_MACHINE_WIDTH BITS_PER_LONG 66#define ACPI_MACHINE_WIDTH BITS_PER_LONG
67#define acpi_cache_t kmem_cache_t 67#define acpi_cache_t struct kmem_cache
68#define acpi_spinlock spinlock_t * 68#define acpi_spinlock spinlock_t *
69#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol); 69#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
70#define strtoul simple_strtoul 70#define strtoul simple_strtoul
diff --git a/include/asm-alpha/dma-mapping.h b/include/asm-alpha/dma-mapping.h
index b9ff4d8cb33a..57e09f5e3424 100644
--- a/include/asm-alpha/dma-mapping.h
+++ b/include/asm-alpha/dma-mapping.h
@@ -51,7 +51,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
51 51
52#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 52#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
53#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 53#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
54#define dma_is_consistent(dev) (1) 54#define dma_is_consistent(d, h) (1)
55 55
56int dma_set_mask(struct device *dev, u64 mask); 56int dma_set_mask(struct device *dev, u64 mask);
57 57
@@ -60,7 +60,7 @@ int dma_set_mask(struct device *dev, u64 mask);
60#define dma_sync_single_range(dev, addr, off, size, dir) do { } while (0) 60#define dma_sync_single_range(dev, addr, off, size, dir) do { } while (0)
61#define dma_sync_sg_for_cpu(dev, sg, nents, dir) do { } while (0) 61#define dma_sync_sg_for_cpu(dev, sg, nents, dir) do { } while (0)
62#define dma_sync_sg_for_device(dev, sg, nents, dir) do { } while (0) 62#define dma_sync_sg_for_device(dev, sg, nents, dir) do { } while (0)
63#define dma_cache_sync(va, size, dir) do { } while (0) 63#define dma_cache_sync(dev, va, size, dir) do { } while (0)
64 64
65#define dma_get_cache_alignment() L1_CACHE_BYTES 65#define dma_get_cache_alignment() L1_CACHE_BYTES
66 66
diff --git a/include/asm-alpha/unistd.h b/include/asm-alpha/unistd.h
index 2cabbd465c0c..84313d14e780 100644
--- a/include/asm-alpha/unistd.h
+++ b/include/asm-alpha/unistd.h
@@ -387,188 +387,6 @@
387 387
388#define NR_SYSCALLS 447 388#define NR_SYSCALLS 447
389 389
390#if defined(__GNUC__)
391
392#define _syscall_return(type) \
393 return (_sc_err ? errno = _sc_ret, _sc_ret = -1L : 0), (type) _sc_ret
394
395#define _syscall_clobbers \
396 "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", \
397 "$22", "$23", "$24", "$25", "$27", "$28" \
398
399#define _syscall0(type, name) \
400type name(void) \
401{ \
402 long _sc_ret, _sc_err; \
403 { \
404 register long _sc_0 __asm__("$0"); \
405 register long _sc_19 __asm__("$19"); \
406 \
407 _sc_0 = __NR_##name; \
408 __asm__("callsys # %0 %1 %2" \
409 : "=r"(_sc_0), "=r"(_sc_19) \
410 : "0"(_sc_0) \
411 : _syscall_clobbers); \
412 _sc_ret = _sc_0, _sc_err = _sc_19; \
413 } \
414 _syscall_return(type); \
415}
416
417#define _syscall1(type,name,type1,arg1) \
418type name(type1 arg1) \
419{ \
420 long _sc_ret, _sc_err; \
421 { \
422 register long _sc_0 __asm__("$0"); \
423 register long _sc_16 __asm__("$16"); \
424 register long _sc_19 __asm__("$19"); \
425 \
426 _sc_0 = __NR_##name; \
427 _sc_16 = (long) (arg1); \
428 __asm__("callsys # %0 %1 %2 %3" \
429 : "=r"(_sc_0), "=r"(_sc_19) \
430 : "0"(_sc_0), "r"(_sc_16) \
431 : _syscall_clobbers); \
432 _sc_ret = _sc_0, _sc_err = _sc_19; \
433 } \
434 _syscall_return(type); \
435}
436
437#define _syscall2(type,name,type1,arg1,type2,arg2) \
438type name(type1 arg1,type2 arg2) \
439{ \
440 long _sc_ret, _sc_err; \
441 { \
442 register long _sc_0 __asm__("$0"); \
443 register long _sc_16 __asm__("$16"); \
444 register long _sc_17 __asm__("$17"); \
445 register long _sc_19 __asm__("$19"); \
446 \
447 _sc_0 = __NR_##name; \
448 _sc_16 = (long) (arg1); \
449 _sc_17 = (long) (arg2); \
450 __asm__("callsys # %0 %1 %2 %3 %4" \
451 : "=r"(_sc_0), "=r"(_sc_19) \
452 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17) \
453 : _syscall_clobbers); \
454 _sc_ret = _sc_0, _sc_err = _sc_19; \
455 } \
456 _syscall_return(type); \
457}
458
459#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
460type name(type1 arg1,type2 arg2,type3 arg3) \
461{ \
462 long _sc_ret, _sc_err; \
463 { \
464 register long _sc_0 __asm__("$0"); \
465 register long _sc_16 __asm__("$16"); \
466 register long _sc_17 __asm__("$17"); \
467 register long _sc_18 __asm__("$18"); \
468 register long _sc_19 __asm__("$19"); \
469 \
470 _sc_0 = __NR_##name; \
471 _sc_16 = (long) (arg1); \
472 _sc_17 = (long) (arg2); \
473 _sc_18 = (long) (arg3); \
474 __asm__("callsys # %0 %1 %2 %3 %4 %5" \
475 : "=r"(_sc_0), "=r"(_sc_19) \
476 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
477 "r"(_sc_18) \
478 : _syscall_clobbers); \
479 _sc_ret = _sc_0, _sc_err = _sc_19; \
480 } \
481 _syscall_return(type); \
482}
483
484#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
485type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
486{ \
487 long _sc_ret, _sc_err; \
488 { \
489 register long _sc_0 __asm__("$0"); \
490 register long _sc_16 __asm__("$16"); \
491 register long _sc_17 __asm__("$17"); \
492 register long _sc_18 __asm__("$18"); \
493 register long _sc_19 __asm__("$19"); \
494 \
495 _sc_0 = __NR_##name; \
496 _sc_16 = (long) (arg1); \
497 _sc_17 = (long) (arg2); \
498 _sc_18 = (long) (arg3); \
499 _sc_19 = (long) (arg4); \
500 __asm__("callsys # %0 %1 %2 %3 %4 %5 %6" \
501 : "=r"(_sc_0), "=r"(_sc_19) \
502 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
503 "r"(_sc_18), "1"(_sc_19) \
504 : _syscall_clobbers); \
505 _sc_ret = _sc_0, _sc_err = _sc_19; \
506 } \
507 _syscall_return(type); \
508}
509
510#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
511 type5,arg5) \
512type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
513{ \
514 long _sc_ret, _sc_err; \
515 { \
516 register long _sc_0 __asm__("$0"); \
517 register long _sc_16 __asm__("$16"); \
518 register long _sc_17 __asm__("$17"); \
519 register long _sc_18 __asm__("$18"); \
520 register long _sc_19 __asm__("$19"); \
521 register long _sc_20 __asm__("$20"); \
522 \
523 _sc_0 = __NR_##name; \
524 _sc_16 = (long) (arg1); \
525 _sc_17 = (long) (arg2); \
526 _sc_18 = (long) (arg3); \
527 _sc_19 = (long) (arg4); \
528 _sc_20 = (long) (arg5); \
529 __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7" \
530 : "=r"(_sc_0), "=r"(_sc_19) \
531 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
532 "r"(_sc_18), "1"(_sc_19), "r"(_sc_20) \
533 : _syscall_clobbers); \
534 _sc_ret = _sc_0, _sc_err = _sc_19; \
535 } \
536 _syscall_return(type); \
537}
538
539#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
540 type5,arg5,type6,arg6) \
541type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6)\
542{ \
543 long _sc_ret, _sc_err; \
544 { \
545 register long _sc_0 __asm__("$0"); \
546 register long _sc_16 __asm__("$16"); \
547 register long _sc_17 __asm__("$17"); \
548 register long _sc_18 __asm__("$18"); \
549 register long _sc_19 __asm__("$19"); \
550 register long _sc_20 __asm__("$20"); \
551 register long _sc_21 __asm__("$21"); \
552 \
553 _sc_0 = __NR_##name; \
554 _sc_16 = (long) (arg1); \
555 _sc_17 = (long) (arg2); \
556 _sc_18 = (long) (arg3); \
557 _sc_19 = (long) (arg4); \
558 _sc_20 = (long) (arg5); \
559 _sc_21 = (long) (arg6); \
560 __asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7 %8" \
561 : "=r"(_sc_0), "=r"(_sc_19) \
562 : "0"(_sc_0), "r"(_sc_16), "r"(_sc_17), \
563 "r"(_sc_18), "1"(_sc_19), "r"(_sc_20), "r"(_sc_21) \
564 : _syscall_clobbers); \
565 _sc_ret = _sc_0, _sc_err = _sc_19; \
566 } \
567 _syscall_return(type); \
568}
569
570#endif /* __GNUC__ */
571
572#define __ARCH_WANT_IPC_PARSE_VERSION 390#define __ARCH_WANT_IPC_PARSE_VERSION
573#define __ARCH_WANT_OLD_READDIR 391#define __ARCH_WANT_OLD_READDIR
574#define __ARCH_WANT_STAT64 392#define __ARCH_WANT_STAT64
diff --git a/include/asm-arm/dma-mapping.h b/include/asm-arm/dma-mapping.h
index 666617711c81..9bc46b486afb 100644
--- a/include/asm-arm/dma-mapping.h
+++ b/include/asm-arm/dma-mapping.h
@@ -48,7 +48,7 @@ static inline int dma_get_cache_alignment(void)
48 return 32; 48 return 32;
49} 49}
50 50
51static inline int dma_is_consistent(dma_addr_t handle) 51static inline int dma_is_consistent(struct device *dev, dma_addr_t handle)
52{ 52{
53 return !!arch_is_coherent(); 53 return !!arch_is_coherent();
54} 54}
diff --git a/include/asm-arm/setup.h b/include/asm-arm/setup.h
index aa4b5782f0c9..e5407392afca 100644
--- a/include/asm-arm/setup.h
+++ b/include/asm-arm/setup.h
@@ -14,55 +14,57 @@
14#ifndef __ASMARM_SETUP_H 14#ifndef __ASMARM_SETUP_H
15#define __ASMARM_SETUP_H 15#define __ASMARM_SETUP_H
16 16
17#include <asm/types.h>
18
17#define COMMAND_LINE_SIZE 1024 19#define COMMAND_LINE_SIZE 1024
18 20
19/* The list ends with an ATAG_NONE node. */ 21/* The list ends with an ATAG_NONE node. */
20#define ATAG_NONE 0x00000000 22#define ATAG_NONE 0x00000000
21 23
22struct tag_header { 24struct tag_header {
23 u32 size; 25 __u32 size;
24 u32 tag; 26 __u32 tag;
25}; 27};
26 28
27/* The list must start with an ATAG_CORE node */ 29/* The list must start with an ATAG_CORE node */
28#define ATAG_CORE 0x54410001 30#define ATAG_CORE 0x54410001
29 31
30struct tag_core { 32struct tag_core {
31 u32 flags; /* bit 0 = read-only */ 33 __u32 flags; /* bit 0 = read-only */
32 u32 pagesize; 34 __u32 pagesize;
33 u32 rootdev; 35 __u32 rootdev;
34}; 36};
35 37
36/* it is allowed to have multiple ATAG_MEM nodes */ 38/* it is allowed to have multiple ATAG_MEM nodes */
37#define ATAG_MEM 0x54410002 39#define ATAG_MEM 0x54410002
38 40
39struct tag_mem32 { 41struct tag_mem32 {
40 u32 size; 42 __u32 size;
41 u32 start; /* physical start address */ 43 __u32 start; /* physical start address */
42}; 44};
43 45
44/* VGA text type displays */ 46/* VGA text type displays */
45#define ATAG_VIDEOTEXT 0x54410003 47#define ATAG_VIDEOTEXT 0x54410003
46 48
47struct tag_videotext { 49struct tag_videotext {
48 u8 x; 50 __u8 x;
49 u8 y; 51 __u8 y;
50 u16 video_page; 52 __u16 video_page;
51 u8 video_mode; 53 __u8 video_mode;
52 u8 video_cols; 54 __u8 video_cols;
53 u16 video_ega_bx; 55 __u16 video_ega_bx;
54 u8 video_lines; 56 __u8 video_lines;
55 u8 video_isvga; 57 __u8 video_isvga;
56 u16 video_points; 58 __u16 video_points;
57}; 59};
58 60
59/* describes how the ramdisk will be used in kernel */ 61/* describes how the ramdisk will be used in kernel */
60#define ATAG_RAMDISK 0x54410004 62#define ATAG_RAMDISK 0x54410004
61 63
62struct tag_ramdisk { 64struct tag_ramdisk {
63 u32 flags; /* bit 0 = load, bit 1 = prompt */ 65 __u32 flags; /* bit 0 = load, bit 1 = prompt */
64 u32 size; /* decompressed ramdisk size in _kilo_ bytes */ 66 __u32 size; /* decompressed ramdisk size in _kilo_ bytes */
65 u32 start; /* starting block of floppy-based RAM disk image */ 67 __u32 start; /* starting block of floppy-based RAM disk image */
66}; 68};
67 69
68/* describes where the compressed ramdisk image lives (virtual address) */ 70/* describes where the compressed ramdisk image lives (virtual address) */
@@ -76,23 +78,23 @@ struct tag_ramdisk {
76#define ATAG_INITRD2 0x54420005 78#define ATAG_INITRD2 0x54420005
77 79
78struct tag_initrd { 80struct tag_initrd {
79 u32 start; /* physical start address */ 81 __u32 start; /* physical start address */
80 u32 size; /* size of compressed ramdisk image in bytes */ 82 __u32 size; /* size of compressed ramdisk image in bytes */
81}; 83};
82 84
83/* board serial number. "64 bits should be enough for everybody" */ 85/* board serial number. "64 bits should be enough for everybody" */
84#define ATAG_SERIAL 0x54410006 86#define ATAG_SERIAL 0x54410006
85 87
86struct tag_serialnr { 88struct tag_serialnr {
87 u32 low; 89 __u32 low;
88 u32 high; 90 __u32 high;
89}; 91};
90 92
91/* board revision */ 93/* board revision */
92#define ATAG_REVISION 0x54410007 94#define ATAG_REVISION 0x54410007
93 95
94struct tag_revision { 96struct tag_revision {
95 u32 rev; 97 __u32 rev;
96}; 98};
97 99
98/* initial values for vesafb-type framebuffers. see struct screen_info 100/* initial values for vesafb-type framebuffers. see struct screen_info
@@ -101,20 +103,20 @@ struct tag_revision {
101#define ATAG_VIDEOLFB 0x54410008 103#define ATAG_VIDEOLFB 0x54410008
102 104
103struct tag_videolfb { 105struct tag_videolfb {
104 u16 lfb_width; 106 __u16 lfb_width;
105 u16 lfb_height; 107 __u16 lfb_height;
106 u16 lfb_depth; 108 __u16 lfb_depth;
107 u16 lfb_linelength; 109 __u16 lfb_linelength;
108 u32 lfb_base; 110 __u32 lfb_base;
109 u32 lfb_size; 111 __u32 lfb_size;
110 u8 red_size; 112 __u8 red_size;
111 u8 red_pos; 113 __u8 red_pos;
112 u8 green_size; 114 __u8 green_size;
113 u8 green_pos; 115 __u8 green_pos;
114 u8 blue_size; 116 __u8 blue_size;
115 u8 blue_pos; 117 __u8 blue_pos;
116 u8 rsvd_size; 118 __u8 rsvd_size;
117 u8 rsvd_pos; 119 __u8 rsvd_pos;
118}; 120};
119 121
120/* command line: \0 terminated string */ 122/* command line: \0 terminated string */
@@ -128,17 +130,17 @@ struct tag_cmdline {
128#define ATAG_ACORN 0x41000101 130#define ATAG_ACORN 0x41000101
129 131
130struct tag_acorn { 132struct tag_acorn {
131 u32 memc_control_reg; 133 __u32 memc_control_reg;
132 u32 vram_pages; 134 __u32 vram_pages;
133 u8 sounddefault; 135 __u8 sounddefault;
134 u8 adfsdrives; 136 __u8 adfsdrives;
135}; 137};
136 138
137/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */ 139/* footbridge memory clock, see arch/arm/mach-footbridge/arch.c */
138#define ATAG_MEMCLK 0x41000402 140#define ATAG_MEMCLK 0x41000402
139 141
140struct tag_memclk { 142struct tag_memclk {
141 u32 fmemclk; 143 __u32 fmemclk;
142}; 144};
143 145
144struct tag { 146struct tag {
@@ -167,24 +169,26 @@ struct tag {
167}; 169};
168 170
169struct tagtable { 171struct tagtable {
170 u32 tag; 172 __u32 tag;
171 int (*parse)(const struct tag *); 173 int (*parse)(const struct tag *);
172}; 174};
173 175
174#define __tag __attribute_used__ __attribute__((__section__(".taglist.init")))
175#define __tagtable(tag, fn) \
176static struct tagtable __tagtable_##fn __tag = { tag, fn }
177
178#define tag_member_present(tag,member) \ 176#define tag_member_present(tag,member) \
179 ((unsigned long)(&((struct tag *)0L)->member + 1) \ 177 ((unsigned long)(&((struct tag *)0L)->member + 1) \
180 <= (tag)->hdr.size * 4) 178 <= (tag)->hdr.size * 4)
181 179
182#define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size)) 180#define tag_next(t) ((struct tag *)((__u32 *)(t) + (t)->hdr.size))
183#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) 181#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)
184 182
185#define for_each_tag(t,base) \ 183#define for_each_tag(t,base) \
186 for (t = base; t->hdr.size; t = tag_next(t)) 184 for (t = base; t->hdr.size; t = tag_next(t))
187 185
186#ifdef __KERNEL__
187
188#define __tag __attribute_used__ __attribute__((__section__(".taglist.init")))
189#define __tagtable(tag, fn) \
190static struct tagtable __tagtable_##fn __tag = { tag, fn }
191
188/* 192/*
189 * Memory map description 193 * Memory map description
190 */ 194 */
@@ -217,4 +221,6 @@ struct early_params {
217static struct early_params __early_##fn __attribute_used__ \ 221static struct early_params __early_##fn __attribute_used__ \
218__attribute__((__section__(".early_param.init"))) = { name, fn } 222__attribute__((__section__(".early_param.init"))) = { name, fn }
219 223
224#endif /* __KERNEL__ */
225
220#endif 226#endif
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
index 14a87eec5a2d..d44c629d8424 100644
--- a/include/asm-arm/unistd.h
+++ b/include/asm-arm/unistd.h
@@ -377,156 +377,6 @@
377#endif 377#endif
378 378
379#ifdef __KERNEL__ 379#ifdef __KERNEL__
380#include <linux/err.h>
381#include <linux/linkage.h>
382
383#define __sys2(x) #x
384#define __sys1(x) __sys2(x)
385
386#ifndef __syscall
387#if defined(__thumb__) || defined(__ARM_EABI__)
388#define __SYS_REG(name) register long __sysreg __asm__("r7") = __NR_##name;
389#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
390#define __syscall(name) "swi\t0"
391#else
392#define __SYS_REG(name)
393#define __SYS_REG_LIST(regs...) regs
394#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
395#endif
396#endif
397
398#define __syscall_return(type, res) \
399do { \
400 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
401 errno = -(res); \
402 res = -1; \
403 } \
404 return (type) (res); \
405} while (0)
406
407#define _syscall0(type,name) \
408type name(void) { \
409 __SYS_REG(name) \
410 register long __res_r0 __asm__("r0"); \
411 long __res; \
412 __asm__ __volatile__ ( \
413 __syscall(name) \
414 : "=r" (__res_r0) \
415 : __SYS_REG_LIST() \
416 : "memory" ); \
417 __res = __res_r0; \
418 __syscall_return(type,__res); \
419}
420
421#define _syscall1(type,name,type1,arg1) \
422type name(type1 arg1) { \
423 __SYS_REG(name) \
424 register long __r0 __asm__("r0") = (long)arg1; \
425 register long __res_r0 __asm__("r0"); \
426 long __res; \
427 __asm__ __volatile__ ( \
428 __syscall(name) \
429 : "=r" (__res_r0) \
430 : __SYS_REG_LIST( "0" (__r0) ) \
431 : "memory" ); \
432 __res = __res_r0; \
433 __syscall_return(type,__res); \
434}
435
436#define _syscall2(type,name,type1,arg1,type2,arg2) \
437type name(type1 arg1,type2 arg2) { \
438 __SYS_REG(name) \
439 register long __r0 __asm__("r0") = (long)arg1; \
440 register long __r1 __asm__("r1") = (long)arg2; \
441 register long __res_r0 __asm__("r0"); \
442 long __res; \
443 __asm__ __volatile__ ( \
444 __syscall(name) \
445 : "=r" (__res_r0) \
446 : __SYS_REG_LIST( "0" (__r0), "r" (__r1) ) \
447 : "memory" ); \
448 __res = __res_r0; \
449 __syscall_return(type,__res); \
450}
451
452
453#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
454type name(type1 arg1,type2 arg2,type3 arg3) { \
455 __SYS_REG(name) \
456 register long __r0 __asm__("r0") = (long)arg1; \
457 register long __r1 __asm__("r1") = (long)arg2; \
458 register long __r2 __asm__("r2") = (long)arg3; \
459 register long __res_r0 __asm__("r0"); \
460 long __res; \
461 __asm__ __volatile__ ( \
462 __syscall(name) \
463 : "=r" (__res_r0) \
464 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2) ) \
465 : "memory" ); \
466 __res = __res_r0; \
467 __syscall_return(type,__res); \
468}
469
470
471#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
472type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
473 __SYS_REG(name) \
474 register long __r0 __asm__("r0") = (long)arg1; \
475 register long __r1 __asm__("r1") = (long)arg2; \
476 register long __r2 __asm__("r2") = (long)arg3; \
477 register long __r3 __asm__("r3") = (long)arg4; \
478 register long __res_r0 __asm__("r0"); \
479 long __res; \
480 __asm__ __volatile__ ( \
481 __syscall(name) \
482 : "=r" (__res_r0) \
483 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) ) \
484 : "memory" ); \
485 __res = __res_r0; \
486 __syscall_return(type,__res); \
487}
488
489
490#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
491type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
492 __SYS_REG(name) \
493 register long __r0 __asm__("r0") = (long)arg1; \
494 register long __r1 __asm__("r1") = (long)arg2; \
495 register long __r2 __asm__("r2") = (long)arg3; \
496 register long __r3 __asm__("r3") = (long)arg4; \
497 register long __r4 __asm__("r4") = (long)arg5; \
498 register long __res_r0 __asm__("r0"); \
499 long __res; \
500 __asm__ __volatile__ ( \
501 __syscall(name) \
502 : "=r" (__res_r0) \
503 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), \
504 "r" (__r3), "r" (__r4) ) \
505 : "memory" ); \
506 __res = __res_r0; \
507 __syscall_return(type,__res); \
508}
509
510#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
511type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \
512 __SYS_REG(name) \
513 register long __r0 __asm__("r0") = (long)arg1; \
514 register long __r1 __asm__("r1") = (long)arg2; \
515 register long __r2 __asm__("r2") = (long)arg3; \
516 register long __r3 __asm__("r3") = (long)arg4; \
517 register long __r4 __asm__("r4") = (long)arg5; \
518 register long __r5 __asm__("r5") = (long)arg6; \
519 register long __res_r0 __asm__("r0"); \
520 long __res; \
521 __asm__ __volatile__ ( \
522 __syscall(name) \
523 : "=r" (__res_r0) \
524 : __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), \
525 "r" (__r3), "r" (__r4), "r" (__r5) ) \
526 : "memory" ); \
527 __res = __res_r0; \
528 __syscall_return(type,__res); \
529}
530 380
531#define __ARCH_WANT_IPC_PARSE_VERSION 381#define __ARCH_WANT_IPC_PARSE_VERSION
532#define __ARCH_WANT_STAT64 382#define __ARCH_WANT_STAT64
diff --git a/include/asm-arm26/pgalloc.h b/include/asm-arm26/pgalloc.h
index 6437167b1ffe..7725af3ddb4d 100644
--- a/include/asm-arm26/pgalloc.h
+++ b/include/asm-arm26/pgalloc.h
@@ -15,7 +15,7 @@
15#include <asm/tlbflush.h> 15#include <asm/tlbflush.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17 17
18extern kmem_cache_t *pte_cache; 18extern struct kmem_cache *pte_cache;
19 19
20static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr){ 20static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long addr){
21 return kmem_cache_alloc(pte_cache, GFP_KERNEL); 21 return kmem_cache_alloc(pte_cache, GFP_KERNEL);
diff --git a/include/asm-arm26/setup.h b/include/asm-arm26/setup.h
index 6348931be65d..1a867b4e8d53 100644
--- a/include/asm-arm26/setup.h
+++ b/include/asm-arm26/setup.h
@@ -16,6 +16,8 @@
16 16
17#define COMMAND_LINE_SIZE 1024 17#define COMMAND_LINE_SIZE 1024
18 18
19#ifdef __KERNEL__
20
19/* The list ends with an ATAG_NONE node. */ 21/* The list ends with an ATAG_NONE node. */
20#define ATAG_NONE 0x00000000 22#define ATAG_NONE 0x00000000
21 23
@@ -202,4 +204,6 @@ struct meminfo {
202 204
203extern struct meminfo meminfo; 205extern struct meminfo meminfo;
204 206
207#endif /* __KERNEL__ */
208
205#endif 209#endif
diff --git a/include/asm-arm26/unistd.h b/include/asm-arm26/unistd.h
index 25a5eead85be..4c3b919177e5 100644
--- a/include/asm-arm26/unistd.h
+++ b/include/asm-arm26/unistd.h
@@ -311,139 +311,6 @@
311#define __ARM_NR_usr26 (__ARM_NR_BASE+3) 311#define __ARM_NR_usr26 (__ARM_NR_BASE+3)
312 312
313#ifdef __KERNEL__ 313#ifdef __KERNEL__
314#include <linux/err.h>
315#include <linux/linkage.h>
316
317#define __sys2(x) #x
318#define __sys1(x) __sys2(x)
319
320#ifndef __syscall
321#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
322#endif
323
324#define __syscall_return(type, res) \
325do { \
326 if ((unsigned long)(res) >= (unsigned long)-MAX_ERRNO) { \
327 errno = -(res); \
328 res = -1; \
329 } \
330 return (type) (res); \
331} while (0)
332
333#define _syscall0(type,name) \
334type name(void) { \
335 register long __res_r0 __asm__("r0"); \
336 long __res; \
337 __asm__ __volatile__ ( \
338 __syscall(name) \
339 : "=r" (__res_r0) \
340 : \
341 : "lr"); \
342 __res = __res_r0; \
343 __syscall_return(type,__res); \
344}
345
346#define _syscall1(type,name,type1,arg1) \
347type name(type1 arg1) { \
348 register long __r0 __asm__("r0") = (long)arg1; \
349 register long __res_r0 __asm__("r0"); \
350 long __res; \
351 __asm__ __volatile__ ( \
352 __syscall(name) \
353 : "=r" (__res_r0) \
354 : "r" (__r0) \
355 : "lr"); \
356 __res = __res_r0; \
357 __syscall_return(type,__res); \
358}
359
360#define _syscall2(type,name,type1,arg1,type2,arg2) \
361type name(type1 arg1,type2 arg2) { \
362 register long __r0 __asm__("r0") = (long)arg1; \
363 register long __r1 __asm__("r1") = (long)arg2; \
364 register long __res_r0 __asm__("r0"); \
365 long __res; \
366 __asm__ __volatile__ ( \
367 __syscall(name) \
368 : "=r" (__res_r0) \
369 : "r" (__r0),"r" (__r1) \
370 : "lr"); \
371 __res = __res_r0; \
372 __syscall_return(type,__res); \
373}
374
375
376#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
377type name(type1 arg1,type2 arg2,type3 arg3) { \
378 register long __r0 __asm__("r0") = (long)arg1; \
379 register long __r1 __asm__("r1") = (long)arg2; \
380 register long __r2 __asm__("r2") = (long)arg3; \
381 register long __res_r0 __asm__("r0"); \
382 long __res; \
383 __asm__ __volatile__ ( \
384 __syscall(name) \
385 : "=r" (__res_r0) \
386 : "r" (__r0),"r" (__r1),"r" (__r2) \
387 : "lr"); \
388 __res = __res_r0; \
389 __syscall_return(type,__res); \
390}
391
392
393#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
394type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
395 register long __r0 __asm__("r0") = (long)arg1; \
396 register long __r1 __asm__("r1") = (long)arg2; \
397 register long __r2 __asm__("r2") = (long)arg3; \
398 register long __r3 __asm__("r3") = (long)arg4; \
399 register long __res_r0 __asm__("r0"); \
400 long __res; \
401 __asm__ __volatile__ ( \
402 __syscall(name) \
403 : "=r" (__res_r0) \
404 : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3) \
405 : "lr"); \
406 __res = __res_r0; \
407 __syscall_return(type,__res); \
408}
409
410
411#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
412type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) { \
413 register long __r0 __asm__("r0") = (long)arg1; \
414 register long __r1 __asm__("r1") = (long)arg2; \
415 register long __r2 __asm__("r2") = (long)arg3; \
416 register long __r3 __asm__("r3") = (long)arg4; \
417 register long __r4 __asm__("r4") = (long)arg5; \
418 register long __res_r0 __asm__("r0"); \
419 long __res; \
420 __asm__ __volatile__ ( \
421 __syscall(name) \
422 : "=r" (__res_r0) \
423 : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3),"r" (__r4) \
424 : "lr"); \
425 __res = __res_r0; \
426 __syscall_return(type,__res); \
427}
428
429#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
430type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) { \
431 register long __r0 __asm__("r0") = (long)arg1; \
432 register long __r1 __asm__("r1") = (long)arg2; \
433 register long __r2 __asm__("r2") = (long)arg3; \
434 register long __r3 __asm__("r3") = (long)arg4; \
435 register long __r4 __asm__("r4") = (long)arg5; \
436 register long __r5 __asm__("r5") = (long)arg6; \
437 register long __res_r0 __asm__("r0"); \
438 long __res; \
439 __asm__ __volatile__ ( \
440 __syscall(name) \
441 : "=r" (__res_r0) \
442 : "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3), "r" (__r4),"r" (__r5) \
443 : "lr"); \
444 __res = __res_r0; \
445 __syscall_return(type,__res); \
446}
447 314
448#define __ARCH_WANT_IPC_PARSE_VERSION 315#define __ARCH_WANT_IPC_PARSE_VERSION
449#define __ARCH_WANT_OLD_READDIR 316#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-avr32/dma-mapping.h b/include/asm-avr32/dma-mapping.h
index 4c40cb41cdf8..0580b5d62bba 100644
--- a/include/asm-avr32/dma-mapping.h
+++ b/include/asm-avr32/dma-mapping.h
@@ -8,7 +8,8 @@
8#include <asm/cacheflush.h> 8#include <asm/cacheflush.h>
9#include <asm/io.h> 9#include <asm/io.h>
10 10
11extern void dma_cache_sync(void *vaddr, size_t size, int direction); 11extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
12 int direction);
12 13
13/* 14/*
14 * Return whether the given device DMA address mask can be supported 15 * Return whether the given device DMA address mask can be supported
@@ -307,7 +308,7 @@ dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
307#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 308#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
308#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 309#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
309 310
310static inline int dma_is_consistent(dma_addr_t dma_addr) 311static inline int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
311{ 312{
312 return 1; 313 return 1;
313} 314}
diff --git a/include/asm-avr32/setup.h b/include/asm-avr32/setup.h
index 10193da4113b..0a5224245e44 100644
--- a/include/asm-avr32/setup.h
+++ b/include/asm-avr32/setup.h
@@ -13,6 +13,8 @@
13 13
14#define COMMAND_LINE_SIZE 256 14#define COMMAND_LINE_SIZE 256
15 15
16#ifdef __KERNEL__
17
16/* Magic number indicating that a tag table is present */ 18/* Magic number indicating that a tag table is present */
17#define ATAG_MAGIC 0xa2a25441 19#define ATAG_MAGIC 0xa2a25441
18 20
@@ -138,4 +140,6 @@ void chip_enable_sdram(void);
138 140
139#endif /* !__ASSEMBLY__ */ 141#endif /* !__ASSEMBLY__ */
140 142
143#endif /* __KERNEL__ */
144
141#endif /* __ASM_AVR32_SETUP_H__ */ 145#endif /* __ASM_AVR32_SETUP_H__ */
diff --git a/include/asm-cris/arch-v10/bitops.h b/include/asm-cris/arch-v10/bitops.h
index b73f5396e5a6..be85f6de25d3 100644
--- a/include/asm-cris/arch-v10/bitops.h
+++ b/include/asm-cris/arch-v10/bitops.h
@@ -10,7 +10,7 @@
10 * number. They differ in that the first function also inverts all bits 10 * number. They differ in that the first function also inverts all bits
11 * in the input. 11 * in the input.
12 */ 12 */
13extern inline unsigned long cris_swapnwbrlz(unsigned long w) 13static inline unsigned long cris_swapnwbrlz(unsigned long w)
14{ 14{
15 /* Let's just say we return the result in the same register as the 15 /* Let's just say we return the result in the same register as the
16 input. Saying we clobber the input but can return the result 16 input. Saying we clobber the input but can return the result
@@ -26,7 +26,7 @@ extern inline unsigned long cris_swapnwbrlz(unsigned long w)
26 return res; 26 return res;
27} 27}
28 28
29extern inline unsigned long cris_swapwbrlz(unsigned long w) 29static inline unsigned long cris_swapwbrlz(unsigned long w)
30{ 30{
31 unsigned res; 31 unsigned res;
32 __asm__ ("swapwbr %0 \n\t" 32 __asm__ ("swapwbr %0 \n\t"
@@ -40,7 +40,7 @@ extern inline unsigned long cris_swapwbrlz(unsigned long w)
40 * ffz = Find First Zero in word. Undefined if no zero exists, 40 * ffz = Find First Zero in word. Undefined if no zero exists,
41 * so code should check against ~0UL first.. 41 * so code should check against ~0UL first..
42 */ 42 */
43extern inline unsigned long ffz(unsigned long w) 43static inline unsigned long ffz(unsigned long w)
44{ 44{
45 return cris_swapnwbrlz(w); 45 return cris_swapnwbrlz(w);
46} 46}
@@ -51,7 +51,7 @@ extern inline unsigned long ffz(unsigned long w)
51 * 51 *
52 * Undefined if no bit exists, so code should check against 0 first. 52 * Undefined if no bit exists, so code should check against 0 first.
53 */ 53 */
54extern inline unsigned long __ffs(unsigned long word) 54static inline unsigned long __ffs(unsigned long word)
55{ 55{
56 return cris_swapnwbrlz(~word); 56 return cris_swapnwbrlz(~word);
57} 57}
@@ -65,7 +65,7 @@ extern inline unsigned long __ffs(unsigned long word)
65 * differs in spirit from the above ffz (man ffs). 65 * differs in spirit from the above ffz (man ffs).
66 */ 66 */
67 67
68extern inline unsigned long kernel_ffs(unsigned long w) 68static inline unsigned long kernel_ffs(unsigned long w)
69{ 69{
70 return w ? cris_swapwbrlz (w) + 1 : 0; 70 return w ? cris_swapwbrlz (w) + 1 : 0;
71} 71}
diff --git a/include/asm-cris/dma-mapping.h b/include/asm-cris/dma-mapping.h
index cbf1a98f0129..662cea70152d 100644
--- a/include/asm-cris/dma-mapping.h
+++ b/include/asm-cris/dma-mapping.h
@@ -156,10 +156,10 @@ dma_get_cache_alignment(void)
156 return (1 << INTERNODE_CACHE_SHIFT); 156 return (1 << INTERNODE_CACHE_SHIFT);
157} 157}
158 158
159#define dma_is_consistent(d) (1) 159#define dma_is_consistent(d, h) (1)
160 160
161static inline void 161static inline void
162dma_cache_sync(void *vaddr, size_t size, 162dma_cache_sync(struct device *dev, void *vaddr, size_t size,
163 enum dma_data_direction direction) 163 enum dma_data_direction direction)
164{ 164{
165} 165}
diff --git a/include/asm-cris/semaphore-helper.h b/include/asm-cris/semaphore-helper.h
index dbd0f30b85b6..a8e1e6cb7cd0 100644
--- a/include/asm-cris/semaphore-helper.h
+++ b/include/asm-cris/semaphore-helper.h
@@ -20,12 +20,12 @@
20/* 20/*
21 * These two _must_ execute atomically wrt each other. 21 * These two _must_ execute atomically wrt each other.
22 */ 22 */
23extern inline void wake_one_more(struct semaphore * sem) 23static inline void wake_one_more(struct semaphore * sem)
24{ 24{
25 atomic_inc(&sem->waking); 25 atomic_inc(&sem->waking);
26} 26}
27 27
28extern inline int waking_non_zero(struct semaphore *sem) 28static inline int waking_non_zero(struct semaphore *sem)
29{ 29{
30 unsigned long flags; 30 unsigned long flags;
31 int ret = 0; 31 int ret = 0;
@@ -40,7 +40,7 @@ extern inline int waking_non_zero(struct semaphore *sem)
40 return ret; 40 return ret;
41} 41}
42 42
43extern inline int waking_non_zero_interruptible(struct semaphore *sem, 43static inline int waking_non_zero_interruptible(struct semaphore *sem,
44 struct task_struct *tsk) 44 struct task_struct *tsk)
45{ 45{
46 int ret = 0; 46 int ret = 0;
@@ -59,7 +59,7 @@ extern inline int waking_non_zero_interruptible(struct semaphore *sem,
59 return ret; 59 return ret;
60} 60}
61 61
62extern inline int waking_non_zero_trylock(struct semaphore *sem) 62static inline int waking_non_zero_trylock(struct semaphore *sem)
63{ 63{
64 int ret = 1; 64 int ret = 1;
65 unsigned long flags; 65 unsigned long flags;
diff --git a/include/asm-frv/dma-mapping.h b/include/asm-frv/dma-mapping.h
index e9fc1d47797e..bcb2df68496e 100644
--- a/include/asm-frv/dma-mapping.h
+++ b/include/asm-frv/dma-mapping.h
@@ -172,10 +172,10 @@ int dma_get_cache_alignment(void)
172 return 1 << L1_CACHE_SHIFT; 172 return 1 << L1_CACHE_SHIFT;
173} 173}
174 174
175#define dma_is_consistent(d) (1) 175#define dma_is_consistent(d, h) (1)
176 176
177static inline 177static inline
178void dma_cache_sync(void *vaddr, size_t size, 178void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
179 enum dma_data_direction direction) 179 enum dma_data_direction direction)
180{ 180{
181 flush_write_buffers(); 181 flush_write_buffers();
diff --git a/include/asm-frv/highmem.h b/include/asm-frv/highmem.h
index 0f390f41f816..ff4d6cdeb152 100644
--- a/include/asm-frv/highmem.h
+++ b/include/asm-frv/highmem.h
@@ -115,7 +115,7 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
115{ 115{
116 unsigned long paddr; 116 unsigned long paddr;
117 117
118 inc_preempt_count(); 118 pagefault_disable();
119 paddr = page_to_phys(page); 119 paddr = page_to_phys(page);
120 120
121 switch (type) { 121 switch (type) {
@@ -170,8 +170,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
170 default: 170 default:
171 BUG(); 171 BUG();
172 } 172 }
173 dec_preempt_count(); 173 pagefault_enable();
174 preempt_check_resched();
175} 174}
176 175
177#endif /* !__ASSEMBLY__ */ 176#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-frv/param.h b/include/asm-frv/param.h
index 168381ebb41a..365653b1726c 100644
--- a/include/asm-frv/param.h
+++ b/include/asm-frv/param.h
@@ -18,6 +18,5 @@
18#endif 18#endif
19 19
20#define MAXHOSTNAMELEN 64 /* max length of hostname */ 20#define MAXHOSTNAMELEN 64 /* max length of hostname */
21#define COMMAND_LINE_SIZE 512
22 21
23#endif /* _ASM_PARAM_H */ 22#endif /* _ASM_PARAM_H */
diff --git a/include/asm-frv/setup.h b/include/asm-frv/setup.h
index 0d293b9a5857..afd787ceede6 100644
--- a/include/asm-frv/setup.h
+++ b/include/asm-frv/setup.h
@@ -12,6 +12,10 @@
12#ifndef _ASM_SETUP_H 12#ifndef _ASM_SETUP_H
13#define _ASM_SETUP_H 13#define _ASM_SETUP_H
14 14
15#define COMMAND_LINE_SIZE 512
16
17#ifdef __KERNEL__
18
15#include <linux/init.h> 19#include <linux/init.h>
16 20
17#ifndef __ASSEMBLY__ 21#ifndef __ASSEMBLY__
@@ -22,4 +26,6 @@ extern unsigned long __initdata num_mappedpages;
22 26
23#endif /* !__ASSEMBLY__ */ 27#endif /* !__ASSEMBLY__ */
24 28
29#endif /* __KERNEL__ */
30
25#endif /* _ASM_SETUP_H */ 31#endif /* _ASM_SETUP_H */
diff --git a/include/asm-frv/unistd.h b/include/asm-frv/unistd.h
index 725e854928cf..584c0417ae4d 100644
--- a/include/asm-frv/unistd.h
+++ b/include/asm-frv/unistd.h
@@ -320,125 +320,6 @@
320#ifdef __KERNEL__ 320#ifdef __KERNEL__
321 321
322#define NR_syscalls 310 322#define NR_syscalls 310
323#include <linux/err.h>
324
325/*
326 * process the return value of a syscall, consigning it to one of two possible fates
327 * - user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h>
328 */
329#undef __syscall_return
330#define __syscall_return(type, res) \
331do { \
332 unsigned long __sr2 = (res); \
333 if (__builtin_expect(__sr2 >= (unsigned long)(-MAX_ERRNO), 0)) { \
334 errno = (-__sr2); \
335 __sr2 = ~0UL; \
336 } \
337 return (type) __sr2; \
338} while (0)
339
340/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
341
342#undef _syscall0
343#define _syscall0(type,name) \
344type name(void) \
345{ \
346 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
347 register unsigned long __sc0 __asm__ ("gr8"); \
348 __asm__ __volatile__ ("tira gr0,#0" \
349 : "=r" (__sc0) \
350 : "r" (__scnum)); \
351 __syscall_return(type, __sc0); \
352}
353
354#undef _syscall1
355#define _syscall1(type,name,type1,arg1) \
356type name(type1 arg1) \
357{ \
358 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
359 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
360 __asm__ __volatile__ ("tira gr0,#0" \
361 : "+r" (__sc0) \
362 : "r" (__scnum)); \
363 __syscall_return(type, __sc0); \
364}
365
366#undef _syscall2
367#define _syscall2(type,name,type1,arg1,type2,arg2) \
368type name(type1 arg1,type2 arg2) \
369{ \
370 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
371 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
372 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
373 __asm__ __volatile__ ("tira gr0,#0" \
374 : "+r" (__sc0) \
375 : "r" (__scnum), "r" (__sc1)); \
376 __syscall_return(type, __sc0); \
377}
378
379#undef _syscall3
380#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
381type name(type1 arg1,type2 arg2,type3 arg3) \
382{ \
383 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
384 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
385 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
386 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
387 __asm__ __volatile__ ("tira gr0,#0" \
388 : "+r" (__sc0) \
389 : "r" (__scnum), "r" (__sc1), "r" (__sc2)); \
390 __syscall_return(type, __sc0); \
391}
392
393#undef _syscall4
394#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
395type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
396{ \
397 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
398 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
399 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
400 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
401 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
402 __asm__ __volatile__ ("tira gr0,#0" \
403 : "+r" (__sc0) \
404 : "r" (__scnum), "r" (__sc1), "r" (__sc2), "r" (__sc3)); \
405 __syscall_return(type, __sc0); \
406}
407
408#undef _syscall5
409#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
410type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
411{ \
412 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
413 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
414 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
415 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
416 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
417 register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
418 __asm__ __volatile__ ("tira gr0,#0" \
419 : "+r" (__sc0) \
420 : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
421 "r" (__sc3), "r" (__sc4)); \
422 __syscall_return(type, __sc0); \
423}
424
425#undef _syscall6
426#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
427type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
428{ \
429 register unsigned long __scnum __asm__ ("gr7") = (__NR_##name); \
430 register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1; \
431 register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2; \
432 register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3; \
433 register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4; \
434 register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5; \
435 register unsigned long __sc5 __asm__ ("gr13") = (unsigned long) arg6; \
436 __asm__ __volatile__ ("tira gr0,#0" \
437 : "+r" (__sc0) \
438 : "r" (__scnum), "r" (__sc1), "r" (__sc2), \
439 "r" (__sc3), "r" (__sc4), "r" (__sc5)); \
440 __syscall_return(type, __sc0); \
441}
442 323
443#define __ARCH_WANT_IPC_PARSE_VERSION 324#define __ARCH_WANT_IPC_PARSE_VERSION
444/* #define __ARCH_WANT_OLD_READDIR */ 325/* #define __ARCH_WANT_OLD_READDIR */
diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild
index 3c06be381701..fa14f8cd30c5 100644
--- a/include/asm-generic/Kbuild
+++ b/include/asm-generic/Kbuild
@@ -1,4 +1,3 @@
1header-y += atomic.h
2header-y += errno-base.h 1header-y += errno-base.h
3header-y += errno.h 2header-y += errno.h
4header-y += fcntl.h 3header-y += fcntl.h
diff --git a/include/asm-generic/Kbuild.asm b/include/asm-generic/Kbuild.asm
index a84c3d88a189..a37e95fe58d6 100644
--- a/include/asm-generic/Kbuild.asm
+++ b/include/asm-generic/Kbuild.asm
@@ -14,6 +14,7 @@ unifdef-y += posix_types.h
14unifdef-y += ptrace.h 14unifdef-y += ptrace.h
15unifdef-y += resource.h 15unifdef-y += resource.h
16unifdef-y += sembuf.h 16unifdef-y += sembuf.h
17unifdef-y += setup.h
17unifdef-y += shmbuf.h 18unifdef-y += shmbuf.h
18unifdef-y += sigcontext.h 19unifdef-y += sigcontext.h
19unifdef-y += siginfo.h 20unifdef-y += siginfo.h
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index 42a95d9a0641..b7e4a0467cb1 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -66,7 +66,7 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66 atomic64_sub(i, v); 66 atomic64_sub(i, v);
67} 67}
68 68
69#else 69#else /* BITS_PER_LONG == 64 */
70 70
71typedef atomic_t atomic_long_t; 71typedef atomic_t atomic_long_t;
72 72
@@ -113,5 +113,6 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
113 atomic_sub(i, v); 113 atomic_sub(i, v);
114} 114}
115 115
116#endif 116#endif /* BITS_PER_LONG == 64 */
117#endif 117
118#endif /* _ASM_GENERIC_ATOMIC_H */
diff --git a/include/asm-generic/dma-mapping.h b/include/asm-generic/dma-mapping.h
index b541e48cc545..783ab9944d70 100644
--- a/include/asm-generic/dma-mapping.h
+++ b/include/asm-generic/dma-mapping.h
@@ -266,7 +266,7 @@ dma_error(dma_addr_t dma_addr)
266 266
267#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 267#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
268#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 268#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
269#define dma_is_consistent(d) (1) 269#define dma_is_consistent(d, h) (1)
270 270
271static inline int 271static inline int
272dma_get_cache_alignment(void) 272dma_get_cache_alignment(void)
@@ -295,7 +295,7 @@ dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
295} 295}
296 296
297static inline void 297static inline void
298dma_cache_sync(void *vaddr, size_t size, 298dma_cache_sync(struct device *dev, void *vaddr, size_t size,
299 enum dma_data_direction direction) 299 enum dma_data_direction direction)
300{ 300{
301 /* could define this in terms of the dma_cache ... operations, 301 /* could define this in terms of the dma_cache ... operations,
diff --git a/include/asm-generic/futex.h b/include/asm-generic/futex.h
index df893c160318..f422df0956a2 100644
--- a/include/asm-generic/futex.h
+++ b/include/asm-generic/futex.h
@@ -21,7 +21,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
21 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 21 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
22 return -EFAULT; 22 return -EFAULT;
23 23
24 inc_preempt_count(); 24 pagefault_disable();
25 25
26 switch (op) { 26 switch (op) {
27 case FUTEX_OP_SET: 27 case FUTEX_OP_SET:
@@ -33,7 +33,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
33 ret = -ENOSYS; 33 ret = -ENOSYS;
34 } 34 }
35 35
36 dec_preempt_count(); 36 pagefault_enable();
37 37
38 if (!ret) { 38 if (!ret) {
39 switch (cmp) { 39 switch (cmp) {
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index e60d6f21fa62..4d4c62d11059 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -11,8 +11,8 @@
11 11
12#define RODATA \ 12#define RODATA \
13 . = ALIGN(4096); \ 13 . = ALIGN(4096); \
14 __start_rodata = .; \
15 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \ 14 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
15 VMLINUX_SYMBOL(__start_rodata) = .; \
16 *(.rodata) *(.rodata.*) \ 16 *(.rodata) *(.rodata.*) \
17 *(__vermagic) /* Kernel version magic */ \ 17 *(__vermagic) /* Kernel version magic */ \
18 } \ 18 } \
@@ -119,17 +119,16 @@
119 *(__ksymtab_strings) \ 119 *(__ksymtab_strings) \
120 } \ 120 } \
121 \ 121 \
122 EH_FRAME \
123 \
122 /* Built-in module parameters. */ \ 124 /* Built-in module parameters. */ \
123 __param : AT(ADDR(__param) - LOAD_OFFSET) { \ 125 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
124 VMLINUX_SYMBOL(__start___param) = .; \ 126 VMLINUX_SYMBOL(__start___param) = .; \
125 *(__param) \ 127 *(__param) \
126 VMLINUX_SYMBOL(__stop___param) = .; \ 128 VMLINUX_SYMBOL(__stop___param) = .; \
129 VMLINUX_SYMBOL(__end_rodata) = .; \
127 } \ 130 } \
128 \ 131 \
129 /* Unwind data binary search table */ \
130 EH_FRAME_HDR \
131 \
132 __end_rodata = .; \
133 . = ALIGN(4096); 132 . = ALIGN(4096);
134 133
135#define SECURITY_INIT \ 134#define SECURITY_INIT \
@@ -162,15 +161,23 @@
162 VMLINUX_SYMBOL(__kprobes_text_end) = .; 161 VMLINUX_SYMBOL(__kprobes_text_end) = .;
163 162
164#ifdef CONFIG_STACK_UNWIND 163#ifdef CONFIG_STACK_UNWIND
165 /* Unwind data binary search table */ 164#define EH_FRAME \
166#define EH_FRAME_HDR \ 165 /* Unwind data binary search table */ \
166 . = ALIGN(8); \
167 .eh_frame_hdr : AT(ADDR(.eh_frame_hdr) - LOAD_OFFSET) { \ 167 .eh_frame_hdr : AT(ADDR(.eh_frame_hdr) - LOAD_OFFSET) { \
168 VMLINUX_SYMBOL(__start_unwind_hdr) = .; \ 168 VMLINUX_SYMBOL(__start_unwind_hdr) = .; \
169 *(.eh_frame_hdr) \ 169 *(.eh_frame_hdr) \
170 VMLINUX_SYMBOL(__end_unwind_hdr) = .; \ 170 VMLINUX_SYMBOL(__end_unwind_hdr) = .; \
171 } \
172 /* Unwind data */ \
173 . = ALIGN(8); \
174 .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) { \
175 VMLINUX_SYMBOL(__start_unwind) = .; \
176 *(.eh_frame) \
177 VMLINUX_SYMBOL(__end_unwind) = .; \
171 } 178 }
172#else 179#else
173#define EH_FRAME_HDR 180#define EH_FRAME
174#endif 181#endif
175 182
176 /* DWARF debug sections. 183 /* DWARF debug sections.
diff --git a/include/asm-h8300/delay.h b/include/asm-h8300/delay.h
index cbccbbdd640f..743beba70f82 100644
--- a/include/asm-h8300/delay.h
+++ b/include/asm-h8300/delay.h
@@ -9,7 +9,7 @@
9 * Delay routines, using a pre-computed "loops_per_second" value. 9 * Delay routines, using a pre-computed "loops_per_second" value.
10 */ 10 */
11 11
12extern __inline__ void __delay(unsigned long loops) 12static inline void __delay(unsigned long loops)
13{ 13{
14 __asm__ __volatile__ ("1:\n\t" 14 __asm__ __volatile__ ("1:\n\t"
15 "dec.l #1,%0\n\t" 15 "dec.l #1,%0\n\t"
@@ -27,7 +27,7 @@ extern __inline__ void __delay(unsigned long loops)
27 27
28extern unsigned long loops_per_jiffy; 28extern unsigned long loops_per_jiffy;
29 29
30extern __inline__ void udelay(unsigned long usecs) 30static inline void udelay(unsigned long usecs)
31{ 31{
32 usecs *= 4295; /* 2**32 / 1000000 */ 32 usecs *= 4295; /* 2**32 / 1000000 */
33 usecs /= (loops_per_jiffy*HZ); 33 usecs /= (loops_per_jiffy*HZ);
diff --git a/include/asm-h8300/mmu_context.h b/include/asm-h8300/mmu_context.h
index 855721a5dcc9..5c165f7bee0e 100644
--- a/include/asm-h8300/mmu_context.h
+++ b/include/asm-h8300/mmu_context.h
@@ -9,7 +9,7 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
9{ 9{
10} 10}
11 11
12extern inline int 12static inline int
13init_new_context(struct task_struct *tsk, struct mm_struct *mm) 13init_new_context(struct task_struct *tsk, struct mm_struct *mm)
14{ 14{
15 // mm->context = virt_to_phys(mm->pgd); 15 // mm->context = virt_to_phys(mm->pgd);
@@ -23,7 +23,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, str
23{ 23{
24} 24}
25 25
26extern inline void activate_mm(struct mm_struct *prev_mm, 26static inline void activate_mm(struct mm_struct *prev_mm,
27 struct mm_struct *next_mm) 27 struct mm_struct *next_mm)
28{ 28{
29} 29}
diff --git a/include/asm-h8300/pci.h b/include/asm-h8300/pci.h
index 5edad5b70fd5..0c771b05fdd5 100644
--- a/include/asm-h8300/pci.h
+++ b/include/asm-h8300/pci.h
@@ -10,12 +10,12 @@
10#define pcibios_assign_all_busses() 0 10#define pcibios_assign_all_busses() 0
11#define pcibios_scan_all_fns(a, b) 0 11#define pcibios_scan_all_fns(a, b) 0
12 12
13extern inline void pcibios_set_master(struct pci_dev *dev) 13static inline void pcibios_set_master(struct pci_dev *dev)
14{ 14{
15 /* No special bus mastering setup handling */ 15 /* No special bus mastering setup handling */
16} 16}
17 17
18extern inline void pcibios_penalize_isa_irq(int irq, int active) 18static inline void pcibios_penalize_isa_irq(int irq, int active)
19{ 19{
20 /* We don't do dynamic PCI IRQ allocation */ 20 /* We don't do dynamic PCI IRQ allocation */
21} 21}
diff --git a/include/asm-h8300/tlbflush.h b/include/asm-h8300/tlbflush.h
index bbdffbeeedef..9a2c5c9fd700 100644
--- a/include/asm-h8300/tlbflush.h
+++ b/include/asm-h8300/tlbflush.h
@@ -47,12 +47,12 @@ static inline void flush_tlb_range(struct mm_struct *mm,
47 BUG(); 47 BUG();
48} 48}
49 49
50extern inline void flush_tlb_kernel_page(unsigned long addr) 50static inline void flush_tlb_kernel_page(unsigned long addr)
51{ 51{
52 BUG(); 52 BUG();
53} 53}
54 54
55extern inline void flush_tlb_pgtables(struct mm_struct *mm, 55static inline void flush_tlb_pgtables(struct mm_struct *mm,
56 unsigned long start, unsigned long end) 56 unsigned long start, unsigned long end)
57{ 57{
58 BUG(); 58 BUG();
diff --git a/include/asm-h8300/unistd.h b/include/asm-h8300/unistd.h
index 747788d629ae..7ddd414f8d16 100644
--- a/include/asm-h8300/unistd.h
+++ b/include/asm-h8300/unistd.h
@@ -295,172 +295,6 @@
295#ifdef __KERNEL__ 295#ifdef __KERNEL__
296 296
297#define NR_syscalls 289 297#define NR_syscalls 289
298#include <linux/err.h>
299
300/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
301 <asm-m68k/errno.h> */
302
303#define __syscall_return(type, res) \
304do { \
305 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
306 /* avoid using res which is declared to be in register d0; \
307 errno might expand to a function call and clobber it. */ \
308 int __err = -(res); \
309 errno = __err; \
310 res = -1; \
311 } \
312 return (type) (res); \
313} while (0)
314
315#define _syscall0(type, name) \
316type name(void) \
317{ \
318 register long __res __asm__("er0"); \
319 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
320 "trapa #0\n\t" \
321 : "=r" (__res) \
322 : "g" (__NR_##name) \
323 : "cc", "memory"); \
324 __syscall_return(type, __res); \
325}
326
327#define _syscall1(type, name, atype, a) \
328type name(atype a) \
329{ \
330 register long __res __asm__("er0"); \
331 register long _a __asm__("er1"); \
332 _a = (long)a; \
333 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
334 "trapa #0\n\t" \
335 : "=r" (__res) \
336 : "g" (__NR_##name), \
337 "g" (_a) \
338 : "cc", "memory"); \
339 __syscall_return(type, __res); \
340}
341
342#define _syscall2(type, name, atype, a, btype, b) \
343type name(atype a, btype b) \
344{ \
345 register long __res __asm__("er0"); \
346 register long _a __asm__("er1"); \
347 register long _b __asm__("er2"); \
348 _a = (long)a; \
349 _b = (long)b; \
350 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
351 "trapa #0\n\t" \
352 : "=r" (__res) \
353 : "g" (__NR_##name), \
354 "g" (_a), \
355 "g" (_b) \
356 : "cc", "memory"); \
357 __syscall_return(type, __res); \
358}
359
360#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
361type name(atype a, btype b, ctype c) \
362{ \
363 register long __res __asm__("er0"); \
364 register long _a __asm__("er1"); \
365 register long _b __asm__("er2"); \
366 register long _c __asm__("er3"); \
367 _a = (long)a; \
368 _b = (long)b; \
369 _c = (long)c; \
370 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
371 "trapa #0\n\t" \
372 : "=r" (__res) \
373 : "g" (__NR_##name), \
374 "g" (_a), \
375 "g" (_b), \
376 "g" (_c) \
377 : "cc", "memory"); \
378 __syscall_return(type, __res); \
379}
380
381#define _syscall4(type, name, atype, a, btype, b, \
382 ctype, c, dtype, d) \
383type name(atype a, btype b, ctype c, dtype d) \
384{ \
385 register long __res __asm__("er0"); \
386 register long _a __asm__("er1"); \
387 register long _b __asm__("er2"); \
388 register long _c __asm__("er3"); \
389 register long _d __asm__("er4"); \
390 _a = (long)a; \
391 _b = (long)b; \
392 _c = (long)c; \
393 _d = (long)d; \
394 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
395 "trapa #0\n\t" \
396 : "=r" (__res) \
397 : "g" (__NR_##name), \
398 "g" (_a), \
399 "g" (_b), \
400 "g" (_c), \
401 "g" (_d) \
402 : "cc", "memory"); \
403 __syscall_return(type, __res); \
404}
405
406#define _syscall5(type, name, atype, a, btype, b, \
407 ctype, c, dtype, d, etype, e) \
408type name(atype a, btype b, ctype c, dtype d, etype e) \
409{ \
410 register long __res __asm__("er0"); \
411 register long _a __asm__("er1"); \
412 register long _b __asm__("er2"); \
413 register long _c __asm__("er3"); \
414 register long _d __asm__("er4"); \
415 register long _e __asm__("er5"); \
416 _a = (long)a; \
417 _b = (long)b; \
418 _c = (long)c; \
419 _d = (long)d; \
420 _e = (long)e; \
421 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
422 "trapa #0\n\t" \
423 : "=r" (__res) \
424 : "g" (__NR_##name), \
425 "g" (_a), \
426 "g" (_b), \
427 "g" (_c), \
428 "g" (_d), \
429 "g" (_e) \
430 : "cc", "memory"); \
431 __syscall_return(type, __res); \
432}
433
434#define _syscall6(type, name, atype, a, btype, b, \
435 ctype, c, dtype, d, etype, e, ftype, f) \
436type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \
437{ \
438 register long __res __asm__("er0"); \
439 register long _a __asm__("er1"); \
440 register long _b __asm__("er2"); \
441 register long _c __asm__("er3"); \
442 register long _d __asm__("er4"); \
443 register long _e __asm__("er5"); \
444 register long _f __asm__("er6"); \
445 _a = (long)a; \
446 _b = (long)b; \
447 _c = (long)c; \
448 _d = (long)d; \
449 _e = (long)e; \
450 _f = (long)f; \
451 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
452 "trapa #0\n\t" \
453 : "=r" (__res) \
454 : "g" (__NR_##name), \
455 "g" (_a), \
456 "g" (_b), \
457 "g" (_c), \
458 "g" (_d), \
459 "g" (_e) \
460 "g" (_f) \
461 : "cc", "memory"); \
462 __syscall_return(type, __res); \
463}
464 298
465#define __ARCH_WANT_IPC_PARSE_VERSION 299#define __ARCH_WANT_IPC_PARSE_VERSION
466#define __ARCH_WANT_OLD_READDIR 300#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-i386/Kbuild b/include/asm-i386/Kbuild
index 147e4ac1ebf0..5ae93afc67e1 100644
--- a/include/asm-i386/Kbuild
+++ b/include/asm-i386/Kbuild
@@ -7,5 +7,4 @@ header-y += ptrace-abi.h
7header-y += ucontext.h 7header-y += ucontext.h
8 8
9unifdef-y += mtrr.h 9unifdef-y += mtrr.h
10unifdef-y += setup.h
11unifdef-y += vm86.h 10unifdef-y += vm86.h
diff --git a/include/asm-i386/alternative.h b/include/asm-i386/alternative.h
index b01a7ec409ce..b8fa9557c532 100644
--- a/include/asm-i386/alternative.h
+++ b/include/asm-i386/alternative.h
@@ -4,7 +4,7 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <asm/types.h> 6#include <asm/types.h>
7 7#include <linux/stddef.h>
8#include <linux/types.h> 8#include <linux/types.h>
9 9
10struct alt_instr { 10struct alt_instr {
@@ -118,4 +118,15 @@ static inline void alternatives_smp_switch(int smp) {}
118#define LOCK_PREFIX "" 118#define LOCK_PREFIX ""
119#endif 119#endif
120 120
121struct paravirt_patch;
122#ifdef CONFIG_PARAVIRT
123void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end);
124#else
125static inline void
126apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
127{}
128#define __start_parainstructions NULL
129#define __stop_parainstructions NULL
130#endif
131
121#endif /* _I386_ALTERNATIVE_H */ 132#endif /* _I386_ALTERNATIVE_H */
diff --git a/include/asm-i386/apic.h b/include/asm-i386/apic.h
index b9529578fc37..41a44319905f 100644
--- a/include/asm-i386/apic.h
+++ b/include/asm-i386/apic.h
@@ -37,18 +37,27 @@ extern void generic_apic_probe(void);
37/* 37/*
38 * Basic functions accessing APICs. 38 * Basic functions accessing APICs.
39 */ 39 */
40#ifdef CONFIG_PARAVIRT
41#include <asm/paravirt.h>
42#else
43#define apic_write native_apic_write
44#define apic_write_atomic native_apic_write_atomic
45#define apic_read native_apic_read
46#endif
40 47
41static __inline void apic_write(unsigned long reg, unsigned long v) 48static __inline fastcall void native_apic_write(unsigned long reg,
49 unsigned long v)
42{ 50{
43 *((volatile unsigned long *)(APIC_BASE+reg)) = v; 51 *((volatile unsigned long *)(APIC_BASE+reg)) = v;
44} 52}
45 53
46static __inline void apic_write_atomic(unsigned long reg, unsigned long v) 54static __inline fastcall void native_apic_write_atomic(unsigned long reg,
55 unsigned long v)
47{ 56{
48 xchg((volatile unsigned long *)(APIC_BASE+reg), v); 57 xchg((volatile unsigned long *)(APIC_BASE+reg), v);
49} 58}
50 59
51static __inline unsigned long apic_read(unsigned long reg) 60static __inline fastcall unsigned long native_apic_read(unsigned long reg)
52{ 61{
53 return *((volatile unsigned long *)(APIC_BASE+reg)); 62 return *((volatile unsigned long *)(APIC_BASE+reg));
54} 63}
diff --git a/include/asm-i386/atomic.h b/include/asm-i386/atomic.h
index a6c024e2506f..c57441bb2905 100644
--- a/include/asm-i386/atomic.h
+++ b/include/asm-i386/atomic.h
@@ -187,9 +187,9 @@ static __inline__ int atomic_add_return(int i, atomic_t *v)
187 /* Modern 486+ processor */ 187 /* Modern 486+ processor */
188 __i = i; 188 __i = i;
189 __asm__ __volatile__( 189 __asm__ __volatile__(
190 LOCK_PREFIX "xaddl %0, %1;" 190 LOCK_PREFIX "xaddl %0, %1"
191 :"=r"(i) 191 :"+r" (i), "+m" (v->counter)
192 :"m"(v->counter), "0"(i)); 192 : : "memory");
193 return i + __i; 193 return i + __i;
194 194
195#ifdef CONFIG_M386 195#ifdef CONFIG_M386
diff --git a/include/asm-i386/boot.h b/include/asm-i386/boot.h
index 96b228e6e79c..8ce79a6fa891 100644
--- a/include/asm-i386/boot.h
+++ b/include/asm-i386/boot.h
@@ -12,4 +12,8 @@
12#define EXTENDED_VGA 0xfffe /* 80x50 mode */ 12#define EXTENDED_VGA 0xfffe /* 80x50 mode */
13#define ASK_VGA 0xfffd /* ask for it at bootup */ 13#define ASK_VGA 0xfffd /* ask for it at bootup */
14 14
15#endif 15/* Physical address where kenrel should be loaded. */
16#define LOAD_PHYSICAL_ADDR ((0x100000 + CONFIG_PHYSICAL_ALIGN - 1) \
17 & ~(CONFIG_PHYSICAL_ALIGN - 1))
18
19#endif /* _LINUX_BOOT_H */
diff --git a/include/asm-i386/bugs.h b/include/asm-i386/bugs.h
index 592ffeeda45e..38f1aebbbdb5 100644
--- a/include/asm-i386/bugs.h
+++ b/include/asm-i386/bugs.h
@@ -21,6 +21,7 @@
21#include <asm/processor.h> 21#include <asm/processor.h>
22#include <asm/i387.h> 22#include <asm/i387.h>
23#include <asm/msr.h> 23#include <asm/msr.h>
24#include <asm/paravirt.h>
24 25
25static int __init no_halt(char *s) 26static int __init no_halt(char *s)
26{ 27{
@@ -91,6 +92,9 @@ static void __init check_fpu(void)
91 92
92static void __init check_hlt(void) 93static void __init check_hlt(void)
93{ 94{
95 if (paravirt_enabled())
96 return;
97
94 printk(KERN_INFO "Checking 'hlt' instruction... "); 98 printk(KERN_INFO "Checking 'hlt' instruction... ");
95 if (!boot_cpu_data.hlt_works_ok) { 99 if (!boot_cpu_data.hlt_works_ok) {
96 printk("disabled\n"); 100 printk("disabled\n");
diff --git a/include/asm-i386/cpu.h b/include/asm-i386/cpu.h
index b1bc7b1b64b0..9d914e1e4aad 100644
--- a/include/asm-i386/cpu.h
+++ b/include/asm-i386/cpu.h
@@ -13,6 +13,9 @@ struct i386_cpu {
13extern int arch_register_cpu(int num); 13extern int arch_register_cpu(int num);
14#ifdef CONFIG_HOTPLUG_CPU 14#ifdef CONFIG_HOTPLUG_CPU
15extern void arch_unregister_cpu(int); 15extern void arch_unregister_cpu(int);
16extern int enable_cpu_hotplug;
17#else
18#define enable_cpu_hotplug 0
16#endif 19#endif
17 20
18DECLARE_PER_CPU(int, cpu_state); 21DECLARE_PER_CPU(int, cpu_state);
diff --git a/include/asm-i386/cpufeature.h b/include/asm-i386/cpufeature.h
index d314ebb3d59e..3f92b94e0d75 100644
--- a/include/asm-i386/cpufeature.h
+++ b/include/asm-i386/cpufeature.h
@@ -31,7 +31,7 @@
31#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */ 31#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */
32#define X86_FEATURE_PN (0*32+18) /* Processor serial number */ 32#define X86_FEATURE_PN (0*32+18) /* Processor serial number */
33#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */ 33#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */
34#define X86_FEATURE_DTES (0*32+21) /* Debug Trace Store */ 34#define X86_FEATURE_DS (0*32+21) /* Debug Store */
35#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */ 35#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */
36#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */ 36#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
37#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */ 37#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
@@ -73,6 +73,8 @@
73#define X86_FEATURE_UP (3*32+ 9) /* smp kernel running on up */ 73#define X86_FEATURE_UP (3*32+ 9) /* smp kernel running on up */
74#define X86_FEATURE_FXSAVE_LEAK (3*32+10) /* FXSAVE leaks FOP/FIP/FOP */ 74#define X86_FEATURE_FXSAVE_LEAK (3*32+10) /* FXSAVE leaks FOP/FIP/FOP */
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 */
77#define X86_FEATURE_BTS (3*32+13) /* Branch Trace Store */
76 78
77/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ 79/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
78#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */ 80#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
@@ -134,6 +136,10 @@
134#define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN) 136#define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN)
135#define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM) 137#define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM)
136#define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN) 138#define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN)
139#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
140#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
141#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
142#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
137 143
138#endif /* __ASM_I386_CPUFEATURE_H */ 144#endif /* __ASM_I386_CPUFEATURE_H */
139 145
diff --git a/include/asm-i386/current.h b/include/asm-i386/current.h
index 3cbbecd79016..5252ee0f6d7a 100644
--- a/include/asm-i386/current.h
+++ b/include/asm-i386/current.h
@@ -1,13 +1,14 @@
1#ifndef _I386_CURRENT_H 1#ifndef _I386_CURRENT_H
2#define _I386_CURRENT_H 2#define _I386_CURRENT_H
3 3
4#include <linux/thread_info.h> 4#include <asm/pda.h>
5#include <linux/compiler.h>
5 6
6struct task_struct; 7struct task_struct;
7 8
8static __always_inline struct task_struct * get_current(void) 9static __always_inline struct task_struct *get_current(void)
9{ 10{
10 return current_thread_info()->task; 11 return read_pda(pcurrent);
11} 12}
12 13
13#define current get_current() 14#define current get_current()
diff --git a/include/asm-i386/delay.h b/include/asm-i386/delay.h
index b1c7650dc7b9..32d6678d0bbf 100644
--- a/include/asm-i386/delay.h
+++ b/include/asm-i386/delay.h
@@ -7,6 +7,7 @@
7 * Delay routines calling functions in arch/i386/lib/delay.c 7 * Delay routines calling functions in arch/i386/lib/delay.c
8 */ 8 */
9 9
10/* Undefined functions to get compile-time errors */
10extern void __bad_udelay(void); 11extern void __bad_udelay(void);
11extern void __bad_ndelay(void); 12extern void __bad_ndelay(void);
12 13
@@ -15,13 +16,23 @@ extern void __ndelay(unsigned long nsecs);
15extern void __const_udelay(unsigned long usecs); 16extern void __const_udelay(unsigned long usecs);
16extern void __delay(unsigned long loops); 17extern void __delay(unsigned long loops);
17 18
19#if defined(CONFIG_PARAVIRT) && !defined(USE_REAL_TIME_DELAY)
20#define udelay(n) paravirt_ops.const_udelay((n) * 0x10c7ul)
21
22#define ndelay(n) paravirt_ops.const_udelay((n) * 5ul)
23
24#else /* !PARAVIRT || USE_REAL_TIME_DELAY */
25
26/* 0x10c7 is 2**32 / 1000000 (rounded up) */
18#define udelay(n) (__builtin_constant_p(n) ? \ 27#define udelay(n) (__builtin_constant_p(n) ? \
19 ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \ 28 ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
20 __udelay(n)) 29 __udelay(n))
21 30
31/* 0x5 is 2**32 / 1000000000 (rounded up) */
22#define ndelay(n) (__builtin_constant_p(n) ? \ 32#define ndelay(n) (__builtin_constant_p(n) ? \
23 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ 33 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
24 __ndelay(n)) 34 __ndelay(n))
35#endif
25 36
26void use_tsc_delay(void); 37void use_tsc_delay(void);
27 38
diff --git a/include/asm-i386/desc.h b/include/asm-i386/desc.h
index 5874ef119ffd..f398cc456448 100644
--- a/include/asm-i386/desc.h
+++ b/include/asm-i386/desc.h
@@ -4,8 +4,6 @@
4#include <asm/ldt.h> 4#include <asm/ldt.h>
5#include <asm/segment.h> 5#include <asm/segment.h>
6 6
7#define CPU_16BIT_STACK_SIZE 1024
8
9#ifndef __ASSEMBLY__ 7#ifndef __ASSEMBLY__
10 8
11#include <linux/preempt.h> 9#include <linux/preempt.h>
@@ -16,8 +14,6 @@
16 14
17extern struct desc_struct cpu_gdt_table[GDT_ENTRIES]; 15extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
18 16
19DECLARE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]);
20
21struct Xgt_desc_struct { 17struct Xgt_desc_struct {
22 unsigned short size; 18 unsigned short size;
23 unsigned long address __attribute__((packed)); 19 unsigned long address __attribute__((packed));
@@ -33,11 +29,6 @@ static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
33 return (struct desc_struct *)per_cpu(cpu_gdt_descr, cpu).address; 29 return (struct desc_struct *)per_cpu(cpu_gdt_descr, cpu).address;
34} 30}
35 31
36/*
37 * This is the ldt that every process will get unless we need
38 * something other than this.
39 */
40extern struct desc_struct default_ldt[];
41extern struct desc_struct idt_table[]; 32extern struct desc_struct idt_table[];
42extern void set_intr_gate(unsigned int irq, void * addr); 33extern void set_intr_gate(unsigned int irq, void * addr);
43 34
@@ -64,8 +55,10 @@ static inline void pack_gate(__u32 *a, __u32 *b,
64#define DESCTYPE_DPL3 0x60 /* DPL-3 */ 55#define DESCTYPE_DPL3 0x60 /* DPL-3 */
65#define DESCTYPE_S 0x10 /* !system */ 56#define DESCTYPE_S 0x10 /* !system */
66 57
58#ifdef CONFIG_PARAVIRT
59#include <asm/paravirt.h>
60#else
67#define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8)) 61#define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8))
68#define load_LDT_desc() __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8))
69 62
70#define load_gdt(dtr) __asm__ __volatile("lgdt %0"::"m" (*dtr)) 63#define load_gdt(dtr) __asm__ __volatile("lgdt %0"::"m" (*dtr))
71#define load_idt(dtr) __asm__ __volatile("lidt %0"::"m" (*dtr)) 64#define load_idt(dtr) __asm__ __volatile("lidt %0"::"m" (*dtr))
@@ -88,6 +81,10 @@ static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
88#undef C 81#undef C
89} 82}
90 83
84#define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
85#define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
86#define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
87
91static inline void write_dt_entry(void *dt, int entry, __u32 entry_a, __u32 entry_b) 88static inline void write_dt_entry(void *dt, int entry, __u32 entry_a, __u32 entry_b)
92{ 89{
93 __u32 *lp = (__u32 *)((char *)dt + entry*8); 90 __u32 *lp = (__u32 *)((char *)dt + entry*8);
@@ -95,9 +92,25 @@ static inline void write_dt_entry(void *dt, int entry, __u32 entry_a, __u32 entr
95 *(lp+1) = entry_b; 92 *(lp+1) = entry_b;
96} 93}
97 94
98#define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b) 95#define set_ldt native_set_ldt
99#define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b) 96#endif /* CONFIG_PARAVIRT */
100#define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b) 97
98static inline fastcall void native_set_ldt(const void *addr,
99 unsigned int entries)
100{
101 if (likely(entries == 0))
102 __asm__ __volatile__("lldt %w0"::"q" (0));
103 else {
104 unsigned cpu = smp_processor_id();
105 __u32 a, b;
106
107 pack_descriptor(&a, &b, (unsigned long)addr,
108 entries * sizeof(struct desc_struct) - 1,
109 DESCTYPE_LDT, 0);
110 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
111 __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
112 }
113}
101 114
102static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg) 115static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
103{ 116{
@@ -115,14 +128,6 @@ static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const vo
115 write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b); 128 write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b);
116} 129}
117 130
118static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int entries)
119{
120 __u32 a, b;
121 pack_descriptor(&a, &b, (unsigned long)addr,
122 entries * sizeof(struct desc_struct) - 1,
123 DESCTYPE_LDT, 0);
124 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
125}
126 131
127#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr) 132#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
128 133
@@ -153,35 +158,22 @@ static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int entri
153 158
154static inline void clear_LDT(void) 159static inline void clear_LDT(void)
155{ 160{
156 int cpu = get_cpu(); 161 set_ldt(NULL, 0);
157
158 set_ldt_desc(cpu, &default_ldt[0], 5);
159 load_LDT_desc();
160 put_cpu();
161} 162}
162 163
163/* 164/*
164 * load one particular LDT into the current CPU 165 * load one particular LDT into the current CPU
165 */ 166 */
166static inline void load_LDT_nolock(mm_context_t *pc, int cpu) 167static inline void load_LDT_nolock(mm_context_t *pc)
167{ 168{
168 void *segments = pc->ldt; 169 set_ldt(pc->ldt, pc->size);
169 int count = pc->size;
170
171 if (likely(!count)) {
172 segments = &default_ldt[0];
173 count = 5;
174 }
175
176 set_ldt_desc(cpu, segments, count);
177 load_LDT_desc();
178} 170}
179 171
180static inline void load_LDT(mm_context_t *pc) 172static inline void load_LDT(mm_context_t *pc)
181{ 173{
182 int cpu = get_cpu(); 174 preempt_disable();
183 load_LDT_nolock(pc, cpu); 175 load_LDT_nolock(pc);
184 put_cpu(); 176 preempt_enable();
185} 177}
186 178
187static inline unsigned long get_desc_base(unsigned long *desc) 179static inline unsigned long get_desc_base(unsigned long *desc)
@@ -193,6 +185,29 @@ static inline unsigned long get_desc_base(unsigned long *desc)
193 return base; 185 return base;
194} 186}
195 187
188#else /* __ASSEMBLY__ */
189
190/*
191 * GET_DESC_BASE reads the descriptor base of the specified segment.
192 *
193 * Args:
194 * idx - descriptor index
195 * gdt - GDT pointer
196 * base - 32bit register to which the base will be written
197 * lo_w - lo word of the "base" register
198 * lo_b - lo byte of the "base" register
199 * hi_b - hi byte of the low word of the "base" register
200 *
201 * Example:
202 * GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
203 * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
204 */
205#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \
206 movb idx*8+4(gdt), lo_b; \
207 movb idx*8+7(gdt), hi_b; \
208 shll $16, base; \
209 movw idx*8+2(gdt), lo_w;
210
196#endif /* !__ASSEMBLY__ */ 211#endif /* !__ASSEMBLY__ */
197 212
198#endif 213#endif
diff --git a/include/asm-i386/dma-mapping.h b/include/asm-i386/dma-mapping.h
index 81999a3ebe7c..183eebeebbdc 100644
--- a/include/asm-i386/dma-mapping.h
+++ b/include/asm-i386/dma-mapping.h
@@ -156,10 +156,10 @@ dma_get_cache_alignment(void)
156 return (1 << INTERNODE_CACHE_SHIFT); 156 return (1 << INTERNODE_CACHE_SHIFT);
157} 157}
158 158
159#define dma_is_consistent(d) (1) 159#define dma_is_consistent(d, h) (1)
160 160
161static inline void 161static inline void
162dma_cache_sync(void *vaddr, size_t size, 162dma_cache_sync(struct device *dev, void *vaddr, size_t size,
163 enum dma_data_direction direction) 163 enum dma_data_direction direction)
164{ 164{
165 flush_write_buffers(); 165 flush_write_buffers();
diff --git a/include/asm-i386/e820.h b/include/asm-i386/e820.h
index f7514fb6e8e4..395077aba583 100644
--- a/include/asm-i386/e820.h
+++ b/include/asm-i386/e820.h
@@ -38,6 +38,11 @@ extern struct e820map e820;
38 38
39extern int e820_all_mapped(unsigned long start, unsigned long end, 39extern int e820_all_mapped(unsigned long start, unsigned long end,
40 unsigned type); 40 unsigned type);
41extern void find_max_pfn(void);
42extern void register_bootmem_low_pages(unsigned long max_low_pfn);
43extern void register_memory(void);
44extern void limit_regions(unsigned long long size);
45extern void print_memory_map(char *who);
41 46
42#endif/*!__ASSEMBLY__*/ 47#endif/*!__ASSEMBLY__*/
43 48
diff --git a/include/asm-i386/elf.h b/include/asm-i386/elf.h
index 3a05436f31c0..45d21a0c95bf 100644
--- a/include/asm-i386/elf.h
+++ b/include/asm-i386/elf.h
@@ -91,7 +91,7 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
91 pr_reg[7] = regs->xds; \ 91 pr_reg[7] = regs->xds; \
92 pr_reg[8] = regs->xes; \ 92 pr_reg[8] = regs->xes; \
93 savesegment(fs,pr_reg[9]); \ 93 savesegment(fs,pr_reg[9]); \
94 savesegment(gs,pr_reg[10]); \ 94 pr_reg[10] = regs->xgs; \
95 pr_reg[11] = regs->orig_eax; \ 95 pr_reg[11] = regs->orig_eax; \
96 pr_reg[12] = regs->eip; \ 96 pr_reg[12] = regs->eip; \
97 pr_reg[13] = regs->xcs; \ 97 pr_reg[13] = regs->xcs; \
diff --git a/include/asm-i386/futex.h b/include/asm-i386/futex.h
index 946d97cfea23..438ef0ec7101 100644
--- a/include/asm-i386/futex.h
+++ b/include/asm-i386/futex.h
@@ -56,7 +56,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
56 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 56 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
57 return -EFAULT; 57 return -EFAULT;
58 58
59 inc_preempt_count(); 59 pagefault_disable();
60 60
61 if (op == FUTEX_OP_SET) 61 if (op == FUTEX_OP_SET)
62 __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg); 62 __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
@@ -88,7 +88,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
88 } 88 }
89 } 89 }
90 90
91 dec_preempt_count(); 91 pagefault_enable();
92 92
93 if (!ret) { 93 if (!ret) {
94 switch (cmp) { 94 switch (cmp) {
diff --git a/include/asm-i386/genapic.h b/include/asm-i386/genapic.h
index 8ffbb0f07457..fd2be593b06e 100644
--- a/include/asm-i386/genapic.h
+++ b/include/asm-i386/genapic.h
@@ -122,6 +122,6 @@ struct genapic {
122 APICFUNC(phys_pkg_id) \ 122 APICFUNC(phys_pkg_id) \
123 } 123 }
124 124
125extern struct genapic *genapic; 125extern struct genapic *genapic, apic_default;
126 126
127#endif 127#endif
diff --git a/include/asm-i386/i387.h b/include/asm-i386/i387.h
index bc1d6edae1ed..434936c732d6 100644
--- a/include/asm-i386/i387.h
+++ b/include/asm-i386/i387.h
@@ -76,7 +76,9 @@ static inline void __save_init_fpu( struct task_struct *tsk )
76 76
77#define __unlazy_fpu( tsk ) do { \ 77#define __unlazy_fpu( tsk ) do { \
78 if (task_thread_info(tsk)->status & TS_USEDFPU) \ 78 if (task_thread_info(tsk)->status & TS_USEDFPU) \
79 save_init_fpu( tsk ); \ 79 save_init_fpu( tsk ); \
80 else \
81 tsk->fpu_counter = 0; \
80} while (0) 82} while (0)
81 83
82#define __clear_fpu( tsk ) \ 84#define __clear_fpu( tsk ) \
@@ -118,6 +120,7 @@ static inline void save_init_fpu( struct task_struct *tsk )
118extern unsigned short get_fpu_cwd( struct task_struct *tsk ); 120extern unsigned short get_fpu_cwd( struct task_struct *tsk );
119extern unsigned short get_fpu_swd( struct task_struct *tsk ); 121extern unsigned short get_fpu_swd( struct task_struct *tsk );
120extern unsigned short get_fpu_mxcsr( struct task_struct *tsk ); 122extern unsigned short get_fpu_mxcsr( struct task_struct *tsk );
123extern asmlinkage void math_state_restore(void);
121 124
122/* 125/*
123 * Signal frame handlers... 126 * Signal frame handlers...
diff --git a/include/asm-i386/io.h b/include/asm-i386/io.h
index 68df0dc3ab8f..86ff5e83be2f 100644
--- a/include/asm-i386/io.h
+++ b/include/asm-i386/io.h
@@ -256,11 +256,11 @@ static inline void flush_write_buffers(void)
256 256
257#endif /* __KERNEL__ */ 257#endif /* __KERNEL__ */
258 258
259#ifdef SLOW_IO_BY_JUMPING 259#if defined(CONFIG_PARAVIRT)
260#define __SLOW_DOWN_IO "jmp 1f; 1: jmp 1f; 1:" 260#include <asm/paravirt.h>
261#else 261#else
262
262#define __SLOW_DOWN_IO "outb %%al,$0x80;" 263#define __SLOW_DOWN_IO "outb %%al,$0x80;"
263#endif
264 264
265static inline void slow_down_io(void) { 265static inline void slow_down_io(void) {
266 __asm__ __volatile__( 266 __asm__ __volatile__(
@@ -271,6 +271,8 @@ static inline void slow_down_io(void) {
271 : : ); 271 : : );
272} 272}
273 273
274#endif
275
274#ifdef CONFIG_X86_NUMAQ 276#ifdef CONFIG_X86_NUMAQ
275extern void *xquad_portio; /* Where the IO area was mapped */ 277extern void *xquad_portio; /* Where the IO area was mapped */
276#define XQUAD_PORT_ADDR(port, quad) (xquad_portio + (XQUAD_PORTIO_QUAD*quad) + port) 278#define XQUAD_PORT_ADDR(port, quad) (xquad_portio + (XQUAD_PORTIO_QUAD*quad) + port)
diff --git a/include/asm-i386/irq.h b/include/asm-i386/irq.h
index 331726b41128..11761cdaae19 100644
--- a/include/asm-i386/irq.h
+++ b/include/asm-i386/irq.h
@@ -37,8 +37,13 @@ static __inline__ int irq_canonicalize(int irq)
37extern int irqbalance_disable(char *str); 37extern int irqbalance_disable(char *str);
38#endif 38#endif
39 39
40extern void quirk_intel_irqbalance(void);
41
40#ifdef CONFIG_HOTPLUG_CPU 42#ifdef CONFIG_HOTPLUG_CPU
41extern void fixup_irqs(cpumask_t map); 43extern void fixup_irqs(cpumask_t map);
42#endif 44#endif
43 45
46void init_IRQ(void);
47void __init native_init_IRQ(void);
48
44#endif /* _ASM_IRQ_H */ 49#endif /* _ASM_IRQ_H */
diff --git a/include/asm-i386/irq_regs.h b/include/asm-i386/irq_regs.h
index 3dd9c0b70270..a1b3f7f594a2 100644
--- a/include/asm-i386/irq_regs.h
+++ b/include/asm-i386/irq_regs.h
@@ -1 +1,27 @@
1#include <asm-generic/irq_regs.h> 1/*
2 * Per-cpu current frame pointer - the location of the last exception frame on
3 * the stack, stored in the PDA.
4 *
5 * Jeremy Fitzhardinge <jeremy@goop.org>
6 */
7#ifndef _ASM_I386_IRQ_REGS_H
8#define _ASM_I386_IRQ_REGS_H
9
10#include <asm/pda.h>
11
12static inline struct pt_regs *get_irq_regs(void)
13{
14 return read_pda(irq_regs);
15}
16
17static inline struct pt_regs *set_irq_regs(struct pt_regs *new_regs)
18{
19 struct pt_regs *old_regs;
20
21 old_regs = read_pda(irq_regs);
22 write_pda(irq_regs, new_regs);
23
24 return old_regs;
25}
26
27#endif /* _ASM_I386_IRQ_REGS_H */
diff --git a/include/asm-i386/irqflags.h b/include/asm-i386/irqflags.h
index e1bdb97c07fa..17b18cf4fe9d 100644
--- a/include/asm-i386/irqflags.h
+++ b/include/asm-i386/irqflags.h
@@ -10,6 +10,9 @@
10#ifndef _ASM_IRQFLAGS_H 10#ifndef _ASM_IRQFLAGS_H
11#define _ASM_IRQFLAGS_H 11#define _ASM_IRQFLAGS_H
12 12
13#ifdef CONFIG_PARAVIRT
14#include <asm/paravirt.h>
15#else
13#ifndef __ASSEMBLY__ 16#ifndef __ASSEMBLY__
14 17
15static inline unsigned long __raw_local_save_flags(void) 18static inline unsigned long __raw_local_save_flags(void)
@@ -25,9 +28,6 @@ static inline unsigned long __raw_local_save_flags(void)
25 return flags; 28 return flags;
26} 29}
27 30
28#define raw_local_save_flags(flags) \
29 do { (flags) = __raw_local_save_flags(); } while (0)
30
31static inline void raw_local_irq_restore(unsigned long flags) 31static inline void raw_local_irq_restore(unsigned long flags)
32{ 32{
33 __asm__ __volatile__( 33 __asm__ __volatile__(
@@ -66,18 +66,6 @@ static inline void halt(void)
66 __asm__ __volatile__("hlt": : :"memory"); 66 __asm__ __volatile__("hlt": : :"memory");
67} 67}
68 68
69static inline int raw_irqs_disabled_flags(unsigned long flags)
70{
71 return !(flags & (1 << 9));
72}
73
74static inline int raw_irqs_disabled(void)
75{
76 unsigned long flags = __raw_local_save_flags();
77
78 return raw_irqs_disabled_flags(flags);
79}
80
81/* 69/*
82 * For spinlocks, etc: 70 * For spinlocks, etc:
83 */ 71 */
@@ -90,9 +78,33 @@ static inline unsigned long __raw_local_irq_save(void)
90 return flags; 78 return flags;
91} 79}
92 80
81#else
82#define DISABLE_INTERRUPTS(clobbers) cli
83#define ENABLE_INTERRUPTS(clobbers) sti
84#define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
85#define INTERRUPT_RETURN iret
86#define GET_CR0_INTO_EAX movl %cr0, %eax
87#endif /* __ASSEMBLY__ */
88#endif /* CONFIG_PARAVIRT */
89
90#ifndef __ASSEMBLY__
91#define raw_local_save_flags(flags) \
92 do { (flags) = __raw_local_save_flags(); } while (0)
93
93#define raw_local_irq_save(flags) \ 94#define raw_local_irq_save(flags) \
94 do { (flags) = __raw_local_irq_save(); } while (0) 95 do { (flags) = __raw_local_irq_save(); } while (0)
95 96
97static inline int raw_irqs_disabled_flags(unsigned long flags)
98{
99 return !(flags & (1 << 9));
100}
101
102static inline int raw_irqs_disabled(void)
103{
104 unsigned long flags = __raw_local_save_flags();
105
106 return raw_irqs_disabled_flags(flags);
107}
96#endif /* __ASSEMBLY__ */ 108#endif /* __ASSEMBLY__ */
97 109
98/* 110/*
diff --git a/include/asm-i386/mach-default/setup_arch.h b/include/asm-i386/mach-default/setup_arch.h
index fb42099e7bd4..605e3ccb991b 100644
--- a/include/asm-i386/mach-default/setup_arch.h
+++ b/include/asm-i386/mach-default/setup_arch.h
@@ -2,4 +2,6 @@
2 2
3/* no action for generic */ 3/* no action for generic */
4 4
5#ifndef ARCH_SETUP
5#define ARCH_SETUP 6#define ARCH_SETUP
7#endif
diff --git a/include/asm-i386/math_emu.h b/include/asm-i386/math_emu.h
index 697673b555ce..a4b0aa3320e6 100644
--- a/include/asm-i386/math_emu.h
+++ b/include/asm-i386/math_emu.h
@@ -21,6 +21,7 @@ struct info {
21 long ___eax; 21 long ___eax;
22 long ___ds; 22 long ___ds;
23 long ___es; 23 long ___es;
24 long ___fs;
24 long ___orig_eax; 25 long ___orig_eax;
25 long ___eip; 26 long ___eip;
26 long ___cs; 27 long ___cs;
diff --git a/include/asm-i386/mmu_context.h b/include/asm-i386/mmu_context.h
index 62b7bf184094..68ff102d6f5e 100644
--- a/include/asm-i386/mmu_context.h
+++ b/include/asm-i386/mmu_context.h
@@ -44,7 +44,7 @@ static inline void switch_mm(struct mm_struct *prev,
44 * load the LDT, if the LDT is different: 44 * load the LDT, if the LDT is different:
45 */ 45 */
46 if (unlikely(prev->context.ldt != next->context.ldt)) 46 if (unlikely(prev->context.ldt != next->context.ldt))
47 load_LDT_nolock(&next->context, cpu); 47 load_LDT_nolock(&next->context);
48 } 48 }
49#ifdef CONFIG_SMP 49#ifdef CONFIG_SMP
50 else { 50 else {
@@ -56,14 +56,14 @@ static inline void switch_mm(struct mm_struct *prev,
56 * tlb flush IPI delivery. We must reload %cr3. 56 * tlb flush IPI delivery. We must reload %cr3.
57 */ 57 */
58 load_cr3(next->pgd); 58 load_cr3(next->pgd);
59 load_LDT_nolock(&next->context, cpu); 59 load_LDT_nolock(&next->context);
60 } 60 }
61 } 61 }
62#endif 62#endif
63} 63}
64 64
65#define deactivate_mm(tsk, mm) \ 65#define deactivate_mm(tsk, mm) \
66 asm("movl %0,%%fs ; movl %0,%%gs": :"r" (0)) 66 asm("movl %0,%%fs": :"r" (0));
67 67
68#define activate_mm(prev, next) \ 68#define activate_mm(prev, next) \
69 switch_mm((prev),(next),NULL) 69 switch_mm((prev),(next),NULL)
diff --git a/include/asm-i386/mmzone.h b/include/asm-i386/mmzone.h
index 61b073322006..3503ad66945e 100644
--- a/include/asm-i386/mmzone.h
+++ b/include/asm-i386/mmzone.h
@@ -120,13 +120,26 @@ static inline int pfn_valid(int pfn)
120 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 120 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
121#define alloc_bootmem_low_pages(x) \ 121#define alloc_bootmem_low_pages(x) \
122 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0) 122 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
123#define alloc_bootmem_node(ignore, x) \ 123#define alloc_bootmem_node(pgdat, x) \
124 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) 124({ \
125#define alloc_bootmem_pages_node(ignore, x) \ 125 struct pglist_data __attribute__ ((unused)) \
126 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) 126 *__alloc_bootmem_node__pgdat = (pgdat); \
127#define alloc_bootmem_low_pages_node(ignore, x) \ 127 __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, \
128 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0) 128 __pa(MAX_DMA_ADDRESS)); \
129 129})
130#define alloc_bootmem_pages_node(pgdat, x) \
131({ \
132 struct pglist_data __attribute__ ((unused)) \
133 *__alloc_bootmem_node__pgdat = (pgdat); \
134 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, \
135 __pa(MAX_DMA_ADDRESS)) \
136})
137#define alloc_bootmem_low_pages_node(pgdat, x) \
138({ \
139 struct pglist_data __attribute__ ((unused)) \
140 *__alloc_bootmem_node__pgdat = (pgdat); \
141 __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0); \
142})
130#endif /* CONFIG_NEED_MULTIPLE_NODES */ 143#endif /* CONFIG_NEED_MULTIPLE_NODES */
131 144
132#endif /* _ASM_MMZONE_H_ */ 145#endif /* _ASM_MMZONE_H_ */
diff --git a/include/asm-i386/module.h b/include/asm-i386/module.h
index 424661d25bd3..02f8f541cbe0 100644
--- a/include/asm-i386/module.h
+++ b/include/asm-i386/module.h
@@ -20,6 +20,8 @@ struct mod_arch_specific
20#define MODULE_PROC_FAMILY "586TSC " 20#define MODULE_PROC_FAMILY "586TSC "
21#elif defined CONFIG_M586MMX 21#elif defined CONFIG_M586MMX
22#define MODULE_PROC_FAMILY "586MMX " 22#define MODULE_PROC_FAMILY "586MMX "
23#elif defined CONFIG_MCORE2
24#define MODULE_PROC_FAMILY "CORE2 "
23#elif defined CONFIG_M686 25#elif defined CONFIG_M686
24#define MODULE_PROC_FAMILY "686 " 26#define MODULE_PROC_FAMILY "686 "
25#elif defined CONFIG_MPENTIUMII 27#elif defined CONFIG_MPENTIUMII
@@ -60,18 +62,12 @@ struct mod_arch_specific
60#error unknown processor family 62#error unknown processor family
61#endif 63#endif
62 64
63#ifdef CONFIG_REGPARM
64#define MODULE_REGPARM "REGPARM "
65#else
66#define MODULE_REGPARM ""
67#endif
68
69#ifdef CONFIG_4KSTACKS 65#ifdef CONFIG_4KSTACKS
70#define MODULE_STACKSIZE "4KSTACKS " 66#define MODULE_STACKSIZE "4KSTACKS "
71#else 67#else
72#define MODULE_STACKSIZE "" 68#define MODULE_STACKSIZE ""
73#endif 69#endif
74 70
75#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_REGPARM MODULE_STACKSIZE 71#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_STACKSIZE
76 72
77#endif /* _ASM_I386_MODULE_H */ 73#endif /* _ASM_I386_MODULE_H */
diff --git a/include/asm-i386/mpspec_def.h b/include/asm-i386/mpspec_def.h
index 76feedf85a8a..13bafb16e7af 100644
--- a/include/asm-i386/mpspec_def.h
+++ b/include/asm-i386/mpspec_def.h
@@ -97,7 +97,6 @@ struct mpc_config_bus
97#define BUSTYPE_TC "TC" 97#define BUSTYPE_TC "TC"
98#define BUSTYPE_VME "VME" 98#define BUSTYPE_VME "VME"
99#define BUSTYPE_XPRESS "XPRESS" 99#define BUSTYPE_XPRESS "XPRESS"
100#define BUSTYPE_NEC98 "NEC98"
101 100
102struct mpc_config_ioapic 101struct mpc_config_ioapic
103{ 102{
@@ -182,7 +181,6 @@ enum mp_bustype {
182 MP_BUS_EISA, 181 MP_BUS_EISA,
183 MP_BUS_PCI, 182 MP_BUS_PCI,
184 MP_BUS_MCA, 183 MP_BUS_MCA,
185 MP_BUS_NEC98
186}; 184};
187#endif 185#endif
188 186
diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h
index 62b76cd96957..5679d4993072 100644
--- a/include/asm-i386/msr.h
+++ b/include/asm-i386/msr.h
@@ -1,6 +1,10 @@
1#ifndef __ASM_MSR_H 1#ifndef __ASM_MSR_H
2#define __ASM_MSR_H 2#define __ASM_MSR_H
3 3
4#ifdef CONFIG_PARAVIRT
5#include <asm/paravirt.h>
6#else
7
4/* 8/*
5 * Access to machine-specific registers (available on 586 and better only) 9 * Access to machine-specific registers (available on 586 and better only)
6 * Note: the rd* operations modify the parameters directly (without using 10 * Note: the rd* operations modify the parameters directly (without using
@@ -77,6 +81,7 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
77 __asm__ __volatile__("rdpmc" \ 81 __asm__ __volatile__("rdpmc" \
78 : "=a" (low), "=d" (high) \ 82 : "=a" (low), "=d" (high) \
79 : "c" (counter)) 83 : "c" (counter))
84#endif /* !CONFIG_PARAVIRT */
80 85
81/* symbolic names for some interesting MSRs */ 86/* symbolic names for some interesting MSRs */
82/* Intel defined MSRs. */ 87/* Intel defined MSRs. */
@@ -141,6 +146,10 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
141#define MSR_IA32_MC0_ADDR 0x402 146#define MSR_IA32_MC0_ADDR 0x402
142#define MSR_IA32_MC0_MISC 0x403 147#define MSR_IA32_MC0_MISC 0x403
143 148
149#define MSR_IA32_PEBS_ENABLE 0x3f1
150#define MSR_IA32_DS_AREA 0x600
151#define MSR_IA32_PERF_CAPABILITIES 0x345
152
144/* Pentium IV performance counter MSRs */ 153/* Pentium IV performance counter MSRs */
145#define MSR_P4_BPU_PERFCTR0 0x300 154#define MSR_P4_BPU_PERFCTR0 0x300
146#define MSR_P4_BPU_PERFCTR1 0x301 155#define MSR_P4_BPU_PERFCTR1 0x301
@@ -284,4 +293,13 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
284#define MSR_TMTA_LRTI_READOUT 0x80868018 293#define MSR_TMTA_LRTI_READOUT 0x80868018
285#define MSR_TMTA_LRTI_VOLT_MHZ 0x8086801a 294#define MSR_TMTA_LRTI_VOLT_MHZ 0x8086801a
286 295
296/* Intel Core-based CPU performance counters */
297#define MSR_CORE_PERF_FIXED_CTR0 0x309
298#define MSR_CORE_PERF_FIXED_CTR1 0x30a
299#define MSR_CORE_PERF_FIXED_CTR2 0x30b
300#define MSR_CORE_PERF_FIXED_CTR_CTRL 0x38d
301#define MSR_CORE_PERF_GLOBAL_STATUS 0x38e
302#define MSR_CORE_PERF_GLOBAL_CTRL 0x38f
303#define MSR_CORE_PERF_GLOBAL_OVF_CTRL 0x390
304
287#endif /* __ASM_MSR_H */ 305#endif /* __ASM_MSR_H */
diff --git a/include/asm-i386/nmi.h b/include/asm-i386/nmi.h
index 269d315719ca..b04333ea6f31 100644
--- a/include/asm-i386/nmi.h
+++ b/include/asm-i386/nmi.h
@@ -5,6 +5,9 @@
5#define ASM_NMI_H 5#define ASM_NMI_H
6 6
7#include <linux/pm.h> 7#include <linux/pm.h>
8#include <asm/irq.h>
9
10#ifdef ARCH_HAS_NMI_WATCHDOG
8 11
9/** 12/**
10 * do_nmi_callback 13 * do_nmi_callback
@@ -42,4 +45,9 @@ extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
42 void __user *, size_t *, loff_t *); 45 void __user *, size_t *, loff_t *);
43extern int unknown_nmi_panic; 46extern int unknown_nmi_panic;
44 47
48void __trigger_all_cpu_backtrace(void);
49#define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace()
50
51#endif
52
45#endif /* ASM_NMI_H */ 53#endif /* ASM_NMI_H */
diff --git a/include/asm-i386/page.h b/include/asm-i386/page.h
index f5bf544c729a..fd3f64ace248 100644
--- a/include/asm-i386/page.h
+++ b/include/asm-i386/page.h
@@ -52,6 +52,7 @@ typedef struct { unsigned long long pgprot; } pgprot_t;
52#define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32)) 52#define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
53#define __pmd(x) ((pmd_t) { (x) } ) 53#define __pmd(x) ((pmd_t) { (x) } )
54#define HPAGE_SHIFT 21 54#define HPAGE_SHIFT 21
55#include <asm-generic/pgtable-nopud.h>
55#else 56#else
56typedef struct { unsigned long pte_low; } pte_t; 57typedef struct { unsigned long pte_low; } pte_t;
57typedef struct { unsigned long pgd; } pgd_t; 58typedef struct { unsigned long pgd; } pgd_t;
@@ -59,6 +60,7 @@ typedef struct { unsigned long pgprot; } pgprot_t;
59#define boot_pte_t pte_t /* or would you rather have a typedef */ 60#define boot_pte_t pte_t /* or would you rather have a typedef */
60#define pte_val(x) ((x).pte_low) 61#define pte_val(x) ((x).pte_low)
61#define HPAGE_SHIFT 22 62#define HPAGE_SHIFT 22
63#include <asm-generic/pgtable-nopmd.h>
62#endif 64#endif
63#define PTE_MASK PAGE_MASK 65#define PTE_MASK PAGE_MASK
64 66
@@ -112,18 +114,18 @@ extern int page_is_ram(unsigned long pagenr);
112 114
113#ifdef __ASSEMBLY__ 115#ifdef __ASSEMBLY__
114#define __PAGE_OFFSET CONFIG_PAGE_OFFSET 116#define __PAGE_OFFSET CONFIG_PAGE_OFFSET
115#define __PHYSICAL_START CONFIG_PHYSICAL_START
116#else 117#else
117#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET) 118#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET)
118#define __PHYSICAL_START ((unsigned long)CONFIG_PHYSICAL_START)
119#endif 119#endif
120#define __KERNEL_START (__PAGE_OFFSET + __PHYSICAL_START)
121 120
122 121
123#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET) 122#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
124#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) 123#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
125#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) 124#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)
126#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) 125#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
126/* __pa_symbol should be used for C visible symbols.
127 This seems to be the official gcc blessed way to do such arithmetic. */
128#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0))
127#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) 129#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
128#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) 130#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
129#ifdef CONFIG_FLATMEM 131#ifdef CONFIG_FLATMEM
diff --git a/include/asm-i386/param.h b/include/asm-i386/param.h
index 745dc5bd0fbc..21b32466fcdc 100644
--- a/include/asm-i386/param.h
+++ b/include/asm-i386/param.h
@@ -18,6 +18,5 @@
18#endif 18#endif
19 19
20#define MAXHOSTNAMELEN 64 /* max length of hostname */ 20#define MAXHOSTNAMELEN 64 /* max length of hostname */
21#define COMMAND_LINE_SIZE 256
22 21
23#endif 22#endif
diff --git a/include/asm-i386/paravirt.h b/include/asm-i386/paravirt.h
new file mode 100644
index 000000000000..9f06265065f4
--- /dev/null
+++ b/include/asm-i386/paravirt.h
@@ -0,0 +1,505 @@
1#ifndef __ASM_PARAVIRT_H
2#define __ASM_PARAVIRT_H
3/* Various instructions on x86 need to be replaced for
4 * para-virtualization: those hooks are defined here. */
5#include <linux/linkage.h>
6#include <linux/stringify.h>
7#include <asm/page.h>
8
9#ifdef CONFIG_PARAVIRT
10/* These are the most performance critical ops, so we want to be able to patch
11 * callers */
12#define PARAVIRT_IRQ_DISABLE 0
13#define PARAVIRT_IRQ_ENABLE 1
14#define PARAVIRT_RESTORE_FLAGS 2
15#define PARAVIRT_SAVE_FLAGS 3
16#define PARAVIRT_SAVE_FLAGS_IRQ_DISABLE 4
17#define PARAVIRT_INTERRUPT_RETURN 5
18#define PARAVIRT_STI_SYSEXIT 6
19
20/* Bitmask of what can be clobbered: usually at least eax. */
21#define CLBR_NONE 0x0
22#define CLBR_EAX 0x1
23#define CLBR_ECX 0x2
24#define CLBR_EDX 0x4
25#define CLBR_ANY 0x7
26
27#ifndef __ASSEMBLY__
28struct thread_struct;
29struct Xgt_desc_struct;
30struct tss_struct;
31struct mm_struct;
32struct paravirt_ops
33{
34 unsigned int kernel_rpl;
35 int paravirt_enabled;
36 const char *name;
37
38 /*
39 * Patch may replace one of the defined code sequences with arbitrary
40 * code, subject to the same register constraints. This generally
41 * means the code is not free to clobber any registers other than EAX.
42 * The patch function should return the number of bytes of code
43 * generated, as we nop pad the rest in generic code.
44 */
45 unsigned (*patch)(u8 type, u16 clobber, void *firstinsn, unsigned len);
46
47 void (*arch_setup)(void);
48 char *(*memory_setup)(void);
49 void (*init_IRQ)(void);
50
51 void (*banner)(void);
52
53 unsigned long (*get_wallclock)(void);
54 int (*set_wallclock)(unsigned long);
55 void (*time_init)(void);
56
57 /* All the function pointers here are declared as "fastcall"
58 so that we get a specific register-based calling
59 convention. This makes it easier to implement inline
60 assembler replacements. */
61
62 void (fastcall *cpuid)(unsigned int *eax, unsigned int *ebx,
63 unsigned int *ecx, unsigned int *edx);
64
65 unsigned long (fastcall *get_debugreg)(int regno);
66 void (fastcall *set_debugreg)(int regno, unsigned long value);
67
68 void (fastcall *clts)(void);
69
70 unsigned long (fastcall *read_cr0)(void);
71 void (fastcall *write_cr0)(unsigned long);
72
73 unsigned long (fastcall *read_cr2)(void);
74 void (fastcall *write_cr2)(unsigned long);
75
76 unsigned long (fastcall *read_cr3)(void);
77 void (fastcall *write_cr3)(unsigned long);
78
79 unsigned long (fastcall *read_cr4_safe)(void);
80 unsigned long (fastcall *read_cr4)(void);
81 void (fastcall *write_cr4)(unsigned long);
82
83 unsigned long (fastcall *save_fl)(void);
84 void (fastcall *restore_fl)(unsigned long);
85 void (fastcall *irq_disable)(void);
86 void (fastcall *irq_enable)(void);
87 void (fastcall *safe_halt)(void);
88 void (fastcall *halt)(void);
89 void (fastcall *wbinvd)(void);
90
91 /* err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */
92 u64 (fastcall *read_msr)(unsigned int msr, int *err);
93 int (fastcall *write_msr)(unsigned int msr, u64 val);
94
95 u64 (fastcall *read_tsc)(void);
96 u64 (fastcall *read_pmc)(void);
97
98 void (fastcall *load_tr_desc)(void);
99 void (fastcall *load_gdt)(const struct Xgt_desc_struct *);
100 void (fastcall *load_idt)(const struct Xgt_desc_struct *);
101 void (fastcall *store_gdt)(struct Xgt_desc_struct *);
102 void (fastcall *store_idt)(struct Xgt_desc_struct *);
103 void (fastcall *set_ldt)(const void *desc, unsigned entries);
104 unsigned long (fastcall *store_tr)(void);
105 void (fastcall *load_tls)(struct thread_struct *t, unsigned int cpu);
106 void (fastcall *write_ldt_entry)(void *dt, int entrynum,
107 u32 low, u32 high);
108 void (fastcall *write_gdt_entry)(void *dt, int entrynum,
109 u32 low, u32 high);
110 void (fastcall *write_idt_entry)(void *dt, int entrynum,
111 u32 low, u32 high);
112 void (fastcall *load_esp0)(struct tss_struct *tss,
113 struct thread_struct *thread);
114
115 void (fastcall *set_iopl_mask)(unsigned mask);
116
117 void (fastcall *io_delay)(void);
118 void (*const_udelay)(unsigned long loops);
119
120#ifdef CONFIG_X86_LOCAL_APIC
121 void (fastcall *apic_write)(unsigned long reg, unsigned long v);
122 void (fastcall *apic_write_atomic)(unsigned long reg, unsigned long v);
123 unsigned long (fastcall *apic_read)(unsigned long reg);
124#endif
125
126 void (fastcall *flush_tlb_user)(void);
127 void (fastcall *flush_tlb_kernel)(void);
128 void (fastcall *flush_tlb_single)(u32 addr);
129
130 void (fastcall *set_pte)(pte_t *ptep, pte_t pteval);
131 void (fastcall *set_pte_at)(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pteval);
132 void (fastcall *set_pmd)(pmd_t *pmdp, pmd_t pmdval);
133 void (fastcall *pte_update)(struct mm_struct *mm, u32 addr, pte_t *ptep);
134 void (fastcall *pte_update_defer)(struct mm_struct *mm, u32 addr, pte_t *ptep);
135#ifdef CONFIG_X86_PAE
136 void (fastcall *set_pte_atomic)(pte_t *ptep, pte_t pteval);
137 void (fastcall *set_pte_present)(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte);
138 void (fastcall *set_pud)(pud_t *pudp, pud_t pudval);
139 void (fastcall *pte_clear)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
140 void (fastcall *pmd_clear)(pmd_t *pmdp);
141#endif
142
143 /* These two are jmp to, not actually called. */
144 void (fastcall *irq_enable_sysexit)(void);
145 void (fastcall *iret)(void);
146};
147
148/* Mark a paravirt probe function. */
149#define paravirt_probe(fn) \
150 static asmlinkage void (*__paravirtprobe_##fn)(void) __attribute_used__ \
151 __attribute__((__section__(".paravirtprobe"))) = fn
152
153extern struct paravirt_ops paravirt_ops;
154
155#define paravirt_enabled() (paravirt_ops.paravirt_enabled)
156
157static inline void load_esp0(struct tss_struct *tss,
158 struct thread_struct *thread)
159{
160 paravirt_ops.load_esp0(tss, thread);
161}
162
163#define ARCH_SETUP paravirt_ops.arch_setup();
164static inline unsigned long get_wallclock(void)
165{
166 return paravirt_ops.get_wallclock();
167}
168
169static inline int set_wallclock(unsigned long nowtime)
170{
171 return paravirt_ops.set_wallclock(nowtime);
172}
173
174static inline void do_time_init(void)
175{
176 return paravirt_ops.time_init();
177}
178
179/* The paravirtualized CPUID instruction. */
180static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
181 unsigned int *ecx, unsigned int *edx)
182{
183 paravirt_ops.cpuid(eax, ebx, ecx, edx);
184}
185
186/*
187 * These special macros can be used to get or set a debugging register
188 */
189#define get_debugreg(var, reg) var = paravirt_ops.get_debugreg(reg)
190#define set_debugreg(val, reg) paravirt_ops.set_debugreg(reg, val)
191
192#define clts() paravirt_ops.clts()
193
194#define read_cr0() paravirt_ops.read_cr0()
195#define write_cr0(x) paravirt_ops.write_cr0(x)
196
197#define read_cr2() paravirt_ops.read_cr2()
198#define write_cr2(x) paravirt_ops.write_cr2(x)
199
200#define read_cr3() paravirt_ops.read_cr3()
201#define write_cr3(x) paravirt_ops.write_cr3(x)
202
203#define read_cr4() paravirt_ops.read_cr4()
204#define read_cr4_safe(x) paravirt_ops.read_cr4_safe()
205#define write_cr4(x) paravirt_ops.write_cr4(x)
206
207static inline void raw_safe_halt(void)
208{
209 paravirt_ops.safe_halt();
210}
211
212static inline void halt(void)
213{
214 paravirt_ops.safe_halt();
215}
216#define wbinvd() paravirt_ops.wbinvd()
217
218#define get_kernel_rpl() (paravirt_ops.kernel_rpl)
219
220#define rdmsr(msr,val1,val2) do { \
221 int _err; \
222 u64 _l = paravirt_ops.read_msr(msr,&_err); \
223 val1 = (u32)_l; \
224 val2 = _l >> 32; \
225} while(0)
226
227#define wrmsr(msr,val1,val2) do { \
228 u64 _l = ((u64)(val2) << 32) | (val1); \
229 paravirt_ops.write_msr((msr), _l); \
230} while(0)
231
232#define rdmsrl(msr,val) do { \
233 int _err; \
234 val = paravirt_ops.read_msr((msr),&_err); \
235} while(0)
236
237#define wrmsrl(msr,val) (paravirt_ops.write_msr((msr),(val)))
238#define wrmsr_safe(msr,a,b) ({ \
239 u64 _l = ((u64)(b) << 32) | (a); \
240 paravirt_ops.write_msr((msr),_l); \
241})
242
243/* rdmsr with exception handling */
244#define rdmsr_safe(msr,a,b) ({ \
245 int _err; \
246 u64 _l = paravirt_ops.read_msr(msr,&_err); \
247 (*a) = (u32)_l; \
248 (*b) = _l >> 32; \
249 _err; })
250
251#define rdtsc(low,high) do { \
252 u64 _l = paravirt_ops.read_tsc(); \
253 low = (u32)_l; \
254 high = _l >> 32; \
255} while(0)
256
257#define rdtscl(low) do { \
258 u64 _l = paravirt_ops.read_tsc(); \
259 low = (int)_l; \
260} while(0)
261
262#define rdtscll(val) (val = paravirt_ops.read_tsc())
263
264#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
265
266#define rdpmc(counter,low,high) do { \
267 u64 _l = paravirt_ops.read_pmc(); \
268 low = (u32)_l; \
269 high = _l >> 32; \
270} while(0)
271
272#define load_TR_desc() (paravirt_ops.load_tr_desc())
273#define load_gdt(dtr) (paravirt_ops.load_gdt(dtr))
274#define load_idt(dtr) (paravirt_ops.load_idt(dtr))
275#define set_ldt(addr, entries) (paravirt_ops.set_ldt((addr), (entries)))
276#define store_gdt(dtr) (paravirt_ops.store_gdt(dtr))
277#define store_idt(dtr) (paravirt_ops.store_idt(dtr))
278#define store_tr(tr) ((tr) = paravirt_ops.store_tr())
279#define load_TLS(t,cpu) (paravirt_ops.load_tls((t),(cpu)))
280#define write_ldt_entry(dt, entry, low, high) \
281 (paravirt_ops.write_ldt_entry((dt), (entry), (low), (high)))
282#define write_gdt_entry(dt, entry, low, high) \
283 (paravirt_ops.write_gdt_entry((dt), (entry), (low), (high)))
284#define write_idt_entry(dt, entry, low, high) \
285 (paravirt_ops.write_idt_entry((dt), (entry), (low), (high)))
286#define set_iopl_mask(mask) (paravirt_ops.set_iopl_mask(mask))
287
288/* The paravirtualized I/O functions */
289static inline void slow_down_io(void) {
290 paravirt_ops.io_delay();
291#ifdef REALLY_SLOW_IO
292 paravirt_ops.io_delay();
293 paravirt_ops.io_delay();
294 paravirt_ops.io_delay();
295#endif
296}
297
298#ifdef CONFIG_X86_LOCAL_APIC
299/*
300 * Basic functions accessing APICs.
301 */
302static inline void apic_write(unsigned long reg, unsigned long v)
303{
304 paravirt_ops.apic_write(reg,v);
305}
306
307static inline void apic_write_atomic(unsigned long reg, unsigned long v)
308{
309 paravirt_ops.apic_write_atomic(reg,v);
310}
311
312static inline unsigned long apic_read(unsigned long reg)
313{
314 return paravirt_ops.apic_read(reg);
315}
316#endif
317
318
319#define __flush_tlb() paravirt_ops.flush_tlb_user()
320#define __flush_tlb_global() paravirt_ops.flush_tlb_kernel()
321#define __flush_tlb_single(addr) paravirt_ops.flush_tlb_single(addr)
322
323static inline void set_pte(pte_t *ptep, pte_t pteval)
324{
325 paravirt_ops.set_pte(ptep, pteval);
326}
327
328static inline void set_pte_at(struct mm_struct *mm, u32 addr, pte_t *ptep, pte_t pteval)
329{
330 paravirt_ops.set_pte_at(mm, addr, ptep, pteval);
331}
332
333static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval)
334{
335 paravirt_ops.set_pmd(pmdp, pmdval);
336}
337
338static inline void pte_update(struct mm_struct *mm, u32 addr, pte_t *ptep)
339{
340 paravirt_ops.pte_update(mm, addr, ptep);
341}
342
343static inline void pte_update_defer(struct mm_struct *mm, u32 addr, pte_t *ptep)
344{
345 paravirt_ops.pte_update_defer(mm, addr, ptep);
346}
347
348#ifdef CONFIG_X86_PAE
349static inline void set_pte_atomic(pte_t *ptep, pte_t pteval)
350{
351 paravirt_ops.set_pte_atomic(ptep, pteval);
352}
353
354static inline void set_pte_present(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte)
355{
356 paravirt_ops.set_pte_present(mm, addr, ptep, pte);
357}
358
359static inline void set_pud(pud_t *pudp, pud_t pudval)
360{
361 paravirt_ops.set_pud(pudp, pudval);
362}
363
364static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
365{
366 paravirt_ops.pte_clear(mm, addr, ptep);
367}
368
369static inline void pmd_clear(pmd_t *pmdp)
370{
371 paravirt_ops.pmd_clear(pmdp);
372}
373#endif
374
375/* These all sit in the .parainstructions section to tell us what to patch. */
376struct paravirt_patch {
377 u8 *instr; /* original instructions */
378 u8 instrtype; /* type of this instruction */
379 u8 len; /* length of original instruction */
380 u16 clobbers; /* what registers you may clobber */
381};
382
383#define paravirt_alt(insn_string, typenum, clobber) \
384 "771:\n\t" insn_string "\n" "772:\n" \
385 ".pushsection .parainstructions,\"a\"\n" \
386 " .long 771b\n" \
387 " .byte " __stringify(typenum) "\n" \
388 " .byte 772b-771b\n" \
389 " .short " __stringify(clobber) "\n" \
390 ".popsection"
391
392static inline unsigned long __raw_local_save_flags(void)
393{
394 unsigned long f;
395
396 __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
397 "call *%1;"
398 "popl %%edx; popl %%ecx",
399 PARAVIRT_SAVE_FLAGS, CLBR_NONE)
400 : "=a"(f): "m"(paravirt_ops.save_fl)
401 : "memory", "cc");
402 return f;
403}
404
405static inline void raw_local_irq_restore(unsigned long f)
406{
407 __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
408 "call *%1;"
409 "popl %%edx; popl %%ecx",
410 PARAVIRT_RESTORE_FLAGS, CLBR_EAX)
411 : "=a"(f) : "m" (paravirt_ops.restore_fl), "0"(f)
412 : "memory", "cc");
413}
414
415static inline void raw_local_irq_disable(void)
416{
417 __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
418 "call *%0;"
419 "popl %%edx; popl %%ecx",
420 PARAVIRT_IRQ_DISABLE, CLBR_EAX)
421 : : "m" (paravirt_ops.irq_disable)
422 : "memory", "eax", "cc");
423}
424
425static inline void raw_local_irq_enable(void)
426{
427 __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
428 "call *%0;"
429 "popl %%edx; popl %%ecx",
430 PARAVIRT_IRQ_ENABLE, CLBR_EAX)
431 : : "m" (paravirt_ops.irq_enable)
432 : "memory", "eax", "cc");
433}
434
435static inline unsigned long __raw_local_irq_save(void)
436{
437 unsigned long f;
438
439 __asm__ __volatile__(paravirt_alt( "pushl %%ecx; pushl %%edx;"
440 "call *%1; pushl %%eax;"
441 "call *%2; popl %%eax;"
442 "popl %%edx; popl %%ecx",
443 PARAVIRT_SAVE_FLAGS_IRQ_DISABLE,
444 CLBR_NONE)
445 : "=a"(f)
446 : "m" (paravirt_ops.save_fl),
447 "m" (paravirt_ops.irq_disable)
448 : "memory", "cc");
449 return f;
450}
451
452#define CLI_STRING paravirt_alt("pushl %%ecx; pushl %%edx;" \
453 "call *paravirt_ops+%c[irq_disable];" \
454 "popl %%edx; popl %%ecx", \
455 PARAVIRT_IRQ_DISABLE, CLBR_EAX)
456
457#define STI_STRING paravirt_alt("pushl %%ecx; pushl %%edx;" \
458 "call *paravirt_ops+%c[irq_enable];" \
459 "popl %%edx; popl %%ecx", \
460 PARAVIRT_IRQ_ENABLE, CLBR_EAX)
461#define CLI_STI_CLOBBERS , "%eax"
462#define CLI_STI_INPUT_ARGS \
463 , \
464 [irq_disable] "i" (offsetof(struct paravirt_ops, irq_disable)), \
465 [irq_enable] "i" (offsetof(struct paravirt_ops, irq_enable))
466
467#else /* __ASSEMBLY__ */
468
469#define PARA_PATCH(ptype, clobbers, ops) \
470771:; \
471 ops; \
472772:; \
473 .pushsection .parainstructions,"a"; \
474 .long 771b; \
475 .byte ptype; \
476 .byte 772b-771b; \
477 .short clobbers; \
478 .popsection
479
480#define INTERRUPT_RETURN \
481 PARA_PATCH(PARAVIRT_INTERRUPT_RETURN, CLBR_ANY, \
482 jmp *%cs:paravirt_ops+PARAVIRT_iret)
483
484#define DISABLE_INTERRUPTS(clobbers) \
485 PARA_PATCH(PARAVIRT_IRQ_DISABLE, clobbers, \
486 pushl %ecx; pushl %edx; \
487 call *paravirt_ops+PARAVIRT_irq_disable; \
488 popl %edx; popl %ecx) \
489
490#define ENABLE_INTERRUPTS(clobbers) \
491 PARA_PATCH(PARAVIRT_IRQ_ENABLE, clobbers, \
492 pushl %ecx; pushl %edx; \
493 call *%cs:paravirt_ops+PARAVIRT_irq_enable; \
494 popl %edx; popl %ecx)
495
496#define ENABLE_INTERRUPTS_SYSEXIT \
497 PARA_PATCH(PARAVIRT_STI_SYSEXIT, CLBR_ANY, \
498 jmp *%cs:paravirt_ops+PARAVIRT_irq_enable_sysexit)
499
500#define GET_CR0_INTO_EAX \
501 call *paravirt_ops+PARAVIRT_read_cr0
502
503#endif /* __ASSEMBLY__ */
504#endif /* CONFIG_PARAVIRT */
505#endif /* __ASM_PARAVIRT_H */
diff --git a/include/asm-i386/pda.h b/include/asm-i386/pda.h
new file mode 100644
index 000000000000..2ba2736aa109
--- /dev/null
+++ b/include/asm-i386/pda.h
@@ -0,0 +1,100 @@
1/*
2 Per-processor Data Areas
3 Jeremy Fitzhardinge <jeremy@goop.org> 2006
4 Based on asm-x86_64/pda.h by Andi Kleen.
5 */
6#ifndef _I386_PDA_H
7#define _I386_PDA_H
8
9#include <linux/stddef.h>
10#include <linux/types.h>
11
12struct i386_pda
13{
14 struct i386_pda *_pda; /* pointer to self */
15
16 int cpu_number;
17 struct task_struct *pcurrent; /* current process */
18 struct pt_regs *irq_regs;
19};
20
21extern struct i386_pda *_cpu_pda[];
22
23#define cpu_pda(i) (_cpu_pda[i])
24
25#define pda_offset(field) offsetof(struct i386_pda, field)
26
27extern void __bad_pda_field(void);
28
29/* This variable is never instantiated. It is only used as a stand-in
30 for the real per-cpu PDA memory, so that gcc can understand what
31 memory operations the inline asms() below are performing. This
32 eliminates the need to make the asms volatile or have memory
33 clobbers, so gcc can readily analyse them. */
34extern struct i386_pda _proxy_pda;
35
36#define pda_to_op(op,field,val) \
37 do { \
38 typedef typeof(_proxy_pda.field) T__; \
39 if (0) { T__ tmp__; tmp__ = (val); } \
40 switch (sizeof(_proxy_pda.field)) { \
41 case 1: \
42 asm(op "b %1,%%gs:%c2" \
43 : "+m" (_proxy_pda.field) \
44 :"ri" ((T__)val), \
45 "i"(pda_offset(field))); \
46 break; \
47 case 2: \
48 asm(op "w %1,%%gs:%c2" \
49 : "+m" (_proxy_pda.field) \
50 :"ri" ((T__)val), \
51 "i"(pda_offset(field))); \
52 break; \
53 case 4: \
54 asm(op "l %1,%%gs:%c2" \
55 : "+m" (_proxy_pda.field) \
56 :"ri" ((T__)val), \
57 "i"(pda_offset(field))); \
58 break; \
59 default: __bad_pda_field(); \
60 } \
61 } while (0)
62
63#define pda_from_op(op,field) \
64 ({ \
65 typeof(_proxy_pda.field) ret__; \
66 switch (sizeof(_proxy_pda.field)) { \
67 case 1: \
68 asm(op "b %%gs:%c1,%0" \
69 : "=r" (ret__) \
70 : "i" (pda_offset(field)), \
71 "m" (_proxy_pda.field)); \
72 break; \
73 case 2: \
74 asm(op "w %%gs:%c1,%0" \
75 : "=r" (ret__) \
76 : "i" (pda_offset(field)), \
77 "m" (_proxy_pda.field)); \
78 break; \
79 case 4: \
80 asm(op "l %%gs:%c1,%0" \
81 : "=r" (ret__) \
82 : "i" (pda_offset(field)), \
83 "m" (_proxy_pda.field)); \
84 break; \
85 default: __bad_pda_field(); \
86 } \
87 ret__; })
88
89/* Return a pointer to a pda field */
90#define pda_addr(field) \
91 ((typeof(_proxy_pda.field) *)((unsigned char *)read_pda(_pda) + \
92 pda_offset(field)))
93
94#define read_pda(field) pda_from_op("mov",field)
95#define write_pda(field,val) pda_to_op("mov",field,val)
96#define add_pda(field,val) pda_to_op("add",field,val)
97#define sub_pda(field,val) pda_to_op("sub",field,val)
98#define or_pda(field,val) pda_to_op("or",field,val)
99
100#endif /* _I386_PDA_H */
diff --git a/include/asm-i386/percpu.h b/include/asm-i386/percpu.h
index 5764afa4b6a4..510ae1d3486c 100644
--- a/include/asm-i386/percpu.h
+++ b/include/asm-i386/percpu.h
@@ -1,6 +1,31 @@
1#ifndef __ARCH_I386_PERCPU__ 1#ifndef __ARCH_I386_PERCPU__
2#define __ARCH_I386_PERCPU__ 2#define __ARCH_I386_PERCPU__
3 3
4#ifndef __ASSEMBLY__
4#include <asm-generic/percpu.h> 5#include <asm-generic/percpu.h>
6#else
7
8/*
9 * PER_CPU finds an address of a per-cpu variable.
10 *
11 * Args:
12 * var - variable name
13 * cpu - 32bit register containing the current CPU number
14 *
15 * The resulting address is stored in the "cpu" argument.
16 *
17 * Example:
18 * PER_CPU(cpu_gdt_descr, %ebx)
19 */
20#ifdef CONFIG_SMP
21#define PER_CPU(var, cpu) \
22 movl __per_cpu_offset(,cpu,4), cpu; \
23 addl $per_cpu__/**/var, cpu;
24#else /* ! SMP */
25#define PER_CPU(var, cpu) \
26 movl $per_cpu__/**/var, cpu;
27#endif /* SMP */
28
29#endif /* !__ASSEMBLY__ */
5 30
6#endif /* __ARCH_I386_PERCPU__ */ 31#endif /* __ARCH_I386_PERCPU__ */
diff --git a/include/asm-i386/pgtable-2level.h b/include/asm-i386/pgtable-2level.h
index 8d8d3b9ecdb0..38c3fcc0676d 100644
--- a/include/asm-i386/pgtable-2level.h
+++ b/include/asm-i386/pgtable-2level.h
@@ -1,8 +1,6 @@
1#ifndef _I386_PGTABLE_2LEVEL_H 1#ifndef _I386_PGTABLE_2LEVEL_H
2#define _I386_PGTABLE_2LEVEL_H 2#define _I386_PGTABLE_2LEVEL_H
3 3
4#include <asm-generic/pgtable-nopmd.h>
5
6#define pte_ERROR(e) \ 4#define pte_ERROR(e) \
7 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low) 5 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low)
8#define pgd_ERROR(e) \ 6#define pgd_ERROR(e) \
@@ -13,17 +11,19 @@
13 * within a page table are directly modified. Thus, the following 11 * within a page table are directly modified. Thus, the following
14 * hook is made available. 12 * hook is made available.
15 */ 13 */
14#ifndef CONFIG_PARAVIRT
16#define set_pte(pteptr, pteval) (*(pteptr) = pteval) 15#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
17#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) 16#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
17#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
18#endif
19
18#define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval) 20#define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
19#define set_pte_present(mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval) 21#define set_pte_present(mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval)
20#define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval))
21 22
22#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) 23#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
23#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0) 24#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
24 25
25#define __HAVE_ARCH_PTEP_GET_AND_CLEAR 26#define raw_ptep_get_and_clear(xp) __pte(xchg(&(xp)->pte_low, 0))
26#define ptep_get_and_clear(mm,addr,xp) __pte(xchg(&(xp)->pte_low, 0))
27 27
28#define pte_page(x) pfn_to_page(pte_pfn(x)) 28#define pte_page(x) pfn_to_page(pte_pfn(x))
29#define pte_none(x) (!(x).pte_low) 29#define pte_none(x) (!(x).pte_low)
diff --git a/include/asm-i386/pgtable-3level.h b/include/asm-i386/pgtable-3level.h
index c2d701ea35be..7a2318f38303 100644
--- a/include/asm-i386/pgtable-3level.h
+++ b/include/asm-i386/pgtable-3level.h
@@ -1,8 +1,6 @@
1#ifndef _I386_PGTABLE_3LEVEL_H 1#ifndef _I386_PGTABLE_3LEVEL_H
2#define _I386_PGTABLE_3LEVEL_H 2#define _I386_PGTABLE_3LEVEL_H
3 3
4#include <asm-generic/pgtable-nopud.h>
5
6/* 4/*
7 * Intel Physical Address Extension (PAE) Mode - three-level page 5 * Intel Physical Address Extension (PAE) Mode - three-level page
8 * tables on PPro+ CPUs. 6 * tables on PPro+ CPUs.
@@ -44,6 +42,7 @@ static inline int pte_exec_kernel(pte_t pte)
44 return pte_x(pte); 42 return pte_x(pte);
45} 43}
46 44
45#ifndef CONFIG_PARAVIRT
47/* Rules for using set_pte: the pte being assigned *must* be 46/* Rules for using set_pte: the pte being assigned *must* be
48 * either not present or in a state where the hardware will 47 * either not present or in a state where the hardware will
49 * not attempt to update the pte. In places where this is 48 * not attempt to update the pte. In places where this is
@@ -81,25 +80,6 @@ static inline void set_pte_present(struct mm_struct *mm, unsigned long addr, pte
81 (*(pudptr) = (pudval)) 80 (*(pudptr) = (pudval))
82 81
83/* 82/*
84 * Pentium-II erratum A13: in PAE mode we explicitly have to flush
85 * the TLB via cr3 if the top-level pgd is changed...
86 * We do not let the generic code free and clear pgd entries due to
87 * this erratum.
88 */
89static inline void pud_clear (pud_t * pud) { }
90
91#define pud_page(pud) \
92((struct page *) __va(pud_val(pud) & PAGE_MASK))
93
94#define pud_page_vaddr(pud) \
95((unsigned long) __va(pud_val(pud) & PAGE_MASK))
96
97
98/* Find an entry in the second-level page table.. */
99#define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \
100 pmd_index(address))
101
102/*
103 * For PTEs and PDEs, we must clear the P-bit first when clearing a page table 83 * For PTEs and PDEs, we must clear the P-bit first when clearing a page table
104 * entry, so clear the bottom half first and enforce ordering with a compiler 84 * entry, so clear the bottom half first and enforce ordering with a compiler
105 * barrier. 85 * barrier.
@@ -118,9 +98,28 @@ static inline void pmd_clear(pmd_t *pmd)
118 smp_wmb(); 98 smp_wmb();
119 *(tmp + 1) = 0; 99 *(tmp + 1) = 0;
120} 100}
101#endif
102
103/*
104 * Pentium-II erratum A13: in PAE mode we explicitly have to flush
105 * the TLB via cr3 if the top-level pgd is changed...
106 * We do not let the generic code free and clear pgd entries due to
107 * this erratum.
108 */
109static inline void pud_clear (pud_t * pud) { }
110
111#define pud_page(pud) \
112((struct page *) __va(pud_val(pud) & PAGE_MASK))
113
114#define pud_page_vaddr(pud) \
115((unsigned long) __va(pud_val(pud) & PAGE_MASK))
116
117
118/* Find an entry in the second-level page table.. */
119#define pmd_offset(pud, address) ((pmd_t *) pud_page(*(pud)) + \
120 pmd_index(address))
121 121
122#define __HAVE_ARCH_PTEP_GET_AND_CLEAR 122static inline pte_t raw_ptep_get_and_clear(pte_t *ptep)
123static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
124{ 123{
125 pte_t res; 124 pte_t res;
126 125
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
index 7d398f493dde..e6a4723f0eb1 100644
--- a/include/asm-i386/pgtable.h
+++ b/include/asm-i386/pgtable.h
@@ -15,6 +15,7 @@
15#include <asm/processor.h> 15#include <asm/processor.h>
16#include <asm/fixmap.h> 16#include <asm/fixmap.h>
17#include <linux/threads.h> 17#include <linux/threads.h>
18#include <asm/paravirt.h>
18 19
19#ifndef _I386_BITOPS_H 20#ifndef _I386_BITOPS_H
20#include <asm/bitops.h> 21#include <asm/bitops.h>
@@ -34,14 +35,14 @@ struct vm_area_struct;
34#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 35#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
35extern unsigned long empty_zero_page[1024]; 36extern unsigned long empty_zero_page[1024];
36extern pgd_t swapper_pg_dir[1024]; 37extern pgd_t swapper_pg_dir[1024];
37extern kmem_cache_t *pgd_cache; 38extern struct kmem_cache *pgd_cache;
38extern kmem_cache_t *pmd_cache; 39extern struct kmem_cache *pmd_cache;
39extern spinlock_t pgd_lock; 40extern spinlock_t pgd_lock;
40extern struct page *pgd_list; 41extern struct page *pgd_list;
41 42
42void pmd_ctor(void *, kmem_cache_t *, unsigned long); 43void pmd_ctor(void *, struct kmem_cache *, unsigned long);
43void pgd_ctor(void *, kmem_cache_t *, unsigned long); 44void pgd_ctor(void *, struct kmem_cache *, unsigned long);
44void pgd_dtor(void *, kmem_cache_t *, unsigned long); 45void pgd_dtor(void *, struct kmem_cache *, unsigned long);
45void pgtable_cache_init(void); 46void pgtable_cache_init(void);
46void paging_init(void); 47void paging_init(void);
47 48
@@ -246,6 +247,7 @@ static inline pte_t pte_mkhuge(pte_t pte) { (pte).pte_low |= _PAGE_PSE; return p
246# include <asm/pgtable-2level.h> 247# include <asm/pgtable-2level.h>
247#endif 248#endif
248 249
250#ifndef CONFIG_PARAVIRT
249/* 251/*
250 * Rules for using pte_update - it must be called after any PTE update which 252 * Rules for using pte_update - it must be called after any PTE update which
251 * has not been done using the set_pte / clear_pte interfaces. It is used by 253 * has not been done using the set_pte / clear_pte interfaces. It is used by
@@ -261,7 +263,7 @@ static inline pte_t pte_mkhuge(pte_t pte) { (pte).pte_low |= _PAGE_PSE; return p
261 */ 263 */
262#define pte_update(mm, addr, ptep) do { } while (0) 264#define pte_update(mm, addr, ptep) do { } while (0)
263#define pte_update_defer(mm, addr, ptep) do { } while (0) 265#define pte_update_defer(mm, addr, ptep) do { } while (0)
264 266#endif
265 267
266/* 268/*
267 * We only update the dirty/accessed state if we set 269 * We only update the dirty/accessed state if we set
@@ -275,7 +277,7 @@ static inline pte_t pte_mkhuge(pte_t pte) { (pte).pte_low |= _PAGE_PSE; return p
275do { \ 277do { \
276 if (dirty) { \ 278 if (dirty) { \
277 (ptep)->pte_low = (entry).pte_low; \ 279 (ptep)->pte_low = (entry).pte_low; \
278 pte_update_defer((vma)->vm_mm, (addr), (ptep)); \ 280 pte_update_defer((vma)->vm_mm, (address), (ptep)); \
279 flush_tlb_page(vma, address); \ 281 flush_tlb_page(vma, address); \
280 } \ 282 } \
281} while (0) 283} while (0)
@@ -305,7 +307,7 @@ do { \
305 __dirty = pte_dirty(*(ptep)); \ 307 __dirty = pte_dirty(*(ptep)); \
306 if (__dirty) { \ 308 if (__dirty) { \
307 clear_bit(_PAGE_BIT_DIRTY, &(ptep)->pte_low); \ 309 clear_bit(_PAGE_BIT_DIRTY, &(ptep)->pte_low); \
308 pte_update_defer((vma)->vm_mm, (addr), (ptep)); \ 310 pte_update_defer((vma)->vm_mm, (address), (ptep)); \
309 flush_tlb_page(vma, address); \ 311 flush_tlb_page(vma, address); \
310 } \ 312 } \
311 __dirty; \ 313 __dirty; \
@@ -318,12 +320,20 @@ do { \
318 __young = pte_young(*(ptep)); \ 320 __young = pte_young(*(ptep)); \
319 if (__young) { \ 321 if (__young) { \
320 clear_bit(_PAGE_BIT_ACCESSED, &(ptep)->pte_low); \ 322 clear_bit(_PAGE_BIT_ACCESSED, &(ptep)->pte_low); \
321 pte_update_defer((vma)->vm_mm, (addr), (ptep)); \ 323 pte_update_defer((vma)->vm_mm, (address), (ptep)); \
322 flush_tlb_page(vma, address); \ 324 flush_tlb_page(vma, address); \
323 } \ 325 } \
324 __young; \ 326 __young; \
325}) 327})
326 328
329#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
330static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
331{
332 pte_t pte = raw_ptep_get_and_clear(ptep);
333 pte_update(mm, addr, ptep);
334 return pte;
335}
336
327#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL 337#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
328static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full) 338static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
329{ 339{
diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h
index e0ddca94d50c..a52d65440429 100644
--- a/include/asm-i386/processor.h
+++ b/include/asm-i386/processor.h
@@ -20,6 +20,7 @@
20#include <linux/threads.h> 20#include <linux/threads.h>
21#include <asm/percpu.h> 21#include <asm/percpu.h>
22#include <linux/cpumask.h> 22#include <linux/cpumask.h>
23#include <linux/init.h>
23 24
24/* flag for disabling the tsc */ 25/* flag for disabling the tsc */
25extern int tsc_disable; 26extern int tsc_disable;
@@ -72,6 +73,7 @@ struct cpuinfo_x86 {
72#endif 73#endif
73 unsigned char x86_max_cores; /* cpuid returned max cores value */ 74 unsigned char x86_max_cores; /* cpuid returned max cores value */
74 unsigned char apicid; 75 unsigned char apicid;
76 unsigned short x86_clflush_size;
75#ifdef CONFIG_SMP 77#ifdef CONFIG_SMP
76 unsigned char booted_cores; /* number of cores as seen by OS */ 78 unsigned char booted_cores; /* number of cores as seen by OS */
77 __u8 phys_proc_id; /* Physical processor id. */ 79 __u8 phys_proc_id; /* Physical processor id. */
@@ -111,6 +113,8 @@ extern struct cpuinfo_x86 cpu_data[];
111extern int cpu_llc_id[NR_CPUS]; 113extern int cpu_llc_id[NR_CPUS];
112extern char ignore_fpu_irq; 114extern char ignore_fpu_irq;
113 115
116void __init cpu_detect(struct cpuinfo_x86 *c);
117
114extern void identify_cpu(struct cpuinfo_x86 *); 118extern void identify_cpu(struct cpuinfo_x86 *);
115extern void print_cpu_info(struct cpuinfo_x86 *); 119extern void print_cpu_info(struct cpuinfo_x86 *);
116extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); 120extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
@@ -143,8 +147,8 @@ static inline void detect_ht(struct cpuinfo_x86 *c) {}
143#define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */ 147#define X86_EFLAGS_VIP 0x00100000 /* Virtual Interrupt Pending */
144#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */ 148#define X86_EFLAGS_ID 0x00200000 /* CPUID detection flag */
145 149
146static inline void __cpuid(unsigned int *eax, unsigned int *ebx, 150static inline fastcall void native_cpuid(unsigned int *eax, unsigned int *ebx,
147 unsigned int *ecx, unsigned int *edx) 151 unsigned int *ecx, unsigned int *edx)
148{ 152{
149 /* ecx is often an input as well as an output. */ 153 /* ecx is often an input as well as an output. */
150 __asm__("cpuid" 154 __asm__("cpuid"
@@ -155,59 +159,6 @@ static inline void __cpuid(unsigned int *eax, unsigned int *ebx,
155 : "0" (*eax), "2" (*ecx)); 159 : "0" (*eax), "2" (*ecx));
156} 160}
157 161
158/*
159 * Generic CPUID function
160 * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
161 * resulting in stale register contents being returned.
162 */
163static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
164{
165 *eax = op;
166 *ecx = 0;
167 __cpuid(eax, ebx, ecx, edx);
168}
169
170/* Some CPUID calls want 'count' to be placed in ecx */
171static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
172 int *edx)
173{
174 *eax = op;
175 *ecx = count;
176 __cpuid(eax, ebx, ecx, edx);
177}
178
179/*
180 * CPUID functions returning a single datum
181 */
182static inline unsigned int cpuid_eax(unsigned int op)
183{
184 unsigned int eax, ebx, ecx, edx;
185
186 cpuid(op, &eax, &ebx, &ecx, &edx);
187 return eax;
188}
189static inline unsigned int cpuid_ebx(unsigned int op)
190{
191 unsigned int eax, ebx, ecx, edx;
192
193 cpuid(op, &eax, &ebx, &ecx, &edx);
194 return ebx;
195}
196static inline unsigned int cpuid_ecx(unsigned int op)
197{
198 unsigned int eax, ebx, ecx, edx;
199
200 cpuid(op, &eax, &ebx, &ecx, &edx);
201 return ecx;
202}
203static inline unsigned int cpuid_edx(unsigned int op)
204{
205 unsigned int eax, ebx, ecx, edx;
206
207 cpuid(op, &eax, &ebx, &ecx, &edx);
208 return edx;
209}
210
211#define load_cr3(pgdir) write_cr3(__pa(pgdir)) 162#define load_cr3(pgdir) write_cr3(__pa(pgdir))
212 163
213/* 164/*
@@ -473,6 +424,7 @@ struct thread_struct {
473 .vm86_info = NULL, \ 424 .vm86_info = NULL, \
474 .sysenter_cs = __KERNEL_CS, \ 425 .sysenter_cs = __KERNEL_CS, \
475 .io_bitmap_ptr = NULL, \ 426 .io_bitmap_ptr = NULL, \
427 .gs = __KERNEL_PDA, \
476} 428}
477 429
478/* 430/*
@@ -489,18 +441,9 @@ struct thread_struct {
489 .io_bitmap = { [ 0 ... IO_BITMAP_LONGS] = ~0 }, \ 441 .io_bitmap = { [ 0 ... IO_BITMAP_LONGS] = ~0 }, \
490} 442}
491 443
492static inline void load_esp0(struct tss_struct *tss, struct thread_struct *thread)
493{
494 tss->esp0 = thread->esp0;
495 /* This can only happen when SEP is enabled, no need to test "SEP"arately */
496 if (unlikely(tss->ss1 != thread->sysenter_cs)) {
497 tss->ss1 = thread->sysenter_cs;
498 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
499 }
500}
501
502#define start_thread(regs, new_eip, new_esp) do { \ 444#define start_thread(regs, new_eip, new_esp) do { \
503 __asm__("movl %0,%%fs ; movl %0,%%gs": :"r" (0)); \ 445 __asm__("movl %0,%%fs": :"r" (0)); \
446 regs->xgs = 0; \
504 set_fs(USER_DS); \ 447 set_fs(USER_DS); \
505 regs->xds = __USER_DS; \ 448 regs->xds = __USER_DS; \
506 regs->xes = __USER_DS; \ 449 regs->xes = __USER_DS; \
@@ -510,33 +453,6 @@ static inline void load_esp0(struct tss_struct *tss, struct thread_struct *threa
510 regs->esp = new_esp; \ 453 regs->esp = new_esp; \
511} while (0) 454} while (0)
512 455
513/*
514 * These special macros can be used to get or set a debugging register
515 */
516#define get_debugreg(var, register) \
517 __asm__("movl %%db" #register ", %0" \
518 :"=r" (var))
519#define set_debugreg(value, register) \
520 __asm__("movl %0,%%db" #register \
521 : /* no output */ \
522 :"r" (value))
523
524/*
525 * Set IOPL bits in EFLAGS from given mask
526 */
527static inline void set_iopl_mask(unsigned mask)
528{
529 unsigned int reg;
530 __asm__ __volatile__ ("pushfl;"
531 "popl %0;"
532 "andl %1, %0;"
533 "orl %2, %0;"
534 "pushl %0;"
535 "popfl"
536 : "=&r" (reg)
537 : "i" (~X86_EFLAGS_IOPL), "r" (mask));
538}
539
540/* Forward declaration, a strange C thing */ 456/* Forward declaration, a strange C thing */
541struct task_struct; 457struct task_struct;
542struct mm_struct; 458struct mm_struct;
@@ -628,6 +544,105 @@ static inline void rep_nop(void)
628 544
629#define cpu_relax() rep_nop() 545#define cpu_relax() rep_nop()
630 546
547#ifdef CONFIG_PARAVIRT
548#include <asm/paravirt.h>
549#else
550#define paravirt_enabled() 0
551#define __cpuid native_cpuid
552
553static inline void load_esp0(struct tss_struct *tss, struct thread_struct *thread)
554{
555 tss->esp0 = thread->esp0;
556 /* This can only happen when SEP is enabled, no need to test "SEP"arately */
557 if (unlikely(tss->ss1 != thread->sysenter_cs)) {
558 tss->ss1 = thread->sysenter_cs;
559 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
560 }
561}
562
563/*
564 * These special macros can be used to get or set a debugging register
565 */
566#define get_debugreg(var, register) \
567 __asm__("movl %%db" #register ", %0" \
568 :"=r" (var))
569#define set_debugreg(value, register) \
570 __asm__("movl %0,%%db" #register \
571 : /* no output */ \
572 :"r" (value))
573
574#define set_iopl_mask native_set_iopl_mask
575#endif /* CONFIG_PARAVIRT */
576
577/*
578 * Set IOPL bits in EFLAGS from given mask
579 */
580static fastcall inline void native_set_iopl_mask(unsigned mask)
581{
582 unsigned int reg;
583 __asm__ __volatile__ ("pushfl;"
584 "popl %0;"
585 "andl %1, %0;"
586 "orl %2, %0;"
587 "pushl %0;"
588 "popfl"
589 : "=&r" (reg)
590 : "i" (~X86_EFLAGS_IOPL), "r" (mask));
591}
592
593/*
594 * Generic CPUID function
595 * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
596 * resulting in stale register contents being returned.
597 */
598static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx)
599{
600 *eax = op;
601 *ecx = 0;
602 __cpuid(eax, ebx, ecx, edx);
603}
604
605/* Some CPUID calls want 'count' to be placed in ecx */
606static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
607 int *edx)
608{
609 *eax = op;
610 *ecx = count;
611 __cpuid(eax, ebx, ecx, edx);
612}
613
614/*
615 * CPUID functions returning a single datum
616 */
617static inline unsigned int cpuid_eax(unsigned int op)
618{
619 unsigned int eax, ebx, ecx, edx;
620
621 cpuid(op, &eax, &ebx, &ecx, &edx);
622 return eax;
623}
624static inline unsigned int cpuid_ebx(unsigned int op)
625{
626 unsigned int eax, ebx, ecx, edx;
627
628 cpuid(op, &eax, &ebx, &ecx, &edx);
629 return ebx;
630}
631static inline unsigned int cpuid_ecx(unsigned int op)
632{
633 unsigned int eax, ebx, ecx, edx;
634
635 cpuid(op, &eax, &ebx, &ecx, &edx);
636 return ecx;
637}
638static inline unsigned int cpuid_edx(unsigned int op)
639{
640 unsigned int eax, ebx, ecx, edx;
641
642 cpuid(op, &eax, &ebx, &ecx, &edx);
643 return edx;
644}
645
631/* generic versions from gas */ 646/* generic versions from gas */
632#define GENERIC_NOP1 ".byte 0x90\n" 647#define GENERIC_NOP1 ".byte 0x90\n"
633#define GENERIC_NOP2 ".byte 0x89,0xf6\n" 648#define GENERIC_NOP2 ".byte 0x89,0xf6\n"
@@ -727,4 +742,7 @@ extern unsigned long boot_option_idle_override;
727extern void enable_sep_cpu(void); 742extern void enable_sep_cpu(void);
728extern int sysenter_setup(void); 743extern int sysenter_setup(void);
729 744
745extern int init_gdt(int cpu, struct task_struct *idle);
746extern void secondary_cpu_init(void);
747
730#endif /* __ASM_I386_PROCESSOR_H */ 748#endif /* __ASM_I386_PROCESSOR_H */
diff --git a/include/asm-i386/ptrace.h b/include/asm-i386/ptrace.h
index d505f501077a..bdbc894339b4 100644
--- a/include/asm-i386/ptrace.h
+++ b/include/asm-i386/ptrace.h
@@ -16,6 +16,8 @@ struct pt_regs {
16 long eax; 16 long eax;
17 int xds; 17 int xds;
18 int xes; 18 int xes;
19 /* int xfs; */
20 int xgs;
19 long orig_eax; 21 long orig_eax;
20 long eip; 22 long eip;
21 int xcs; 23 int xcs;
diff --git a/include/asm-i386/rwsem.h b/include/asm-i386/rwsem.h
index bc598d6388e3..041906f3c6df 100644
--- a/include/asm-i386/rwsem.h
+++ b/include/asm-i386/rwsem.h
@@ -75,8 +75,8 @@ struct rw_semaphore {
75 75
76 76
77#define __RWSEM_INITIALIZER(name) \ 77#define __RWSEM_INITIALIZER(name) \
78{ RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) \ 78{ RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait_lock), \
79 __RWSEM_DEP_MAP_INIT(name) } 79 LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) }
80 80
81#define DECLARE_RWSEM(name) \ 81#define DECLARE_RWSEM(name) \
82 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 82 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
diff --git a/include/asm-i386/segment.h b/include/asm-i386/segment.h
index b7ab59685ba7..3c796af33776 100644
--- a/include/asm-i386/segment.h
+++ b/include/asm-i386/segment.h
@@ -39,7 +39,7 @@
39 * 25 - APM BIOS support 39 * 25 - APM BIOS support
40 * 40 *
41 * 26 - ESPFIX small SS 41 * 26 - ESPFIX small SS
42 * 27 - unused 42 * 27 - PDA [ per-cpu private data area ]
43 * 28 - unused 43 * 28 - unused
44 * 29 - unused 44 * 29 - unused
45 * 30 - unused 45 * 30 - unused
@@ -74,6 +74,9 @@
74#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14) 74#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)
75#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8) 75#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
76 76
77#define GDT_ENTRY_PDA (GDT_ENTRY_KERNEL_BASE + 15)
78#define __KERNEL_PDA (GDT_ENTRY_PDA * 8)
79
77#define GDT_ENTRY_DOUBLEFAULT_TSS 31 80#define GDT_ENTRY_DOUBLEFAULT_TSS 31
78 81
79/* 82/*
@@ -128,5 +131,7 @@
128#define SEGMENT_LDT 0x4 131#define SEGMENT_LDT 0x4
129#define SEGMENT_GDT 0x0 132#define SEGMENT_GDT 0x0
130 133
134#ifndef CONFIG_PARAVIRT
131#define get_kernel_rpl() 0 135#define get_kernel_rpl() 0
132#endif 136#endif
137#endif
diff --git a/include/asm-i386/setup.h b/include/asm-i386/setup.h
index 2734909eff84..67659dbaf120 100644
--- a/include/asm-i386/setup.h
+++ b/include/asm-i386/setup.h
@@ -6,6 +6,8 @@
6#ifndef _i386_SETUP_H 6#ifndef _i386_SETUP_H
7#define _i386_SETUP_H 7#define _i386_SETUP_H
8 8
9#define COMMAND_LINE_SIZE 256
10
9#ifdef __KERNEL__ 11#ifdef __KERNEL__
10#include <linux/pfn.h> 12#include <linux/pfn.h>
11 13
@@ -14,10 +16,8 @@
14 */ 16 */
15#define MAXMEM_PFN PFN_DOWN(MAXMEM) 17#define MAXMEM_PFN PFN_DOWN(MAXMEM)
16#define MAX_NONPAE_PFN (1 << 20) 18#define MAX_NONPAE_PFN (1 << 20)
17#endif
18 19
19#define PARAM_SIZE 4096 20#define PARAM_SIZE 4096
20#define COMMAND_LINE_SIZE 256
21 21
22#define OLD_CL_MAGIC_ADDR 0x90020 22#define OLD_CL_MAGIC_ADDR 0x90020
23#define OLD_CL_MAGIC 0xA33F 23#define OLD_CL_MAGIC 0xA33F
@@ -70,6 +70,7 @@ extern unsigned char boot_params[PARAM_SIZE];
70struct e820entry; 70struct e820entry;
71 71
72char * __init machine_specific_memory_setup(void); 72char * __init machine_specific_memory_setup(void);
73char *memory_setup(void);
73 74
74int __init copy_e820_map(struct e820entry * biosmap, int nr_map); 75int __init copy_e820_map(struct e820entry * biosmap, int nr_map);
75int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map); 76int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map);
@@ -78,4 +79,6 @@ void __init add_memory_region(unsigned long long start,
78 79
79#endif /* __ASSEMBLY__ */ 80#endif /* __ASSEMBLY__ */
80 81
82#endif /* __KERNEL__ */
83
81#endif /* _i386_SETUP_H */ 84#endif /* _i386_SETUP_H */
diff --git a/include/asm-i386/smp.h b/include/asm-i386/smp.h
index bd59c1508e71..64fe624c02ca 100644
--- a/include/asm-i386/smp.h
+++ b/include/asm-i386/smp.h
@@ -8,6 +8,7 @@
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <linux/threads.h> 9#include <linux/threads.h>
10#include <linux/cpumask.h> 10#include <linux/cpumask.h>
11#include <asm/pda.h>
11#endif 12#endif
12 13
13#ifdef CONFIG_X86_LOCAL_APIC 14#ifdef CONFIG_X86_LOCAL_APIC
@@ -56,7 +57,7 @@ extern void cpu_uninit(void);
56 * from the initial startup. We map APIC_BASE very early in page_setup(), 57 * from the initial startup. We map APIC_BASE very early in page_setup(),
57 * so this is correct in the x86 case. 58 * so this is correct in the x86 case.
58 */ 59 */
59#define raw_smp_processor_id() (current_thread_info()->cpu) 60#define raw_smp_processor_id() (read_pda(cpu_number))
60 61
61extern cpumask_t cpu_callout_map; 62extern cpumask_t cpu_callout_map;
62extern cpumask_t cpu_callin_map; 63extern cpumask_t cpu_callin_map;
diff --git a/include/asm-i386/spinlock.h b/include/asm-i386/spinlock.h
index c18b71fae6b3..d3bcebed60ca 100644
--- a/include/asm-i386/spinlock.h
+++ b/include/asm-i386/spinlock.h
@@ -7,8 +7,14 @@
7#include <asm/processor.h> 7#include <asm/processor.h>
8#include <linux/compiler.h> 8#include <linux/compiler.h>
9 9
10#ifdef CONFIG_PARAVIRT
11#include <asm/paravirt.h>
12#else
10#define CLI_STRING "cli" 13#define CLI_STRING "cli"
11#define STI_STRING "sti" 14#define STI_STRING "sti"
15#define CLI_STI_CLOBBERS
16#define CLI_STI_INPUT_ARGS
17#endif /* CONFIG_PARAVIRT */
12 18
13/* 19/*
14 * Your basic SMP spinlocks, allowing only a single CPU anywhere 20 * Your basic SMP spinlocks, allowing only a single CPU anywhere
@@ -53,25 +59,28 @@ static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long fla
53{ 59{
54 asm volatile( 60 asm volatile(
55 "\n1:\t" 61 "\n1:\t"
56 LOCK_PREFIX " ; decb %0\n\t" 62 LOCK_PREFIX " ; decb %[slock]\n\t"
57 "jns 5f\n" 63 "jns 5f\n"
58 "2:\t" 64 "2:\t"
59 "testl $0x200, %1\n\t" 65 "testl $0x200, %[flags]\n\t"
60 "jz 4f\n\t" 66 "jz 4f\n\t"
61 STI_STRING "\n" 67 STI_STRING "\n"
62 "3:\t" 68 "3:\t"
63 "rep;nop\n\t" 69 "rep;nop\n\t"
64 "cmpb $0, %0\n\t" 70 "cmpb $0, %[slock]\n\t"
65 "jle 3b\n\t" 71 "jle 3b\n\t"
66 CLI_STRING "\n\t" 72 CLI_STRING "\n\t"
67 "jmp 1b\n" 73 "jmp 1b\n"
68 "4:\t" 74 "4:\t"
69 "rep;nop\n\t" 75 "rep;nop\n\t"
70 "cmpb $0, %0\n\t" 76 "cmpb $0, %[slock]\n\t"
71 "jg 1b\n\t" 77 "jg 1b\n\t"
72 "jmp 4b\n" 78 "jmp 4b\n"
73 "5:\n\t" 79 "5:\n\t"
74 : "+m" (lock->slock) : "r" (flags) : "memory"); 80 : [slock] "+m" (lock->slock)
81 : [flags] "r" (flags)
82 CLI_STI_INPUT_ARGS
83 : "memory" CLI_STI_CLOBBERS);
75} 84}
76#endif 85#endif
77 86
diff --git a/include/asm-i386/suspend.h b/include/asm-i386/suspend.h
index 08be1e5009d4..8dbaafe611ff 100644
--- a/include/asm-i386/suspend.h
+++ b/include/asm-i386/suspend.h
@@ -6,29 +6,14 @@
6#include <asm/desc.h> 6#include <asm/desc.h>
7#include <asm/i387.h> 7#include <asm/i387.h>
8 8
9static inline int 9static inline int arch_prepare_suspend(void) { return 0; }
10arch_prepare_suspend(void)
11{
12 /* If you want to make non-PSE machine work, turn off paging
13 in swsusp_arch_suspend. swsusp_pg_dir should have identity mapping, so
14 it could work... */
15 if (!cpu_has_pse) {
16 printk(KERN_ERR "PSE is required for swsusp.\n");
17 return -EPERM;
18 }
19 return 0;
20}
21 10
22/* image of the saved processor state */ 11/* image of the saved processor state */
23struct saved_context { 12struct saved_context {
24 u16 es, fs, gs, ss; 13 u16 es, fs, gs, ss;
25 unsigned long cr0, cr2, cr3, cr4; 14 unsigned long cr0, cr2, cr3, cr4;
26 u16 gdt_pad; 15 struct Xgt_desc_struct gdt;
27 u16 gdt_limit; 16 struct Xgt_desc_struct idt;
28 unsigned long gdt_base;
29 u16 idt_pad;
30 u16 idt_limit;
31 unsigned long idt_base;
32 u16 ldt; 17 u16 ldt;
33 u16 tss; 18 u16 tss;
34 unsigned long tr; 19 unsigned long tr;
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h
index a6dabbcd6e6a..a6d20d9a1a30 100644
--- a/include/asm-i386/system.h
+++ b/include/asm-i386/system.h
@@ -88,6 +88,9 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t" \
88#define savesegment(seg, value) \ 88#define savesegment(seg, value) \
89 asm volatile("mov %%" #seg ",%0":"=rm" (value)) 89 asm volatile("mov %%" #seg ",%0":"=rm" (value))
90 90
91#ifdef CONFIG_PARAVIRT
92#include <asm/paravirt.h>
93#else
91#define read_cr0() ({ \ 94#define read_cr0() ({ \
92 unsigned int __dummy; \ 95 unsigned int __dummy; \
93 __asm__ __volatile__( \ 96 __asm__ __volatile__( \
@@ -139,17 +142,18 @@ __asm__ __volatile__ ("movw %%dx,%1\n\t" \
139#define write_cr4(x) \ 142#define write_cr4(x) \
140 __asm__ __volatile__("movl %0,%%cr4": :"r" (x)) 143 __asm__ __volatile__("movl %0,%%cr4": :"r" (x))
141 144
142/* 145#define wbinvd() \
143 * Clear and set 'TS' bit respectively 146 __asm__ __volatile__ ("wbinvd": : :"memory")
144 */ 147
148/* Clear the 'TS' bit */
145#define clts() __asm__ __volatile__ ("clts") 149#define clts() __asm__ __volatile__ ("clts")
150#endif/* CONFIG_PARAVIRT */
151
152/* Set the 'TS' bit */
146#define stts() write_cr0(8 | read_cr0()) 153#define stts() write_cr0(8 | read_cr0())
147 154
148#endif /* __KERNEL__ */ 155#endif /* __KERNEL__ */
149 156
150#define wbinvd() \
151 __asm__ __volatile__ ("wbinvd": : :"memory")
152
153static inline unsigned long get_limit(unsigned long segment) 157static inline unsigned long get_limit(unsigned long segment)
154{ 158{
155 unsigned long __limit; 159 unsigned long __limit;
diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h
index 54d6d7aea938..46d32ad92082 100644
--- a/include/asm-i386/thread_info.h
+++ b/include/asm-i386/thread_info.h
@@ -95,15 +95,7 @@ static inline struct thread_info *current_thread_info(void)
95 95
96/* thread information allocation */ 96/* thread information allocation */
97#ifdef CONFIG_DEBUG_STACK_USAGE 97#ifdef CONFIG_DEBUG_STACK_USAGE
98#define alloc_thread_info(tsk) \ 98#define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL)
99 ({ \
100 struct thread_info *ret; \
101 \
102 ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \
103 if (ret) \
104 memset(ret, 0, THREAD_SIZE); \
105 ret; \
106 })
107#else 99#else
108#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL) 100#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
109#endif 101#endif
diff --git a/include/asm-i386/time.h b/include/asm-i386/time.h
new file mode 100644
index 000000000000..ea8065af825a
--- /dev/null
+++ b/include/asm-i386/time.h
@@ -0,0 +1,41 @@
1#ifndef _ASMi386_TIME_H
2#define _ASMi386_TIME_H
3
4#include <linux/efi.h>
5#include "mach_time.h"
6
7static inline unsigned long native_get_wallclock(void)
8{
9 unsigned long retval;
10
11 if (efi_enabled)
12 retval = efi_get_time();
13 else
14 retval = mach_get_cmos_time();
15
16 return retval;
17}
18
19static inline int native_set_wallclock(unsigned long nowtime)
20{
21 int retval;
22
23 if (efi_enabled)
24 retval = efi_set_rtc_mmss(nowtime);
25 else
26 retval = mach_set_rtc_mmss(nowtime);
27
28 return retval;
29}
30
31#ifdef CONFIG_PARAVIRT
32#include <asm/paravirt.h>
33#else /* !CONFIG_PARAVIRT */
34
35#define get_wallclock() native_get_wallclock()
36#define set_wallclock(x) native_set_wallclock(x)
37#define do_time_init() time_init_hook()
38
39#endif /* CONFIG_PARAVIRT */
40
41#endif
diff --git a/include/asm-i386/tlbflush.h b/include/asm-i386/tlbflush.h
index 360648b0f2b3..4dd82840d53b 100644
--- a/include/asm-i386/tlbflush.h
+++ b/include/asm-i386/tlbflush.h
@@ -4,7 +4,15 @@
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <asm/processor.h> 5#include <asm/processor.h>
6 6
7#define __flush_tlb() \ 7#ifdef CONFIG_PARAVIRT
8#include <asm/paravirt.h>
9#else
10#define __flush_tlb() __native_flush_tlb()
11#define __flush_tlb_global() __native_flush_tlb_global()
12#define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
13#endif
14
15#define __native_flush_tlb() \
8 do { \ 16 do { \
9 unsigned int tmpreg; \ 17 unsigned int tmpreg; \
10 \ 18 \
@@ -19,7 +27,7 @@
19 * Global pages have to be flushed a bit differently. Not a real 27 * Global pages have to be flushed a bit differently. Not a real
20 * performance problem because this does not happen often. 28 * performance problem because this does not happen often.
21 */ 29 */
22#define __flush_tlb_global() \ 30#define __native_flush_tlb_global() \
23 do { \ 31 do { \
24 unsigned int tmpreg, cr4, cr4_orig; \ 32 unsigned int tmpreg, cr4, cr4_orig; \
25 \ 33 \
@@ -36,6 +44,9 @@
36 : "memory"); \ 44 : "memory"); \
37 } while (0) 45 } while (0)
38 46
47#define __native_flush_tlb_single(addr) \
48 __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory")
49
39# define __flush_tlb_all() \ 50# define __flush_tlb_all() \
40 do { \ 51 do { \
41 if (cpu_has_pge) \ 52 if (cpu_has_pge) \
@@ -46,9 +57,6 @@
46 57
47#define cpu_has_invlpg (boot_cpu_data.x86 > 3) 58#define cpu_has_invlpg (boot_cpu_data.x86 > 3)
48 59
49#define __flush_tlb_single(addr) \
50 __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory")
51
52#ifdef CONFIG_X86_INVLPG 60#ifdef CONFIG_X86_INVLPG
53# define __flush_tlb_one(addr) __flush_tlb_single(addr) 61# define __flush_tlb_one(addr) __flush_tlb_single(addr)
54#else 62#else
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index beeeaf6b054a..833fa1704ff9 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -329,104 +329,6 @@
329#ifdef __KERNEL__ 329#ifdef __KERNEL__
330 330
331#define NR_syscalls 320 331#define NR_syscalls 320
332#include <linux/err.h>
333
334/*
335 * user-visible error numbers are in the range -1 - -MAX_ERRNO: see
336 * <asm-i386/errno.h>
337 */
338#define __syscall_return(type, res) \
339do { \
340 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
341 errno = -(res); \
342 res = -1; \
343 } \
344 return (type) (res); \
345} while (0)
346
347/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
348#define _syscall0(type,name) \
349type name(void) \
350{ \
351long __res; \
352__asm__ volatile ("int $0x80" \
353 : "=a" (__res) \
354 : "0" (__NR_##name)); \
355__syscall_return(type,__res); \
356}
357
358#define _syscall1(type,name,type1,arg1) \
359type name(type1 arg1) \
360{ \
361long __res; \
362__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
363 : "=a" (__res) \
364 : "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \
365__syscall_return(type,__res); \
366}
367
368#define _syscall2(type,name,type1,arg1,type2,arg2) \
369type name(type1 arg1,type2 arg2) \
370{ \
371long __res; \
372__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
373 : "=a" (__res) \
374 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
375 : "memory"); \
376__syscall_return(type,__res); \
377}
378
379#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
380type name(type1 arg1,type2 arg2,type3 arg3) \
381{ \
382long __res; \
383__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
384 : "=a" (__res) \
385 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
386 "d" ((long)(arg3)) : "memory"); \
387__syscall_return(type,__res); \
388}
389
390#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
391type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
392{ \
393long __res; \
394__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
395 : "=a" (__res) \
396 : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
397 "d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \
398__syscall_return(type,__res); \
399}
400
401#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
402 type5,arg5) \
403type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
404{ \
405long __res; \
406__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; movl %1,%%eax ; " \
407 "int $0x80 ; pop %%ebx" \
408 : "=a" (__res) \
409 : "i" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
410 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
411 : "memory"); \
412__syscall_return(type,__res); \
413}
414
415#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
416 type5,arg5,type6,arg6) \
417type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
418{ \
419long __res; \
420 struct { long __a1; long __a6; } __s = { (long)arg1, (long)arg6 }; \
421__asm__ volatile ("push %%ebp ; push %%ebx ; movl 4(%2),%%ebp ; " \
422 "movl 0(%2),%%ebx ; movl %1,%%eax ; int $0x80 ; " \
423 "pop %%ebx ; pop %%ebp" \
424 : "=a" (__res) \
425 : "i" (__NR_##name),"0" ((long)(&__s)),"c" ((long)(arg2)), \
426 "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
427 : "memory"); \
428__syscall_return(type,__res); \
429}
430 332
431#define __ARCH_WANT_IPC_PARSE_VERSION 333#define __ARCH_WANT_IPC_PARSE_VERSION
432#define __ARCH_WANT_OLD_READDIR 334#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-i386/unwind.h b/include/asm-i386/unwind.h
index 5031d693b89d..aa2c931e30db 100644
--- a/include/asm-i386/unwind.h
+++ b/include/asm-i386/unwind.h
@@ -71,6 +71,7 @@ static inline void arch_unw_init_blocked(struct unwind_frame_info *info)
71 info->regs.xss = __KERNEL_DS; 71 info->regs.xss = __KERNEL_DS;
72 info->regs.xds = __USER_DS; 72 info->regs.xds = __USER_DS;
73 info->regs.xes = __USER_DS; 73 info->regs.xes = __USER_DS;
74 info->regs.xgs = __KERNEL_PDA;
74} 75}
75 76
76extern asmlinkage int arch_unwind_init_running(struct unwind_frame_info *, 77extern asmlinkage int arch_unwind_init_running(struct unwind_frame_info *,
@@ -78,17 +79,13 @@ extern asmlinkage int arch_unwind_init_running(struct unwind_frame_info *,
78 void *arg), 79 void *arg),
79 void *arg); 80 void *arg);
80 81
81static inline int arch_unw_user_mode(const struct unwind_frame_info *info) 82static inline int arch_unw_user_mode(/*const*/ struct unwind_frame_info *info)
82{ 83{
83#if 0 /* This can only work when selector register and EFLAGS saves/restores 84 return user_mode_vm(&info->regs)
84 are properly annotated (and tracked in UNW_REGISTER_INFO). */ 85 || info->regs.eip < PAGE_OFFSET
85 return user_mode_vm(&info->regs);
86#else
87 return info->regs.eip < PAGE_OFFSET
88 || (info->regs.eip >= __fix_to_virt(FIX_VDSO) 86 || (info->regs.eip >= __fix_to_virt(FIX_VDSO)
89 && info->regs.eip < __fix_to_virt(FIX_VDSO) + PAGE_SIZE) 87 && info->regs.eip < __fix_to_virt(FIX_VDSO) + PAGE_SIZE)
90 || info->regs.esp < PAGE_OFFSET; 88 || info->regs.esp < PAGE_OFFSET;
91#endif
92} 89}
93 90
94#else 91#else
diff --git a/include/asm-i386/vm86.h b/include/asm-i386/vm86.h
index 952fd6957380..a5edf517b992 100644
--- a/include/asm-i386/vm86.h
+++ b/include/asm-i386/vm86.h
@@ -145,26 +145,13 @@ struct vm86plus_struct {
145 * at the end of the structure. Look at ptrace.h to see the "normal" 145 * at the end of the structure. Look at ptrace.h to see the "normal"
146 * setup. For user space layout see 'struct vm86_regs' above. 146 * setup. For user space layout see 'struct vm86_regs' above.
147 */ 147 */
148#include <asm/ptrace.h>
148 149
149struct kernel_vm86_regs { 150struct kernel_vm86_regs {
150/* 151/*
151 * normal regs, with special meaning for the segment descriptors.. 152 * normal regs, with special meaning for the segment descriptors..
152 */ 153 */
153 long ebx; 154 struct pt_regs pt;
154 long ecx;
155 long edx;
156 long esi;
157 long edi;
158 long ebp;
159 long eax;
160 long __null_ds;
161 long __null_es;
162 long orig_eax;
163 long eip;
164 unsigned short cs, __csh;
165 long eflags;
166 long esp;
167 unsigned short ss, __ssh;
168/* 155/*
169 * these are specific to v86 mode: 156 * these are specific to v86 mode:
170 */ 157 */
diff --git a/include/asm-ia64/Kbuild b/include/asm-ia64/Kbuild
index 15818a18bc52..4a1e48b9f403 100644
--- a/include/asm-ia64/Kbuild
+++ b/include/asm-ia64/Kbuild
@@ -10,7 +10,6 @@ header-y += intrinsics.h
10header-y += perfmon_default_smpl.h 10header-y += perfmon_default_smpl.h
11header-y += ptrace_offsets.h 11header-y += ptrace_offsets.h
12header-y += rse.h 12header-y += rse.h
13header-y += setup.h
14header-y += ucontext.h 13header-y += ucontext.h
15 14
16unifdef-y += perfmon.h 15unifdef-y += perfmon.h
diff --git a/include/asm-ia64/dma-mapping.h b/include/asm-ia64/dma-mapping.h
index 99a8f8e1218c..ebd5887f4b1a 100644
--- a/include/asm-ia64/dma-mapping.h
+++ b/include/asm-ia64/dma-mapping.h
@@ -50,7 +50,8 @@ dma_set_mask (struct device *dev, u64 mask)
50extern int dma_get_cache_alignment(void); 50extern int dma_get_cache_alignment(void);
51 51
52static inline void 52static inline void
53dma_cache_sync (void *vaddr, size_t size, enum dma_data_direction dir) 53dma_cache_sync (struct device *dev, void *vaddr, size_t size,
54 enum dma_data_direction dir)
54{ 55{
55 /* 56 /*
56 * IA-64 is cache-coherent, so this is mostly a no-op. However, we do need to 57 * IA-64 is cache-coherent, so this is mostly a no-op. However, we do need to
@@ -59,6 +60,6 @@ dma_cache_sync (void *vaddr, size_t size, enum dma_data_direction dir)
59 mb(); 60 mb();
60} 61}
61 62
62#define dma_is_consistent(dma_handle) (1) /* all we do is coherent memory... */ 63#define dma_is_consistent(d, h) (1) /* all we do is coherent memory... */
63 64
64#endif /* _ASM_IA64_DMA_MAPPING_H */ 65#endif /* _ASM_IA64_DMA_MAPPING_H */
diff --git a/include/asm-ia64/futex.h b/include/asm-ia64/futex.h
index 07d77f3a8cbe..8a98a2654139 100644
--- a/include/asm-ia64/futex.h
+++ b/include/asm-ia64/futex.h
@@ -59,7 +59,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
59 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 59 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
60 return -EFAULT; 60 return -EFAULT;
61 61
62 inc_preempt_count(); 62 pagefault_disable();
63 63
64 switch (op) { 64 switch (op) {
65 case FUTEX_OP_SET: 65 case FUTEX_OP_SET:
@@ -83,7 +83,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
83 ret = -ENOSYS; 83 ret = -ENOSYS;
84 } 84 }
85 85
86 dec_preempt_count(); 86 pagefault_enable();
87 87
88 if (!ret) { 88 if (!ret) {
89 switch (cmp) { 89 switch (cmp) {
diff --git a/include/asm-ia64/pgalloc.h b/include/asm-ia64/pgalloc.h
index 9cb68e9b377e..393e04c42a2c 100644
--- a/include/asm-ia64/pgalloc.h
+++ b/include/asm-ia64/pgalloc.h
@@ -60,7 +60,7 @@ static inline void *pgtable_quicklist_alloc(void)
60static inline void pgtable_quicklist_free(void *pgtable_entry) 60static inline void pgtable_quicklist_free(void *pgtable_entry)
61{ 61{
62#ifdef CONFIG_NUMA 62#ifdef CONFIG_NUMA
63 unsigned long nid = page_to_nid(virt_to_page(pgtable_entry)); 63 int nid = page_to_nid(virt_to_page(pgtable_entry));
64 64
65 if (unlikely(nid != numa_node_id())) { 65 if (unlikely(nid != numa_node_id())) {
66 free_page((unsigned long)pgtable_entry); 66 free_page((unsigned long)pgtable_entry);
diff --git a/include/asm-m32r/setup.h b/include/asm-m32r/setup.h
index 52f4fa29abfc..6a0b32202d4e 100644
--- a/include/asm-m32r/setup.h
+++ b/include/asm-m32r/setup.h
@@ -1,6 +1,11 @@
1/* 1/*
2 * This is set up by the setup-routine at boot-time 2 * This is set up by the setup-routine at boot-time
3 */ 3 */
4
5#define COMMAND_LINE_SIZE 512
6
7#ifdef __KERNEL__
8
4#define PARAM ((unsigned char *)empty_zero_page) 9#define PARAM ((unsigned char *)empty_zero_page)
5 10
6#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000)) 11#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
@@ -18,8 +23,6 @@
18 23
19#define SCREEN_INFO (*(struct screen_info *) (PARAM+0x200)) 24#define SCREEN_INFO (*(struct screen_info *) (PARAM+0x200))
20 25
21#define COMMAND_LINE_SIZE (512)
22
23#define RAMDISK_IMAGE_START_MASK (0x07FF) 26#define RAMDISK_IMAGE_START_MASK (0x07FF)
24#define RAMDISK_PROMPT_FLAG (0x8000) 27#define RAMDISK_PROMPT_FLAG (0x8000)
25#define RAMDISK_LOAD_FLAG (0x4000) 28#define RAMDISK_LOAD_FLAG (0x4000)
@@ -27,3 +30,5 @@
27extern unsigned long memory_start; 30extern unsigned long memory_start;
28extern unsigned long memory_end; 31extern unsigned long memory_end;
29 32
33#endif /* __KERNEL__ */
34
diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h
index 95aa34298d82..5b66bd3c6ed6 100644
--- a/include/asm-m32r/unistd.h
+++ b/include/asm-m32r/unistd.h
@@ -296,117 +296,6 @@
296#ifdef __KERNEL__ 296#ifdef __KERNEL__
297 297
298#define NR_syscalls 285 298#define NR_syscalls 285
299#include <linux/err.h>
300
301/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
302 * <asm-m32r/errno.h>
303 */
304
305#include <asm/syscall.h> /* SYSCALL_* */
306
307#define __syscall_return(type, res) \
308do { \
309 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
310 /* Avoid using "res" which is declared to be in register r0; \
311 errno might expand to a function call and clobber it. */ \
312 int __err = -(res); \
313 errno = __err; \
314 res = -1; \
315 } \
316 return (type) (res); \
317} while (0)
318
319#define _syscall0(type,name) \
320type name(void) \
321{ \
322register long __scno __asm__ ("r7") = __NR_##name; \
323register long __res __asm__("r0"); \
324__asm__ __volatile__ (\
325 "trap #" SYSCALL_VECTOR "|| nop"\
326 : "=r" (__res) \
327 : "r" (__scno) \
328 : "memory"); \
329__syscall_return(type,__res); \
330}
331
332#define _syscall1(type,name,type1,arg1) \
333type name(type1 arg1) \
334{ \
335register long __scno __asm__ ("r7") = __NR_##name; \
336register long __res __asm__ ("r0") = (long)(arg1); \
337__asm__ __volatile__ (\
338 "trap #" SYSCALL_VECTOR "|| nop"\
339 : "=r" (__res) \
340 : "r" (__scno), "0" (__res) \
341 : "memory"); \
342__syscall_return(type,__res); \
343}
344
345#define _syscall2(type,name,type1,arg1,type2,arg2) \
346type name(type1 arg1,type2 arg2) \
347{ \
348register long __scno __asm__ ("r7") = __NR_##name; \
349register long __arg2 __asm__ ("r1") = (long)(arg2); \
350register long __res __asm__ ("r0") = (long)(arg1); \
351__asm__ __volatile__ (\
352 "trap #" SYSCALL_VECTOR "|| nop"\
353 : "=r" (__res) \
354 : "r" (__scno), "0" (__res), "r" (__arg2) \
355 : "memory"); \
356__syscall_return(type,__res); \
357}
358
359#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
360type name(type1 arg1,type2 arg2,type3 arg3) \
361{ \
362register long __scno __asm__ ("r7") = __NR_##name; \
363register long __arg3 __asm__ ("r2") = (long)(arg3); \
364register long __arg2 __asm__ ("r1") = (long)(arg2); \
365register long __res __asm__ ("r0") = (long)(arg1); \
366__asm__ __volatile__ (\
367 "trap #" SYSCALL_VECTOR "|| nop"\
368 : "=r" (__res) \
369 : "r" (__scno), "0" (__res), "r" (__arg2), \
370 "r" (__arg3) \
371 : "memory"); \
372__syscall_return(type,__res); \
373}
374
375#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
376type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
377{ \
378register long __scno __asm__ ("r7") = __NR_##name; \
379register long __arg4 __asm__ ("r3") = (long)(arg4); \
380register long __arg3 __asm__ ("r2") = (long)(arg3); \
381register long __arg2 __asm__ ("r1") = (long)(arg2); \
382register long __res __asm__ ("r0") = (long)(arg1); \
383__asm__ __volatile__ (\
384 "trap #" SYSCALL_VECTOR "|| nop"\
385 : "=r" (__res) \
386 : "r" (__scno), "0" (__res), "r" (__arg2), \
387 "r" (__arg3), "r" (__arg4) \
388 : "memory"); \
389__syscall_return(type,__res); \
390}
391
392#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
393 type5,arg5) \
394type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
395{ \
396register long __scno __asm__ ("r7") = __NR_##name; \
397register long __arg5 __asm__ ("r4") = (long)(arg5); \
398register long __arg4 __asm__ ("r3") = (long)(arg4); \
399register long __arg3 __asm__ ("r2") = (long)(arg3); \
400register long __arg2 __asm__ ("r1") = (long)(arg2); \
401register long __res __asm__ ("r0") = (long)(arg1); \
402__asm__ __volatile__ (\
403 "trap #" SYSCALL_VECTOR "|| nop"\
404 : "=r" (__res) \
405 : "r" (__scno), "0" (__res), "r" (__arg2), \
406 "r" (__arg3), "r" (__arg4), "r" (__arg5) \
407 : "memory"); \
408__syscall_return(type,__res); \
409}
410 299
411#define __ARCH_WANT_IPC_PARSE_VERSION 300#define __ARCH_WANT_IPC_PARSE_VERSION
412#define __ARCH_WANT_STAT64 301#define __ARCH_WANT_STAT64
diff --git a/include/asm-m68k/dma-mapping.h b/include/asm-m68k/dma-mapping.h
index d90d841d3dfd..00259ed6fc95 100644
--- a/include/asm-m68k/dma-mapping.h
+++ b/include/asm-m68k/dma-mapping.h
@@ -21,7 +21,7 @@ static inline int dma_get_cache_alignment(void)
21 return 1 << L1_CACHE_SHIFT; 21 return 1 << L1_CACHE_SHIFT;
22} 22}
23 23
24static inline int dma_is_consistent(dma_addr_t dma_addr) 24static inline int dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
25{ 25{
26 return 0; 26 return 0;
27} 27}
@@ -41,7 +41,7 @@ static inline void dma_free_noncoherent(struct device *dev, size_t size,
41{ 41{
42 dma_free_coherent(dev, size, addr, handle); 42 dma_free_coherent(dev, size, addr, handle);
43} 43}
44static inline void dma_cache_sync(void *vaddr, size_t size, 44static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
45 enum dma_data_direction dir) 45 enum dma_data_direction dir)
46{ 46{
47 /* we use coherent allocation, so not much to do here. */ 47 /* we use coherent allocation, so not much to do here. */
diff --git a/include/asm-m68k/setup.h b/include/asm-m68k/setup.h
index 7facc9a46e74..2a8853cd6554 100644
--- a/include/asm-m68k/setup.h
+++ b/include/asm-m68k/setup.h
@@ -41,8 +41,12 @@
41#define MACH_Q40 10 41#define MACH_Q40 10
42#define MACH_SUN3X 11 42#define MACH_SUN3X 11
43 43
44#define COMMAND_LINE_SIZE 256
45
44#ifdef __KERNEL__ 46#ifdef __KERNEL__
45 47
48#define CL_SIZE COMMAND_LINE_SIZE
49
46#ifndef __ASSEMBLY__ 50#ifndef __ASSEMBLY__
47extern unsigned long m68k_machtype; 51extern unsigned long m68k_machtype;
48#endif /* !__ASSEMBLY__ */ 52#endif /* !__ASSEMBLY__ */
@@ -355,8 +359,6 @@ extern int m68k_is040or060;
355 */ 359 */
356 360
357#define NUM_MEMINFO 4 361#define NUM_MEMINFO 4
358#define CL_SIZE 256
359#define COMMAND_LINE_SIZE CL_SIZE
360 362
361#ifndef __ASSEMBLY__ 363#ifndef __ASSEMBLY__
362struct mem_info { 364struct mem_info {
diff --git a/include/asm-m68k/unistd.h b/include/asm-m68k/unistd.h
index ad4348058c66..fdbb60e6a0d4 100644
--- a/include/asm-m68k/unistd.h
+++ b/include/asm-m68k/unistd.h
@@ -317,103 +317,6 @@
317#ifdef __KERNEL__ 317#ifdef __KERNEL__
318 318
319#define NR_syscalls 311 319#define NR_syscalls 311
320#include <linux/err.h>
321
322/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
323 <asm-m68k/errno.h> */
324
325#define __syscall_return(type, res) \
326do { \
327 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
328 /* avoid using res which is declared to be in register d0; \
329 errno might expand to a function call and clobber it. */ \
330 int __err = -(res); \
331 errno = __err; \
332 res = -1; \
333 } \
334 return (type) (res); \
335} while (0)
336
337#define _syscall0(type,name) \
338type name(void) \
339{ \
340register long __res __asm__ ("%d0") = __NR_##name; \
341__asm__ __volatile__ ("trap #0" \
342 : "+d" (__res) ); \
343__syscall_return(type,__res); \
344}
345
346#define _syscall1(type,name,atype,a) \
347type name(atype a) \
348{ \
349register long __res __asm__ ("%d0") = __NR_##name; \
350register long __a __asm__ ("%d1") = (long)(a); \
351__asm__ __volatile__ ("trap #0" \
352 : "+d" (__res) \
353 : "d" (__a) ); \
354__syscall_return(type,__res); \
355}
356
357#define _syscall2(type,name,atype,a,btype,b) \
358type name(atype a,btype b) \
359{ \
360register long __res __asm__ ("%d0") = __NR_##name; \
361register long __a __asm__ ("%d1") = (long)(a); \
362register long __b __asm__ ("%d2") = (long)(b); \
363__asm__ __volatile__ ("trap #0" \
364 : "+d" (__res) \
365 : "d" (__a), "d" (__b) \
366 ); \
367__syscall_return(type,__res); \
368}
369
370#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
371type name(atype a,btype b,ctype c) \
372{ \
373register long __res __asm__ ("%d0") = __NR_##name; \
374register long __a __asm__ ("%d1") = (long)(a); \
375register long __b __asm__ ("%d2") = (long)(b); \
376register long __c __asm__ ("%d3") = (long)(c); \
377__asm__ __volatile__ ("trap #0" \
378 : "+d" (__res) \
379 : "d" (__a), "d" (__b), \
380 "d" (__c) \
381 ); \
382__syscall_return(type,__res); \
383}
384
385#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
386type name (atype a, btype b, ctype c, dtype d) \
387{ \
388register long __res __asm__ ("%d0") = __NR_##name; \
389register long __a __asm__ ("%d1") = (long)(a); \
390register long __b __asm__ ("%d2") = (long)(b); \
391register long __c __asm__ ("%d3") = (long)(c); \
392register long __d __asm__ ("%d4") = (long)(d); \
393__asm__ __volatile__ ("trap #0" \
394 : "+d" (__res) \
395 : "d" (__a), "d" (__b), \
396 "d" (__c), "d" (__d) \
397 ); \
398__syscall_return(type,__res); \
399}
400
401#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
402type name (atype a,btype b,ctype c,dtype d,etype e) \
403{ \
404register long __res __asm__ ("%d0") = __NR_##name; \
405register long __a __asm__ ("%d1") = (long)(a); \
406register long __b __asm__ ("%d2") = (long)(b); \
407register long __c __asm__ ("%d3") = (long)(c); \
408register long __d __asm__ ("%d4") = (long)(d); \
409register long __e __asm__ ("%d5") = (long)(e); \
410__asm__ __volatile__ ("trap #0" \
411 : "+d" (__res) \
412 : "d" (__a), "d" (__b), \
413 "d" (__c), "d" (__d), "d" (__e) \
414 ); \
415__syscall_return(type,__res); \
416}
417 320
418#define __ARCH_WANT_IPC_PARSE_VERSION 321#define __ARCH_WANT_IPC_PARSE_VERSION
419#define __ARCH_WANT_OLD_READDIR 322#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-m68knommu/setup.h b/include/asm-m68knommu/setup.h
index d2b0fcce41b2..fb86bb2a6078 100644
--- a/include/asm-m68knommu/setup.h
+++ b/include/asm-m68knommu/setup.h
@@ -1,5 +1,10 @@
1#ifdef __KERNEL__
2
1#include <asm-m68k/setup.h> 3#include <asm-m68k/setup.h>
2 4
3/* We have a bigger command line buffer. */ 5/* We have a bigger command line buffer. */
4#undef COMMAND_LINE_SIZE 6#undef COMMAND_LINE_SIZE
7
8#endif /* __KERNEL__ */
9
5#define COMMAND_LINE_SIZE 512 10#define COMMAND_LINE_SIZE 512
diff --git a/include/asm-m68knommu/unistd.h b/include/asm-m68knommu/unistd.h
index ebaf03197114..82e03195f325 100644
--- a/include/asm-m68knommu/unistd.h
+++ b/include/asm-m68knommu/unistd.h
@@ -318,156 +318,6 @@
318#ifdef __KERNEL__ 318#ifdef __KERNEL__
319 319
320#define NR_syscalls 311 320#define NR_syscalls 311
321#include <linux/err.h>
322
323/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
324 <asm-m68k/errno.h> */
325
326#define __syscall_return(type, res) \
327do { \
328 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
329 /* avoid using res which is declared to be in register d0; \
330 errno might expand to a function call and clobber it. */ \
331 int __err = -(res); \
332 errno = __err; \
333 res = -1; \
334 } \
335 return (type) (res); \
336} while (0)
337
338#define _syscall0(type, name) \
339type name(void) \
340{ \
341 long __res; \
342 __asm__ __volatile__ ("movel %1, %%d0\n\t" \
343 "trap #0\n\t" \
344 "movel %%d0, %0" \
345 : "=g" (__res) \
346 : "i" (__NR_##name) \
347 : "cc", "%d0"); \
348 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
349 errno = -__res; \
350 __res = -1; \
351 } \
352 return (type)__res; \
353}
354
355#define _syscall1(type, name, atype, a) \
356type name(atype a) \
357{ \
358 long __res; \
359 __asm__ __volatile__ ("movel %2, %%d1\n\t" \
360 "movel %1, %%d0\n\t" \
361 "trap #0\n\t" \
362 "movel %%d0, %0" \
363 : "=g" (__res) \
364 : "i" (__NR_##name), \
365 "g" ((long)a) \
366 : "cc", "%d0", "%d1"); \
367 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
368 errno = -__res; \
369 __res = -1; \
370 } \
371 return (type)__res; \
372}
373
374#define _syscall2(type, name, atype, a, btype, b) \
375type name(atype a, btype b) \
376{ \
377 long __res; \
378 __asm__ __volatile__ ("movel %3, %%d2\n\t" \
379 "movel %2, %%d1\n\t" \
380 "movel %1, %%d0\n\t" \
381 "trap #0\n\t" \
382 "movel %%d0, %0" \
383 : "=g" (__res) \
384 : "i" (__NR_##name), \
385 "a" ((long)a), \
386 "g" ((long)b) \
387 : "cc", "%d0", "%d1", "%d2"); \
388 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
389 errno = -__res; \
390 __res = -1; \
391 } \
392 return (type)__res; \
393}
394
395#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
396type name(atype a, btype b, ctype c) \
397{ \
398 long __res; \
399 __asm__ __volatile__ ("movel %4, %%d3\n\t" \
400 "movel %3, %%d2\n\t" \
401 "movel %2, %%d1\n\t" \
402 "movel %1, %%d0\n\t" \
403 "trap #0\n\t" \
404 "movel %%d0, %0" \
405 : "=g" (__res) \
406 : "i" (__NR_##name), \
407 "a" ((long)a), \
408 "a" ((long)b), \
409 "g" ((long)c) \
410 : "cc", "%d0", "%d1", "%d2", "%d3"); \
411 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
412 errno = -__res; \
413 __res = -1; \
414 } \
415 return (type)__res; \
416}
417
418#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
419type name(atype a, btype b, ctype c, dtype d) \
420{ \
421 long __res; \
422 __asm__ __volatile__ ("movel %5, %%d4\n\t" \
423 "movel %4, %%d3\n\t" \
424 "movel %3, %%d2\n\t" \
425 "movel %2, %%d1\n\t" \
426 "movel %1, %%d0\n\t" \
427 "trap #0\n\t" \
428 "movel %%d0, %0" \
429 : "=g" (__res) \
430 : "i" (__NR_##name), \
431 "a" ((long)a), \
432 "a" ((long)b), \
433 "a" ((long)c), \
434 "g" ((long)d) \
435 : "cc", "%d0", "%d1", "%d2", "%d3", \
436 "%d4"); \
437 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
438 errno = -__res; \
439 __res = -1; \
440 } \
441 return (type)__res; \
442}
443
444#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e) \
445type name(atype a, btype b, ctype c, dtype d, etype e) \
446{ \
447 long __res; \
448 __asm__ __volatile__ ("movel %6, %%d5\n\t" \
449 "movel %5, %%d4\n\t" \
450 "movel %4, %%d3\n\t" \
451 "movel %3, %%d2\n\t" \
452 "movel %2, %%d1\n\t" \
453 "movel %1, %%d0\n\t" \
454 "trap #0\n\t" \
455 "movel %%d0, %0" \
456 : "=g" (__res) \
457 : "i" (__NR_##name), \
458 "a" ((long)a), \
459 "a" ((long)b), \
460 "a" ((long)c), \
461 "a" ((long)d), \
462 "g" ((long)e) \
463 : "cc", "%d0", "%d1", "%d2", "%d3", \
464 "%d4", "%d5"); \
465 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
466 errno = -__res; \
467 __res = -1; \
468 } \
469 return (type)__res; \
470}
471 321
472#define __ARCH_WANT_IPC_PARSE_VERSION 322#define __ARCH_WANT_IPC_PARSE_VERSION
473#define __ARCH_WANT_OLD_READDIR 323#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-mips/dma-mapping.h b/include/asm-mips/dma-mapping.h
index 43288634c38a..236d1a467cc7 100644
--- a/include/asm-mips/dma-mapping.h
+++ b/include/asm-mips/dma-mapping.h
@@ -63,9 +63,9 @@ dma_get_cache_alignment(void)
63 return 128; 63 return 128;
64} 64}
65 65
66extern int dma_is_consistent(dma_addr_t dma_addr); 66extern int dma_is_consistent(struct device *dev, dma_addr_t dma_addr);
67 67
68extern void dma_cache_sync(void *vaddr, size_t size, 68extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
69 enum dma_data_direction direction); 69 enum dma_data_direction direction);
70 70
71#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY 71#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
diff --git a/include/asm-mips/futex.h b/include/asm-mips/futex.h
index 927a216bd530..47e5679c2353 100644
--- a/include/asm-mips/futex.h
+++ b/include/asm-mips/futex.h
@@ -88,7 +88,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
88 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 88 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
89 return -EFAULT; 89 return -EFAULT;
90 90
91 inc_preempt_count(); 91 pagefault_disable();
92 92
93 switch (op) { 93 switch (op) {
94 case FUTEX_OP_SET: 94 case FUTEX_OP_SET:
@@ -115,7 +115,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
115 ret = -ENOSYS; 115 ret = -ENOSYS;
116 } 116 }
117 117
118 dec_preempt_count(); 118 pagefault_enable();
119 119
120 if (!ret) { 120 if (!ret) {
121 switch (cmp) { 121 switch (cmp) {
diff --git a/include/asm-mips/highmem.h b/include/asm-mips/highmem.h
index c976bfaaba83..f8c8182f7f2e 100644
--- a/include/asm-mips/highmem.h
+++ b/include/asm-mips/highmem.h
@@ -21,6 +21,7 @@
21 21
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/uaccess.h>
24#include <asm/kmap_types.h> 25#include <asm/kmap_types.h>
25 26
26/* undef for production */ 27/* undef for production */
@@ -70,11 +71,16 @@ static inline void *kmap(struct page *page)
70 71
71static inline void *kmap_atomic(struct page *page, enum km_type type) 72static inline void *kmap_atomic(struct page *page, enum km_type type)
72{ 73{
74 pagefault_disable();
73 return page_address(page); 75 return page_address(page);
74} 76}
75 77
76static inline void kunmap_atomic(void *kvaddr, enum km_type type) { } 78static inline void kunmap_atomic(void *kvaddr, enum km_type type)
77#define kmap_atomic_pfn(pfn, idx) page_address(pfn_to_page(pfn)) 79{
80 pagefault_enable();
81}
82
83#define kmap_atomic_pfn(pfn, idx) kmap_atomic(pfn_to_page(pfn), (idx))
78 84
79#define kmap_atomic_to_page(ptr) virt_to_page(ptr) 85#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
80 86
diff --git a/include/asm-mips/setup.h b/include/asm-mips/setup.h
index 737fa4a6912e..70009a902639 100644
--- a/include/asm-mips/setup.h
+++ b/include/asm-mips/setup.h
@@ -1,8 +1,6 @@
1#ifdef __KERNEL__
2#ifndef _MIPS_SETUP_H 1#ifndef _MIPS_SETUP_H
3#define _MIPS_SETUP_H 2#define _MIPS_SETUP_H
4 3
5#define COMMAND_LINE_SIZE 256 4#define COMMAND_LINE_SIZE 256
6 5
7#endif /* __SETUP_H */ 6#endif /* __SETUP_H */
8#endif /* __KERNEL__ */
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index ec56aa52f669..696cff39a1d3 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -933,268 +933,6 @@
933 933
934#ifndef __ASSEMBLY__ 934#ifndef __ASSEMBLY__
935 935
936/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
937#define _syscall0(type,name) \
938type name(void) \
939{ \
940 register unsigned long __a3 asm("$7"); \
941 unsigned long __v0; \
942 \
943 __asm__ volatile ( \
944 ".set\tnoreorder\n\t" \
945 "li\t$2, %2\t\t\t# " #name "\n\t" \
946 "syscall\n\t" \
947 "move\t%0, $2\n\t" \
948 ".set\treorder" \
949 : "=&r" (__v0), "=r" (__a3) \
950 : "i" (__NR_##name) \
951 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
952 "memory"); \
953 \
954 if (__a3 == 0) \
955 return (type) __v0; \
956 errno = __v0; \
957 return (type) -1; \
958}
959
960/*
961 * DANGER: This macro isn't usable for the pipe(2) call
962 * which has a unusual return convention.
963 */
964#define _syscall1(type,name,atype,a) \
965type name(atype a) \
966{ \
967 register unsigned long __a0 asm("$4") = (unsigned long) a; \
968 register unsigned long __a3 asm("$7"); \
969 unsigned long __v0; \
970 \
971 __asm__ volatile ( \
972 ".set\tnoreorder\n\t" \
973 "li\t$2, %3\t\t\t# " #name "\n\t" \
974 "syscall\n\t" \
975 "move\t%0, $2\n\t" \
976 ".set\treorder" \
977 : "=&r" (__v0), "=r" (__a3) \
978 : "r" (__a0), "i" (__NR_##name) \
979 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
980 "memory"); \
981 \
982 if (__a3 == 0) \
983 return (type) __v0; \
984 errno = __v0; \
985 return (type) -1; \
986}
987
988#define _syscall2(type,name,atype,a,btype,b) \
989type name(atype a, btype b) \
990{ \
991 register unsigned long __a0 asm("$4") = (unsigned long) a; \
992 register unsigned long __a1 asm("$5") = (unsigned long) b; \
993 register unsigned long __a3 asm("$7"); \
994 unsigned long __v0; \
995 \
996 __asm__ volatile ( \
997 ".set\tnoreorder\n\t" \
998 "li\t$2, %4\t\t\t# " #name "\n\t" \
999 "syscall\n\t" \
1000 "move\t%0, $2\n\t" \
1001 ".set\treorder" \
1002 : "=&r" (__v0), "=r" (__a3) \
1003 : "r" (__a0), "r" (__a1), "i" (__NR_##name) \
1004 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1005 "memory"); \
1006 \
1007 if (__a3 == 0) \
1008 return (type) __v0; \
1009 errno = __v0; \
1010 return (type) -1; \
1011}
1012
1013#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
1014type name(atype a, btype b, ctype c) \
1015{ \
1016 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1017 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1018 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1019 register unsigned long __a3 asm("$7"); \
1020 unsigned long __v0; \
1021 \
1022 __asm__ volatile ( \
1023 ".set\tnoreorder\n\t" \
1024 "li\t$2, %5\t\t\t# " #name "\n\t" \
1025 "syscall\n\t" \
1026 "move\t%0, $2\n\t" \
1027 ".set\treorder" \
1028 : "=&r" (__v0), "=r" (__a3) \
1029 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
1030 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1031 "memory"); \
1032 \
1033 if (__a3 == 0) \
1034 return (type) __v0; \
1035 errno = __v0; \
1036 return (type) -1; \
1037}
1038
1039#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
1040type name(atype a, btype b, ctype c, dtype d) \
1041{ \
1042 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1043 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1044 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1045 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1046 unsigned long __v0; \
1047 \
1048 __asm__ volatile ( \
1049 ".set\tnoreorder\n\t" \
1050 "li\t$2, %5\t\t\t# " #name "\n\t" \
1051 "syscall\n\t" \
1052 "move\t%0, $2\n\t" \
1053 ".set\treorder" \
1054 : "=&r" (__v0), "+r" (__a3) \
1055 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
1056 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1057 "memory"); \
1058 \
1059 if (__a3 == 0) \
1060 return (type) __v0; \
1061 errno = __v0; \
1062 return (type) -1; \
1063}
1064
1065#if (_MIPS_SIM == _MIPS_SIM_ABI32)
1066
1067/*
1068 * Using those means your brain needs more than an oil change ;-)
1069 */
1070
1071#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
1072type name(atype a, btype b, ctype c, dtype d, etype e) \
1073{ \
1074 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1075 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1076 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1077 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1078 unsigned long __v0; \
1079 \
1080 __asm__ volatile ( \
1081 ".set\tnoreorder\n\t" \
1082 "lw\t$2, %6\n\t" \
1083 "subu\t$29, 32\n\t" \
1084 "sw\t$2, 16($29)\n\t" \
1085 "li\t$2, %5\t\t\t# " #name "\n\t" \
1086 "syscall\n\t" \
1087 "move\t%0, $2\n\t" \
1088 "addiu\t$29, 32\n\t" \
1089 ".set\treorder" \
1090 : "=&r" (__v0), "+r" (__a3) \
1091 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
1092 "m" ((unsigned long)e) \
1093 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1094 "memory"); \
1095 \
1096 if (__a3 == 0) \
1097 return (type) __v0; \
1098 errno = __v0; \
1099 return (type) -1; \
1100}
1101
1102#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
1103type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \
1104{ \
1105 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1106 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1107 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1108 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1109 unsigned long __v0; \
1110 \
1111 __asm__ volatile ( \
1112 ".set\tnoreorder\n\t" \
1113 "lw\t$2, %6\n\t" \
1114 "lw\t$8, %7\n\t" \
1115 "subu\t$29, 32\n\t" \
1116 "sw\t$2, 16($29)\n\t" \
1117 "sw\t$8, 20($29)\n\t" \
1118 "li\t$2, %5\t\t\t# " #name "\n\t" \
1119 "syscall\n\t" \
1120 "move\t%0, $2\n\t" \
1121 "addiu\t$29, 32\n\t" \
1122 ".set\treorder" \
1123 : "=&r" (__v0), "+r" (__a3) \
1124 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
1125 "m" ((unsigned long)e), "m" ((unsigned long)f) \
1126 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1127 "memory"); \
1128 \
1129 if (__a3 == 0) \
1130 return (type) __v0; \
1131 errno = __v0; \
1132 return (type) -1; \
1133}
1134
1135#endif /* (_MIPS_SIM == _MIPS_SIM_ABI32) */
1136
1137#if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
1138
1139#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
1140type name (atype a,btype b,ctype c,dtype d,etype e) \
1141{ \
1142 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1143 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1144 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1145 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1146 register unsigned long __a4 asm("$8") = (unsigned long) e; \
1147 unsigned long __v0; \
1148 \
1149 __asm__ volatile ( \
1150 ".set\tnoreorder\n\t" \
1151 "li\t$2, %6\t\t\t# " #name "\n\t" \
1152 "syscall\n\t" \
1153 "move\t%0, $2\n\t" \
1154 ".set\treorder" \
1155 : "=&r" (__v0), "+r" (__a3) \
1156 : "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "i" (__NR_##name) \
1157 : "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1158 "memory"); \
1159 \
1160 if (__a3 == 0) \
1161 return (type) __v0; \
1162 errno = __v0; \
1163 return (type) -1; \
1164}
1165
1166#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
1167type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
1168{ \
1169 register unsigned long __a0 asm("$4") = (unsigned long) a; \
1170 register unsigned long __a1 asm("$5") = (unsigned long) b; \
1171 register unsigned long __a2 asm("$6") = (unsigned long) c; \
1172 register unsigned long __a3 asm("$7") = (unsigned long) d; \
1173 register unsigned long __a4 asm("$8") = (unsigned long) e; \
1174 register unsigned long __a5 asm("$9") = (unsigned long) f; \
1175 unsigned long __v0; \
1176 \
1177 __asm__ volatile ( \
1178 ".set\tnoreorder\n\t" \
1179 "li\t$2, %7\t\t\t# " #name "\n\t" \
1180 "syscall\n\t" \
1181 "move\t%0, $2\n\t" \
1182 ".set\treorder" \
1183 : "=&r" (__v0), "+r" (__a3) \
1184 : "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "r" (__a5), \
1185 "i" (__NR_##name) \
1186 : "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
1187 "memory"); \
1188 \
1189 if (__a3 == 0) \
1190 return (type) __v0; \
1191 errno = __v0; \
1192 return (type) -1; \
1193}
1194
1195#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */
1196
1197
1198#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 936#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
1199#define __ARCH_WANT_IPC_PARSE_VERSION 937#define __ARCH_WANT_IPC_PARSE_VERSION
1200#define __ARCH_WANT_OLD_READDIR 938#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-parisc/dma-mapping.h b/include/asm-parisc/dma-mapping.h
index 1e387e1dad30..66f0b408c669 100644
--- a/include/asm-parisc/dma-mapping.h
+++ b/include/asm-parisc/dma-mapping.h
@@ -191,13 +191,13 @@ dma_get_cache_alignment(void)
191} 191}
192 192
193static inline int 193static inline int
194dma_is_consistent(dma_addr_t dma_addr) 194dma_is_consistent(struct device *dev, dma_addr_t dma_addr)
195{ 195{
196 return (hppa_dma_ops->dma_sync_single_for_cpu == NULL); 196 return (hppa_dma_ops->dma_sync_single_for_cpu == NULL);
197} 197}
198 198
199static inline void 199static inline void
200dma_cache_sync(void *vaddr, size_t size, 200dma_cache_sync(struct device *dev, void *vaddr, size_t size,
201 enum dma_data_direction direction) 201 enum dma_data_direction direction)
202{ 202{
203 if(hppa_dma_ops->dma_sync_single_for_cpu) 203 if(hppa_dma_ops->dma_sync_single_for_cpu)
diff --git a/include/asm-parisc/futex.h b/include/asm-parisc/futex.h
index d84bbb283fd1..dbee6e60aa81 100644
--- a/include/asm-parisc/futex.h
+++ b/include/asm-parisc/futex.h
@@ -21,7 +21,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
21 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 21 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
22 return -EFAULT; 22 return -EFAULT;
23 23
24 inc_preempt_count(); 24 pagefault_disable();
25 25
26 switch (op) { 26 switch (op) {
27 case FUTEX_OP_SET: 27 case FUTEX_OP_SET:
@@ -33,7 +33,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
33 ret = -ENOSYS; 33 ret = -ENOSYS;
34 } 34 }
35 35
36 dec_preempt_count(); 36 pagefault_enable();
37 37
38 if (!ret) { 38 if (!ret) {
39 switch (cmp) { 39 switch (cmp) {
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h
index 7e38b5fddada..7c7de87bd8ae 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -342,9 +342,9 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
342#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 342#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
343#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 343#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
344#ifdef CONFIG_NOT_COHERENT_CACHE 344#ifdef CONFIG_NOT_COHERENT_CACHE
345#define dma_is_consistent(d) (0) 345#define dma_is_consistent(d, h) (0)
346#else 346#else
347#define dma_is_consistent(d) (1) 347#define dma_is_consistent(d, h) (1)
348#endif 348#endif
349 349
350static inline int dma_get_cache_alignment(void) 350static inline int dma_get_cache_alignment(void)
@@ -378,7 +378,7 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
378 dma_sync_single_for_device(dev, dma_handle, offset + size, direction); 378 dma_sync_single_for_device(dev, dma_handle, offset + size, direction);
379} 379}
380 380
381static inline void dma_cache_sync(void *vaddr, size_t size, 381static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
382 enum dma_data_direction direction) 382 enum dma_data_direction direction)
383{ 383{
384 BUG_ON(direction == DMA_NONE); 384 BUG_ON(direction == DMA_NONE);
diff --git a/include/asm-powerpc/elf.h b/include/asm-powerpc/elf.h
index b5436642a109..d36426c01b6b 100644
--- a/include/asm-powerpc/elf.h
+++ b/include/asm-powerpc/elf.h
@@ -124,12 +124,10 @@ typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG];
124# define ELF_DATA ELFDATA2MSB 124# define ELF_DATA ELFDATA2MSB
125 typedef elf_greg_t64 elf_greg_t; 125 typedef elf_greg_t64 elf_greg_t;
126 typedef elf_gregset_t64 elf_gregset_t; 126 typedef elf_gregset_t64 elf_gregset_t;
127# define elf_addr_t unsigned long
128#else 127#else
129 /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */ 128 /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */
130 typedef elf_greg_t32 elf_greg_t; 129 typedef elf_greg_t32 elf_greg_t;
131 typedef elf_gregset_t32 elf_gregset_t; 130 typedef elf_gregset_t32 elf_gregset_t;
132# define elf_addr_t __u32
133#endif /* ELF_ARCH */ 131#endif /* ELF_ARCH */
134 132
135/* Floating point registers */ 133/* Floating point registers */
diff --git a/include/asm-powerpc/futex.h b/include/asm-powerpc/futex.h
index 936422e54891..3f3673fd3ff3 100644
--- a/include/asm-powerpc/futex.h
+++ b/include/asm-powerpc/futex.h
@@ -43,7 +43,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
43 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 43 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
44 return -EFAULT; 44 return -EFAULT;
45 45
46 inc_preempt_count(); 46 pagefault_disable();
47 47
48 switch (op) { 48 switch (op) {
49 case FUTEX_OP_SET: 49 case FUTEX_OP_SET:
@@ -65,7 +65,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
65 ret = -ENOSYS; 65 ret = -ENOSYS;
66 } 66 }
67 67
68 dec_preempt_count(); 68 pagefault_enable();
69 69
70 if (!ret) { 70 if (!ret) {
71 switch (cmp) { 71 switch (cmp) {
diff --git a/include/asm-powerpc/pgalloc.h b/include/asm-powerpc/pgalloc.h
index ae63db7b3e7d..b0830db68f8a 100644
--- a/include/asm-powerpc/pgalloc.h
+++ b/include/asm-powerpc/pgalloc.h
@@ -11,7 +11,7 @@
11#include <linux/cpumask.h> 11#include <linux/cpumask.h>
12#include <linux/percpu.h> 12#include <linux/percpu.h>
13 13
14extern kmem_cache_t *pgtable_cache[]; 14extern struct kmem_cache *pgtable_cache[];
15 15
16#ifdef CONFIG_PPC_64K_PAGES 16#ifdef CONFIG_PPC_64K_PAGES
17#define PTE_CACHE_NUM 0 17#define PTE_CACHE_NUM 0
diff --git a/include/asm-powerpc/setup.h b/include/asm-powerpc/setup.h
index 3d9740aae018..817fac0a0714 100644
--- a/include/asm-powerpc/setup.h
+++ b/include/asm-powerpc/setup.h
@@ -1,9 +1,6 @@
1#ifndef _ASM_POWERPC_SETUP_H 1#ifndef _ASM_POWERPC_SETUP_H
2#define _ASM_POWERPC_SETUP_H 2#define _ASM_POWERPC_SETUP_H
3 3
4#ifdef __KERNEL__
5
6#define COMMAND_LINE_SIZE 512 4#define COMMAND_LINE_SIZE 512
7 5
8#endif /* __KERNEL__ */
9#endif /* _ASM_POWERPC_SETUP_H */ 6#endif /* _ASM_POWERPC_SETUP_H */
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h
index 04b6c17cc59b..0ae954e3d258 100644
--- a/include/asm-powerpc/unistd.h
+++ b/include/asm-powerpc/unistd.h
@@ -334,115 +334,6 @@
334 334
335#ifndef __ASSEMBLY__ 335#ifndef __ASSEMBLY__
336 336
337/* On powerpc a system call basically clobbers the same registers like a
338 * function call, with the exception of LR (which is needed for the
339 * "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal
340 * an error return status).
341 */
342
343#define __syscall_nr(nr, type, name, args...) \
344 unsigned long __sc_ret, __sc_err; \
345 { \
346 register unsigned long __sc_0 __asm__ ("r0"); \
347 register unsigned long __sc_3 __asm__ ("r3"); \
348 register unsigned long __sc_4 __asm__ ("r4"); \
349 register unsigned long __sc_5 __asm__ ("r5"); \
350 register unsigned long __sc_6 __asm__ ("r6"); \
351 register unsigned long __sc_7 __asm__ ("r7"); \
352 register unsigned long __sc_8 __asm__ ("r8"); \
353 \
354 __sc_loadargs_##nr(name, args); \
355 __asm__ __volatile__ \
356 ("sc \n\t" \
357 "mfcr %0 " \
358 : "=&r" (__sc_0), \
359 "=&r" (__sc_3), "=&r" (__sc_4), \
360 "=&r" (__sc_5), "=&r" (__sc_6), \
361 "=&r" (__sc_7), "=&r" (__sc_8) \
362 : __sc_asm_input_##nr \
363 : "cr0", "ctr", "memory", \
364 "r9", "r10","r11", "r12"); \
365 __sc_ret = __sc_3; \
366 __sc_err = __sc_0; \
367 } \
368 if (__sc_err & 0x10000000) \
369 { \
370 errno = __sc_ret; \
371 __sc_ret = -1; \
372 } \
373 return (type) __sc_ret
374
375#define __sc_loadargs_0(name, dummy...) \
376 __sc_0 = __NR_##name
377#define __sc_loadargs_1(name, arg1) \
378 __sc_loadargs_0(name); \
379 __sc_3 = (unsigned long) (arg1)
380#define __sc_loadargs_2(name, arg1, arg2) \
381 __sc_loadargs_1(name, arg1); \
382 __sc_4 = (unsigned long) (arg2)
383#define __sc_loadargs_3(name, arg1, arg2, arg3) \
384 __sc_loadargs_2(name, arg1, arg2); \
385 __sc_5 = (unsigned long) (arg3)
386#define __sc_loadargs_4(name, arg1, arg2, arg3, arg4) \
387 __sc_loadargs_3(name, arg1, arg2, arg3); \
388 __sc_6 = (unsigned long) (arg4)
389#define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5) \
390 __sc_loadargs_4(name, arg1, arg2, arg3, arg4); \
391 __sc_7 = (unsigned long) (arg5)
392#define __sc_loadargs_6(name, arg1, arg2, arg3, arg4, arg5, arg6) \
393 __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5); \
394 __sc_8 = (unsigned long) (arg6)
395
396#define __sc_asm_input_0 "0" (__sc_0)
397#define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3)
398#define __sc_asm_input_2 __sc_asm_input_1, "2" (__sc_4)
399#define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5)
400#define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6)
401#define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7)
402#define __sc_asm_input_6 __sc_asm_input_5, "6" (__sc_8)
403
404#define _syscall0(type,name) \
405type name(void) \
406{ \
407 __syscall_nr(0, type, name); \
408}
409
410#define _syscall1(type,name,type1,arg1) \
411type name(type1 arg1) \
412{ \
413 __syscall_nr(1, type, name, arg1); \
414}
415
416#define _syscall2(type,name,type1,arg1,type2,arg2) \
417type name(type1 arg1, type2 arg2) \
418{ \
419 __syscall_nr(2, type, name, arg1, arg2); \
420}
421
422#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
423type name(type1 arg1, type2 arg2, type3 arg3) \
424{ \
425 __syscall_nr(3, type, name, arg1, arg2, arg3); \
426}
427
428#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
429type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
430{ \
431 __syscall_nr(4, type, name, arg1, arg2, arg3, arg4); \
432}
433
434#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
435type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
436{ \
437 __syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5); \
438}
439#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
440type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
441{ \
442 __syscall_nr(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6); \
443}
444
445
446#include <linux/types.h> 337#include <linux/types.h>
447#include <linux/compiler.h> 338#include <linux/compiler.h>
448#include <linux/linkage.h> 339#include <linux/linkage.h>
diff --git a/include/asm-ppc/highmem.h b/include/asm-ppc/highmem.h
index 1d2c4ef81c22..f7b21ee302b4 100644
--- a/include/asm-ppc/highmem.h
+++ b/include/asm-ppc/highmem.h
@@ -79,7 +79,7 @@ static inline void *kmap_atomic(struct page *page, enum km_type type)
79 unsigned long vaddr; 79 unsigned long vaddr;
80 80
81 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */ 81 /* even !CONFIG_PREEMPT needs this, for in_atomic in do_page_fault */
82 inc_preempt_count(); 82 pagefault_disable();
83 if (!PageHighMem(page)) 83 if (!PageHighMem(page))
84 return page_address(page); 84 return page_address(page);
85 85
@@ -101,8 +101,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
101 unsigned int idx = type + KM_TYPE_NR*smp_processor_id(); 101 unsigned int idx = type + KM_TYPE_NR*smp_processor_id();
102 102
103 if (vaddr < KMAP_FIX_BEGIN) { // FIXME 103 if (vaddr < KMAP_FIX_BEGIN) { // FIXME
104 dec_preempt_count(); 104 pagefault_enable();
105 preempt_check_resched();
106 return; 105 return;
107 } 106 }
108 107
@@ -115,8 +114,7 @@ static inline void kunmap_atomic(void *kvaddr, enum km_type type)
115 pte_clear(&init_mm, vaddr, kmap_pte+idx); 114 pte_clear(&init_mm, vaddr, kmap_pte+idx);
116 flush_tlb_page(NULL, vaddr); 115 flush_tlb_page(NULL, vaddr);
117#endif 116#endif
118 dec_preempt_count(); 117 pagefault_enable();
119 preempt_check_resched();
120} 118}
121 119
122static inline struct page *kmap_atomic_to_page(void *ptr) 120static inline struct page *kmap_atomic_to_page(void *ptr)
diff --git a/include/asm-s390/setup.h b/include/asm-s390/setup.h
index 7664bacdd832..9574fe80a046 100644
--- a/include/asm-s390/setup.h
+++ b/include/asm-s390/setup.h
@@ -8,12 +8,13 @@
8#ifndef _ASM_S390_SETUP_H 8#ifndef _ASM_S390_SETUP_H
9#define _ASM_S390_SETUP_H 9#define _ASM_S390_SETUP_H
10 10
11#define COMMAND_LINE_SIZE 896
12
11#ifdef __KERNEL__ 13#ifdef __KERNEL__
12 14
13#include <asm/types.h> 15#include <asm/types.h>
14 16
15#define PARMAREA 0x10400 17#define PARMAREA 0x10400
16#define COMMAND_LINE_SIZE 896
17#define MEMORY_CHUNKS 16 /* max 0x7fff */ 18#define MEMORY_CHUNKS 16 /* max 0x7fff */
18#define IPL_PARMBLOCK_ORIGIN 0x2000 19#define IPL_PARMBLOCK_ORIGIN 0x2000
19 20
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
index 71d3c21b84f0..fb6fef97d739 100644
--- a/include/asm-s390/unistd.h
+++ b/include/asm-s390/unistd.h
@@ -345,160 +345,6 @@
345 345
346#ifdef __KERNEL__ 346#ifdef __KERNEL__
347 347
348#include <linux/err.h>
349
350#define __syscall_return(type, res) \
351do { \
352 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
353 errno = -(res); \
354 res = -1; \
355 } \
356 return (type) (res); \
357} while (0)
358
359#define _svc_clobber "1", "cc", "memory"
360
361#define _syscall0(type,name) \
362type name(void) { \
363 register long __svcres asm("2"); \
364 long __res; \
365 asm volatile( \
366 " .if %1 < 256\n" \
367 " svc %b1\n" \
368 " .else\n" \
369 " la %%r1,%1\n" \
370 " svc 0\n" \
371 " .endif" \
372 : "=d" (__svcres) \
373 : "i" (__NR_##name) \
374 : _svc_clobber); \
375 __res = __svcres; \
376 __syscall_return(type,__res); \
377}
378
379#define _syscall1(type,name,type1,arg1) \
380type name(type1 arg1) { \
381 register type1 __arg1 asm("2") = arg1; \
382 register long __svcres asm("2"); \
383 long __res; \
384 asm volatile( \
385 " .if %1 < 256\n" \
386 " svc %b1\n" \
387 " .else\n" \
388 " la %%r1,%1\n" \
389 " svc 0\n" \
390 " .endif" \
391 : "=d" (__svcres) \
392 : "i" (__NR_##name), \
393 "0" (__arg1) \
394 : _svc_clobber); \
395 __res = __svcres; \
396 __syscall_return(type,__res); \
397}
398
399#define _syscall2(type,name,type1,arg1,type2,arg2) \
400type name(type1 arg1, type2 arg2) { \
401 register type1 __arg1 asm("2") = arg1; \
402 register type2 __arg2 asm("3") = arg2; \
403 register long __svcres asm("2"); \
404 long __res; \
405 asm volatile( \
406 " .if %1 < 256\n" \
407 " svc %b1\n" \
408 " .else\n" \
409 " la %%r1,%1\n" \
410 " svc 0\n" \
411 " .endif" \
412 : "=d" (__svcres) \
413 : "i" (__NR_##name), \
414 "0" (__arg1), \
415 "d" (__arg2) \
416 : _svc_clobber ); \
417 __res = __svcres; \
418 __syscall_return(type,__res); \
419}
420
421#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
422type name(type1 arg1, type2 arg2, type3 arg3) { \
423 register type1 __arg1 asm("2") = arg1; \
424 register type2 __arg2 asm("3") = arg2; \
425 register type3 __arg3 asm("4") = arg3; \
426 register long __svcres asm("2"); \
427 long __res; \
428 asm volatile( \
429 " .if %1 < 256\n" \
430 " svc %b1\n" \
431 " .else\n" \
432 " la %%r1,%1\n" \
433 " svc 0\n" \
434 " .endif" \
435 : "=d" (__svcres) \
436 : "i" (__NR_##name), \
437 "0" (__arg1), \
438 "d" (__arg2), \
439 "d" (__arg3) \
440 : _svc_clobber); \
441 __res = __svcres; \
442 __syscall_return(type,__res); \
443}
444
445#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3, \
446 type4,name4) \
447type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) { \
448 register type1 __arg1 asm("2") = arg1; \
449 register type2 __arg2 asm("3") = arg2; \
450 register type3 __arg3 asm("4") = arg3; \
451 register type4 __arg4 asm("5") = arg4; \
452 register long __svcres asm("2"); \
453 long __res; \
454 asm volatile( \
455 " .if %1 < 256\n" \
456 " svc %b1\n" \
457 " .else\n" \
458 " la %%r1,%1\n" \
459 " svc 0\n" \
460 " .endif" \
461 : "=d" (__svcres) \
462 : "i" (__NR_##name), \
463 "0" (__arg1), \
464 "d" (__arg2), \
465 "d" (__arg3), \
466 "d" (__arg4) \
467 : _svc_clobber); \
468 __res = __svcres; \
469 __syscall_return(type,__res); \
470}
471
472#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3, \
473 type4,name4,type5,name5) \
474type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
475 type5 arg5) { \
476 register type1 __arg1 asm("2") = arg1; \
477 register type2 __arg2 asm("3") = arg2; \
478 register type3 __arg3 asm("4") = arg3; \
479 register type4 __arg4 asm("5") = arg4; \
480 register type5 __arg5 asm("6") = arg5; \
481 register long __svcres asm("2"); \
482 long __res; \
483 asm volatile( \
484 " .if %1 < 256\n" \
485 " svc %b1\n" \
486 " .else\n" \
487 " la %%r1,%1\n" \
488 " svc 0\n" \
489 " .endif" \
490 : "=d" (__svcres) \
491 : "i" (__NR_##name), \
492 "0" (__arg1), \
493 "d" (__arg2), \
494 "d" (__arg3), \
495 "d" (__arg4), \
496 "d" (__arg5) \
497 : _svc_clobber); \
498 __res = __svcres; \
499 __syscall_return(type,__res); \
500}
501
502#define __ARCH_WANT_IPC_PARSE_VERSION 348#define __ARCH_WANT_IPC_PARSE_VERSION
503#define __ARCH_WANT_OLD_READDIR 349#define __ARCH_WANT_OLD_READDIR
504#define __ARCH_WANT_SYS_ALARM 350#define __ARCH_WANT_SYS_ALARM
diff --git a/include/asm-sh/dma-mapping.h b/include/asm-sh/dma-mapping.h
index 56cd4b977232..37ab0c131a4d 100644
--- a/include/asm-sh/dma-mapping.h
+++ b/include/asm-sh/dma-mapping.h
@@ -53,7 +53,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
53 consistent_free(vaddr, size); 53 consistent_free(vaddr, size);
54} 54}
55 55
56static inline void dma_cache_sync(void *vaddr, size_t size, 56static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
57 enum dma_data_direction dir) 57 enum dma_data_direction dir)
58{ 58{
59 consistent_sync(vaddr, size, (int)dir); 59 consistent_sync(vaddr, size, (int)dir);
diff --git a/include/asm-sh/setup.h b/include/asm-sh/setup.h
index 34ca8a7f06ba..1583c6b7bdaa 100644
--- a/include/asm-sh/setup.h
+++ b/include/asm-sh/setup.h
@@ -1,10 +1,12 @@
1#ifdef __KERNEL__
2#ifndef _SH_SETUP_H 1#ifndef _SH_SETUP_H
3#define _SH_SETUP_H 2#define _SH_SETUP_H
4 3
5#define COMMAND_LINE_SIZE 256 4#define COMMAND_LINE_SIZE 256
6 5
6#ifdef __KERNEL__
7
7int setup_early_printk(char *); 8int setup_early_printk(char *);
8 9
9#endif /* _SH_SETUP_H */
10#endif /* __KERNEL__ */ 10#endif /* __KERNEL__ */
11
12#endif /* _SH_SETUP_H */
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index 0cae1d248761..f982073dc6c6 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -332,143 +332,6 @@
332 332
333#ifdef __KERNEL__ 333#ifdef __KERNEL__
334 334
335#include <linux/err.h>
336
337/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
338 * see <asm-sh/errno.h> */
339
340#define __syscall_return(type, res) \
341do { \
342 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
343 /* Avoid using "res" which is declared to be in register r0; \
344 errno might expand to a function call and clobber it. */ \
345 int __err = -(res); \
346 errno = __err; \
347 res = -1; \
348 } \
349 return (type) (res); \
350} while (0)
351
352#if defined(__sh2__) || defined(__SH2E__) || defined(__SH2A__)
353#define SYSCALL_ARG0 "trapa #0x20"
354#define SYSCALL_ARG1 "trapa #0x21"
355#define SYSCALL_ARG2 "trapa #0x22"
356#define SYSCALL_ARG3 "trapa #0x23"
357#define SYSCALL_ARG4 "trapa #0x24"
358#define SYSCALL_ARG5 "trapa #0x25"
359#define SYSCALL_ARG6 "trapa #0x26"
360#else
361#define SYSCALL_ARG0 "trapa #0x10"
362#define SYSCALL_ARG1 "trapa #0x11"
363#define SYSCALL_ARG2 "trapa #0x12"
364#define SYSCALL_ARG3 "trapa #0x13"
365#define SYSCALL_ARG4 "trapa #0x14"
366#define SYSCALL_ARG5 "trapa #0x15"
367#define SYSCALL_ARG6 "trapa #0x16"
368#endif
369
370/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
371#define _syscall0(type,name) \
372type name(void) \
373{ \
374register long __sc0 __asm__ ("r3") = __NR_##name; \
375__asm__ __volatile__ (SYSCALL_ARG0 \
376 : "=z" (__sc0) \
377 : "0" (__sc0) \
378 : "memory" ); \
379__syscall_return(type,__sc0); \
380}
381
382#define _syscall1(type,name,type1,arg1) \
383type name(type1 arg1) \
384{ \
385register long __sc0 __asm__ ("r3") = __NR_##name; \
386register long __sc4 __asm__ ("r4") = (long) arg1; \
387__asm__ __volatile__ (SYSCALL_ARG1 \
388 : "=z" (__sc0) \
389 : "0" (__sc0), "r" (__sc4) \
390 : "memory"); \
391__syscall_return(type,__sc0); \
392}
393
394#define _syscall2(type,name,type1,arg1,type2,arg2) \
395type name(type1 arg1,type2 arg2) \
396{ \
397register long __sc0 __asm__ ("r3") = __NR_##name; \
398register long __sc4 __asm__ ("r4") = (long) arg1; \
399register long __sc5 __asm__ ("r5") = (long) arg2; \
400__asm__ __volatile__ (SYSCALL_ARG2 \
401 : "=z" (__sc0) \
402 : "0" (__sc0), "r" (__sc4), "r" (__sc5) \
403 : "memory"); \
404__syscall_return(type,__sc0); \
405}
406
407#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
408type name(type1 arg1,type2 arg2,type3 arg3) \
409{ \
410register long __sc0 __asm__ ("r3") = __NR_##name; \
411register long __sc4 __asm__ ("r4") = (long) arg1; \
412register long __sc5 __asm__ ("r5") = (long) arg2; \
413register long __sc6 __asm__ ("r6") = (long) arg3; \
414__asm__ __volatile__ (SYSCALL_ARG3 \
415 : "=z" (__sc0) \
416 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \
417 : "memory"); \
418__syscall_return(type,__sc0); \
419}
420
421#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
422type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
423{ \
424register long __sc0 __asm__ ("r3") = __NR_##name; \
425register long __sc4 __asm__ ("r4") = (long) arg1; \
426register long __sc5 __asm__ ("r5") = (long) arg2; \
427register long __sc6 __asm__ ("r6") = (long) arg3; \
428register long __sc7 __asm__ ("r7") = (long) arg4; \
429__asm__ __volatile__ (SYSCALL_ARG4 \
430 : "=z" (__sc0) \
431 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), \
432 "r" (__sc7) \
433 : "memory" ); \
434__syscall_return(type,__sc0); \
435}
436
437#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
438type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
439{ \
440register long __sc3 __asm__ ("r3") = __NR_##name; \
441register long __sc4 __asm__ ("r4") = (long) arg1; \
442register long __sc5 __asm__ ("r5") = (long) arg2; \
443register long __sc6 __asm__ ("r6") = (long) arg3; \
444register long __sc7 __asm__ ("r7") = (long) arg4; \
445register long __sc0 __asm__ ("r0") = (long) arg5; \
446__asm__ __volatile__ (SYSCALL_ARG5 \
447 : "=z" (__sc0) \
448 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
449 "r" (__sc3) \
450 : "memory" ); \
451__syscall_return(type,__sc0); \
452}
453
454#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
455type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
456{ \
457register long __sc3 __asm__ ("r3") = __NR_##name; \
458register long __sc4 __asm__ ("r4") = (long) arg1; \
459register long __sc5 __asm__ ("r5") = (long) arg2; \
460register long __sc6 __asm__ ("r6") = (long) arg3; \
461register long __sc7 __asm__ ("r7") = (long) arg4; \
462register long __sc0 __asm__ ("r0") = (long) arg5; \
463register long __sc1 __asm__ ("r1") = (long) arg6; \
464__asm__ __volatile__ (SYSCALL_ARG6 \
465 : "=z" (__sc0) \
466 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7), \
467 "r" (__sc3), "r" (__sc1) \
468 : "memory" ); \
469__syscall_return(type,__sc0); \
470}
471
472#define __ARCH_WANT_IPC_PARSE_VERSION 335#define __ARCH_WANT_IPC_PARSE_VERSION
473#define __ARCH_WANT_OLD_READDIR 336#define __ARCH_WANT_OLD_READDIR
474#define __ARCH_WANT_OLD_STAT 337#define __ARCH_WANT_OLD_STAT
diff --git a/include/asm-sh64/dma-mapping.h b/include/asm-sh64/dma-mapping.h
index 68e27a8fca31..5efe906c59f7 100644
--- a/include/asm-sh64/dma-mapping.h
+++ b/include/asm-sh64/dma-mapping.h
@@ -35,7 +35,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size,
35 consistent_free(NULL, size, vaddr, dma_handle); 35 consistent_free(NULL, size, vaddr, dma_handle);
36} 36}
37 37
38static inline void dma_cache_sync(void *vaddr, size_t size, 38static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
39 enum dma_data_direction dir) 39 enum dma_data_direction dir)
40{ 40{
41 dma_cache_wback_inv((unsigned long)vaddr, size); 41 dma_cache_wback_inv((unsigned long)vaddr, size);
diff --git a/include/asm-sh64/setup.h b/include/asm-sh64/setup.h
index ebd42eb1b709..5b07b14c2927 100644
--- a/include/asm-sh64/setup.h
+++ b/include/asm-sh64/setup.h
@@ -1,6 +1,10 @@
1#ifndef __ASM_SH64_SETUP_H 1#ifndef __ASM_SH64_SETUP_H
2#define __ASM_SH64_SETUP_H 2#define __ASM_SH64_SETUP_H
3 3
4#define COMMAND_LINE_SIZE 256
5
6#ifdef __KERNEL__
7
4#define PARAM ((unsigned char *)empty_zero_page) 8#define PARAM ((unsigned char *)empty_zero_page)
5#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000)) 9#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
6#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004)) 10#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
@@ -12,5 +16,7 @@
12#define COMMAND_LINE ((char *) (PARAM+256)) 16#define COMMAND_LINE ((char *) (PARAM+256))
13#define COMMAND_LINE_SIZE 256 17#define COMMAND_LINE_SIZE 256
14 18
19#endif /* __KERNEL__ */
20
15#endif /* __ASM_SH64_SETUP_H */ 21#endif /* __ASM_SH64_SETUP_H */
16 22
diff --git a/include/asm-sh64/unistd.h b/include/asm-sh64/unistd.h
index ee7828b27ad1..1f38a7aacaaf 100644
--- a/include/asm-sh64/unistd.h
+++ b/include/asm-sh64/unistd.h
@@ -347,148 +347,6 @@
347#ifdef __KERNEL__ 347#ifdef __KERNEL__
348 348
349#define NR_syscalls 321 349#define NR_syscalls 321
350#include <linux/err.h>
351
352/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
353 * see <asm-sh64/errno.h> */
354
355#define __syscall_return(type, res) \
356do { \
357 /* Note: when returning from kernel the return value is in r9 \
358 ** This prevents conflicts between return value and arg1 \
359 ** when dispatching signal handler, in other words makes \
360 ** life easier in the system call epilogue (see entry.S) \
361 */ \
362 register unsigned long __sr2 __asm__ ("r2") = res; \
363 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
364 errno = -(res); \
365 __sr2 = -1; \
366 } \
367 return (type) (__sr2); \
368} while (0)
369
370/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
371
372#define _syscall0(type,name) \
373type name(void) \
374{ \
375register unsigned long __sc0 __asm__ ("r9") = ((0x10 << 16) | __NR_##name); \
376__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "()" \
377 : "=r" (__sc0) \
378 : "r" (__sc0) ); \
379__syscall_return(type,__sc0); \
380}
381
382 /*
383 * The apparent spurious "dummy" assembler comment is *needed*,
384 * as without it, the compiler treats the arg<n> variables
385 * as no longer live just before the asm. The compiler can
386 * then optimize the storage into any registers it wishes.
387 * The additional dummy statement forces the compiler to put
388 * the arguments into the correct registers before the TRAPA.
389 */
390#define _syscall1(type,name,type1,arg1) \
391type name(type1 arg1) \
392{ \
393register unsigned long __sc0 __asm__ ("r9") = ((0x11 << 16) | __NR_##name); \
394register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
395__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2)" \
396 : "=r" (__sc0) \
397 : "r" (__sc0), "r" (__sc2)); \
398__asm__ __volatile__ ("!dummy %0 %1" \
399 : \
400 : "r" (__sc0), "r" (__sc2)); \
401__syscall_return(type,__sc0); \
402}
403
404#define _syscall2(type,name,type1,arg1,type2,arg2) \
405type name(type1 arg1,type2 arg2) \
406{ \
407register unsigned long __sc0 __asm__ ("r9") = ((0x12 << 16) | __NR_##name); \
408register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
409register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
410__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3)" \
411 : "=r" (__sc0) \
412 : "r" (__sc0), "r" (__sc2), "r" (__sc3) ); \
413__asm__ __volatile__ ("!dummy %0 %1 %2" \
414 : \
415 : "r" (__sc0), "r" (__sc2), "r" (__sc3) ); \
416__syscall_return(type,__sc0); \
417}
418
419#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
420type name(type1 arg1,type2 arg2,type3 arg3) \
421{ \
422register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_##name); \
423register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
424register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
425register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
426__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4)" \
427 : "=r" (__sc0) \
428 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) ); \
429__asm__ __volatile__ ("!dummy %0 %1 %2 %3" \
430 : \
431 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) ); \
432__syscall_return(type,__sc0); \
433}
434
435#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
436type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
437{ \
438register unsigned long __sc0 __asm__ ("r9") = ((0x14 << 16) | __NR_##name); \
439register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
440register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
441register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
442register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
443__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4,%5)" \
444 : "=r" (__sc0) \
445 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
446__asm__ __volatile__ ("!dummy %0 %1 %2 %3 %4" \
447 : \
448 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
449__syscall_return(type,__sc0); \
450}
451
452#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
453type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
454{ \
455register unsigned long __sc0 __asm__ ("r9") = ((0x15 << 16) | __NR_##name); \
456register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
457register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
458register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
459register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
460register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5; \
461__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4,%5,%6)" \
462 : "=r" (__sc0) \
463 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
464 "r" (__sc6)); \
465__asm__ __volatile__ ("!dummy %0 %1 %2 %3 %4 %5" \
466 : \
467 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
468 "r" (__sc6)); \
469__syscall_return(type,__sc0); \
470}
471
472#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
473type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
474{ \
475register unsigned long __sc0 __asm__ ("r9") = ((0x16 << 16) | __NR_##name); \
476register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1; \
477register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2; \
478register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3; \
479register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4; \
480register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5; \
481register unsigned long __sc7 __asm__ ("r7") = (unsigned long) arg6; \
482__asm__ __volatile__ ("trapa %1 !\t\t\t" #name "(%2,%3,%4,%5,%6,%7)" \
483 : "=r" (__sc0) \
484 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
485 "r" (__sc6), "r" (__sc7)); \
486__asm__ __volatile__ ("!dummy %0 %1 %2 %3 %4 %5 %6" \
487 : \
488 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5), \
489 "r" (__sc6), "r" (__sc7)); \
490__syscall_return(type,__sc0); \
491}
492 350
493#define __ARCH_WANT_IPC_PARSE_VERSION 351#define __ARCH_WANT_IPC_PARSE_VERSION
494#define __ARCH_WANT_OLD_READDIR 352#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
index f7827fa4cd5e..d5b2f8053b3b 100644
--- a/include/asm-sparc/unistd.h
+++ b/include/asm-sparc/unistd.h
@@ -329,136 +329,6 @@
329 * find a free slot in the 0-302 range. 329 * find a free slot in the 0-302 range.
330 */ 330 */
331 331
332#define _syscall0(type,name) \
333type name(void) \
334{ \
335long __res; \
336register long __g1 __asm__ ("g1") = __NR_##name; \
337__asm__ __volatile__ ("t 0x10\n\t" \
338 "bcc 1f\n\t" \
339 "mov %%o0, %0\n\t" \
340 "sub %%g0, %%o0, %0\n\t" \
341 "1:\n\t" \
342 : "=r" (__res)\
343 : "r" (__g1) \
344 : "o0", "cc"); \
345if (__res < -255 || __res >= 0) \
346 return (type) __res; \
347errno = -__res; \
348return -1; \
349}
350
351#define _syscall1(type,name,type1,arg1) \
352type name(type1 arg1) \
353{ \
354long __res; \
355register long __g1 __asm__ ("g1") = __NR_##name; \
356register long __o0 __asm__ ("o0") = (long)(arg1); \
357__asm__ __volatile__ ("t 0x10\n\t" \
358 "bcc 1f\n\t" \
359 "mov %%o0, %0\n\t" \
360 "sub %%g0, %%o0, %0\n\t" \
361 "1:\n\t" \
362 : "=r" (__res), "=&r" (__o0) \
363 : "1" (__o0), "r" (__g1) \
364 : "cc"); \
365if (__res < -255 || __res >= 0) \
366 return (type) __res; \
367errno = -__res; \
368return -1; \
369}
370
371#define _syscall2(type,name,type1,arg1,type2,arg2) \
372type name(type1 arg1,type2 arg2) \
373{ \
374long __res; \
375register long __g1 __asm__ ("g1") = __NR_##name; \
376register long __o0 __asm__ ("o0") = (long)(arg1); \
377register long __o1 __asm__ ("o1") = (long)(arg2); \
378__asm__ __volatile__ ("t 0x10\n\t" \
379 "bcc 1f\n\t" \
380 "mov %%o0, %0\n\t" \
381 "sub %%g0, %%o0, %0\n\t" \
382 "1:\n\t" \
383 : "=r" (__res), "=&r" (__o0) \
384 : "1" (__o0), "r" (__o1), "r" (__g1) \
385 : "cc"); \
386if (__res < -255 || __res >= 0) \
387 return (type) __res; \
388errno = -__res; \
389return -1; \
390}
391
392#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
393type name(type1 arg1,type2 arg2,type3 arg3) \
394{ \
395long __res; \
396register long __g1 __asm__ ("g1") = __NR_##name; \
397register long __o0 __asm__ ("o0") = (long)(arg1); \
398register long __o1 __asm__ ("o1") = (long)(arg2); \
399register long __o2 __asm__ ("o2") = (long)(arg3); \
400__asm__ __volatile__ ("t 0x10\n\t" \
401 "bcc 1f\n\t" \
402 "mov %%o0, %0\n\t" \
403 "sub %%g0, %%o0, %0\n\t" \
404 "1:\n\t" \
405 : "=r" (__res), "=&r" (__o0) \
406 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
407 : "cc"); \
408if (__res < -255 || __res>=0) \
409 return (type) __res; \
410errno = -__res; \
411return -1; \
412}
413
414#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
415type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
416{ \
417long __res; \
418register long __g1 __asm__ ("g1") = __NR_##name; \
419register long __o0 __asm__ ("o0") = (long)(arg1); \
420register long __o1 __asm__ ("o1") = (long)(arg2); \
421register long __o2 __asm__ ("o2") = (long)(arg3); \
422register long __o3 __asm__ ("o3") = (long)(arg4); \
423__asm__ __volatile__ ("t 0x10\n\t" \
424 "bcc 1f\n\t" \
425 "mov %%o0, %0\n\t" \
426 "sub %%g0, %%o0, %0\n\t" \
427 "1:\n\t" \
428 : "=r" (__res), "=&r" (__o0) \
429 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
430 : "cc"); \
431if (__res < -255 || __res>=0) \
432 return (type) __res; \
433errno = -__res; \
434return -1; \
435}
436
437#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
438 type5,arg5) \
439type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
440{ \
441long __res; \
442register long __g1 __asm__ ("g1") = __NR_##name; \
443register long __o0 __asm__ ("o0") = (long)(arg1); \
444register long __o1 __asm__ ("o1") = (long)(arg2); \
445register long __o2 __asm__ ("o2") = (long)(arg3); \
446register long __o3 __asm__ ("o3") = (long)(arg4); \
447register long __o4 __asm__ ("o4") = (long)(arg5); \
448__asm__ __volatile__ ("t 0x10\n\t" \
449 "bcc 1f\n\t" \
450 "mov %%o0, %0\n\t" \
451 "sub %%g0, %%o0, %0\n\t" \
452 "1:\n\t" \
453 : "=r" (__res), "=&r" (__o0) \
454 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
455 : "cc"); \
456if (__res < -255 || __res>=0) \
457 return (type) __res; \
458errno = -__res; \
459return -1; \
460}
461
462#define __ARCH_WANT_IPC_PARSE_VERSION 332#define __ARCH_WANT_IPC_PARSE_VERSION
463#define __ARCH_WANT_OLD_READDIR 333#define __ARCH_WANT_OLD_READDIR
464#define __ARCH_WANT_STAT64 334#define __ARCH_WANT_STAT64
diff --git a/include/asm-sparc64/dma-mapping.h b/include/asm-sparc64/dma-mapping.h
index 27c46fbeebd6..2f858a2df94a 100644
--- a/include/asm-sparc64/dma-mapping.h
+++ b/include/asm-sparc64/dma-mapping.h
@@ -181,7 +181,7 @@ dma_sync_single_for_device(struct device *dev, dma_addr_t dma_handle, size_t siz
181 181
182#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 182#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
183#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 183#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
184#define dma_is_consistent(d) (1) 184#define dma_is_consistent(d, h) (1)
185 185
186static inline int 186static inline int
187dma_get_cache_alignment(void) 187dma_get_cache_alignment(void)
@@ -210,7 +210,7 @@ dma_sync_single_range_for_device(struct device *dev, dma_addr_t dma_handle,
210} 210}
211 211
212static inline void 212static inline void
213dma_cache_sync(void *vaddr, size_t size, 213dma_cache_sync(struct device *dev, void *vaddr, size_t size,
214 enum dma_data_direction direction) 214 enum dma_data_direction direction)
215{ 215{
216 /* could define this in terms of the dma_cache ... operations, 216 /* could define this in terms of the dma_cache ... operations,
diff --git a/include/asm-sparc64/futex.h b/include/asm-sparc64/futex.h
index 7392fc4a954e..876312fe82cc 100644
--- a/include/asm-sparc64/futex.h
+++ b/include/asm-sparc64/futex.h
@@ -45,7 +45,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
45 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 45 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
46 oparg = 1 << oparg; 46 oparg = 1 << oparg;
47 47
48 inc_preempt_count(); 48 pagefault_disable();
49 49
50 switch (op) { 50 switch (op) {
51 case FUTEX_OP_SET: 51 case FUTEX_OP_SET:
@@ -67,7 +67,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
67 ret = -ENOSYS; 67 ret = -ENOSYS;
68 } 68 }
69 69
70 dec_preempt_count(); 70 pagefault_enable();
71 71
72 if (!ret) { 72 if (!ret) {
73 switch (cmp) { 73 switch (cmp) {
diff --git a/include/asm-sparc64/pgalloc.h b/include/asm-sparc64/pgalloc.h
index 010f9cd0a672..5891ff7ba760 100644
--- a/include/asm-sparc64/pgalloc.h
+++ b/include/asm-sparc64/pgalloc.h
@@ -13,7 +13,7 @@
13#include <asm/page.h> 13#include <asm/page.h>
14 14
15/* Page table allocation/freeing. */ 15/* Page table allocation/freeing. */
16extern kmem_cache_t *pgtable_cache; 16extern struct kmem_cache *pgtable_cache;
17 17
18static inline pgd_t *pgd_alloc(struct mm_struct *mm) 18static inline pgd_t *pgd_alloc(struct mm_struct *mm)
19{ 19{
diff --git a/include/asm-sparc64/unistd.h b/include/asm-sparc64/unistd.h
index 63669dad0d72..47047536f261 100644
--- a/include/asm-sparc64/unistd.h
+++ b/include/asm-sparc64/unistd.h
@@ -332,124 +332,6 @@
332 * find a free slot in the 0-302 range. 332 * find a free slot in the 0-302 range.
333 */ 333 */
334 334
335#define _syscall0(type,name) \
336type name(void) \
337{ \
338long __res; \
339register long __g1 __asm__ ("g1") = __NR_##name; \
340__asm__ __volatile__ ("t 0x6d\n\t" \
341 "sub %%g0, %%o0, %0\n\t" \
342 "movcc %%xcc, %%o0, %0\n\t" \
343 : "=r" (__res)\
344 : "r" (__g1) \
345 : "o0", "cc"); \
346if (__res >= 0) \
347 return (type) __res; \
348errno = -__res; \
349return -1; \
350}
351
352#define _syscall1(type,name,type1,arg1) \
353type name(type1 arg1) \
354{ \
355long __res; \
356register long __g1 __asm__ ("g1") = __NR_##name; \
357register long __o0 __asm__ ("o0") = (long)(arg1); \
358__asm__ __volatile__ ("t 0x6d\n\t" \
359 "sub %%g0, %%o0, %0\n\t" \
360 "movcc %%xcc, %%o0, %0\n\t" \
361 : "=r" (__res), "=&r" (__o0) \
362 : "1" (__o0), "r" (__g1) \
363 : "cc"); \
364if (__res >= 0) \
365 return (type) __res; \
366errno = -__res; \
367return -1; \
368}
369
370#define _syscall2(type,name,type1,arg1,type2,arg2) \
371type name(type1 arg1,type2 arg2) \
372{ \
373long __res; \
374register long __g1 __asm__ ("g1") = __NR_##name; \
375register long __o0 __asm__ ("o0") = (long)(arg1); \
376register long __o1 __asm__ ("o1") = (long)(arg2); \
377__asm__ __volatile__ ("t 0x6d\n\t" \
378 "sub %%g0, %%o0, %0\n\t" \
379 "movcc %%xcc, %%o0, %0\n\t" \
380 : "=r" (__res), "=&r" (__o0) \
381 : "1" (__o0), "r" (__o1), "r" (__g1) \
382 : "cc"); \
383if (__res >= 0) \
384 return (type) __res; \
385errno = -__res; \
386return -1; \
387}
388
389#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
390type name(type1 arg1,type2 arg2,type3 arg3) \
391{ \
392long __res; \
393register long __g1 __asm__ ("g1") = __NR_##name; \
394register long __o0 __asm__ ("o0") = (long)(arg1); \
395register long __o1 __asm__ ("o1") = (long)(arg2); \
396register long __o2 __asm__ ("o2") = (long)(arg3); \
397__asm__ __volatile__ ("t 0x6d\n\t" \
398 "sub %%g0, %%o0, %0\n\t" \
399 "movcc %%xcc, %%o0, %0\n\t" \
400 : "=r" (__res), "=&r" (__o0) \
401 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
402 : "cc"); \
403if (__res>=0) \
404 return (type) __res; \
405errno = -__res; \
406return -1; \
407}
408
409#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
410type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
411{ \
412long __res; \
413register long __g1 __asm__ ("g1") = __NR_##name; \
414register long __o0 __asm__ ("o0") = (long)(arg1); \
415register long __o1 __asm__ ("o1") = (long)(arg2); \
416register long __o2 __asm__ ("o2") = (long)(arg3); \
417register long __o3 __asm__ ("o3") = (long)(arg4); \
418__asm__ __volatile__ ("t 0x6d\n\t" \
419 "sub %%g0, %%o0, %0\n\t" \
420 "movcc %%xcc, %%o0, %0\n\t" \
421 : "=r" (__res), "=&r" (__o0) \
422 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
423 : "cc"); \
424if (__res>=0) \
425 return (type) __res; \
426errno = -__res; \
427return -1; \
428}
429
430#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
431 type5,arg5) \
432type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
433{ \
434long __res; \
435register long __g1 __asm__ ("g1") = __NR_##name; \
436register long __o0 __asm__ ("o0") = (long)(arg1); \
437register long __o1 __asm__ ("o1") = (long)(arg2); \
438register long __o2 __asm__ ("o2") = (long)(arg3); \
439register long __o3 __asm__ ("o3") = (long)(arg4); \
440register long __o4 __asm__ ("o4") = (long)(arg5); \
441__asm__ __volatile__ ("t 0x6d\n\t" \
442 "sub %%g0, %%o0, %0\n\t" \
443 "movcc %%xcc, %%o0, %0\n\t" \
444 : "=r" (__res), "=&r" (__o0) \
445 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
446 : "cc"); \
447if (__res>=0) \
448 return (type) __res; \
449errno = -__res; \
450return -1; \
451}
452
453/* sysconf options, for SunOS compatibility */ 335/* sysconf options, for SunOS compatibility */
454#define _SC_ARG_MAX 1 336#define _SC_ARG_MAX 1
455#define _SC_CHILD_MAX 2 337#define _SC_CHILD_MAX 2
diff --git a/include/asm-um/dma-mapping.h b/include/asm-um/dma-mapping.h
index babd29895114..f0ee4fb55911 100644
--- a/include/asm-um/dma-mapping.h
+++ b/include/asm-um/dma-mapping.h
@@ -94,7 +94,7 @@ dma_sync_sg(struct device *dev, struct scatterlist *sg, int nelems,
94 94
95#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 95#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
96#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 96#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
97#define dma_is_consistent(d) (1) 97#define dma_is_consistent(d, h) (1)
98 98
99static inline int 99static inline int
100dma_get_cache_alignment(void) 100dma_get_cache_alignment(void)
@@ -112,7 +112,7 @@ dma_sync_single_range(struct device *dev, dma_addr_t dma_handle,
112} 112}
113 113
114static inline void 114static inline void
115dma_cache_sync(void *vaddr, size_t size, 115dma_cache_sync(struct device *dev, void *vaddr, size_t size,
116 enum dma_data_direction direction) 116 enum dma_data_direction direction)
117{ 117{
118 BUG(); 118 BUG();
diff --git a/include/asm-v850/irq.h b/include/asm-v850/irq.h
index 1bf096db8f4c..88687c181f01 100644
--- a/include/asm-v850/irq.h
+++ b/include/asm-v850/irq.h
@@ -46,8 +46,6 @@ extern void
46init_irq_handlers (int base_irq, int num, int interval, 46init_irq_handlers (int base_irq, int num, int interval,
47 struct hw_interrupt_type *irq_type); 47 struct hw_interrupt_type *irq_type);
48 48
49typedef void (*irq_handler_t)(int irq, void *data, struct pt_regs *regs);
50
51/* Handle interrupt IRQ. REGS are the registers at the time of ther 49/* Handle interrupt IRQ. REGS are the registers at the time of ther
52 interrupt. */ 50 interrupt. */
53extern unsigned int handle_irq (int irq, struct pt_regs *regs); 51extern unsigned int handle_irq (int irq, struct pt_regs *regs);
diff --git a/include/asm-v850/unistd.h b/include/asm-v850/unistd.h
index 737401e7d3ad..2241ed45ecfe 100644
--- a/include/asm-v850/unistd.h
+++ b/include/asm-v850/unistd.h
@@ -204,168 +204,8 @@
204#define __NR_gettid 201 204#define __NR_gettid 201
205#define __NR_tkill 202 205#define __NR_tkill 202
206 206
207
208/* Syscall protocol:
209 Syscall number in r12, args in r6-r9, r13-r14
210 Return value in r10
211 Trap 0 for `short' syscalls, where all the args can fit in function
212 call argument registers, and trap 1 when there are additional args in
213 r13-r14. */
214
215#define SYSCALL_NUM "r12"
216#define SYSCALL_ARG0 "r6"
217#define SYSCALL_ARG1 "r7"
218#define SYSCALL_ARG2 "r8"
219#define SYSCALL_ARG3 "r9"
220#define SYSCALL_ARG4 "r13"
221#define SYSCALL_ARG5 "r14"
222#define SYSCALL_RET "r10"
223
224#define SYSCALL_SHORT_TRAP "0"
225#define SYSCALL_LONG_TRAP "1"
226
227/* Registers clobbered by any syscall. This _doesn't_ include the syscall
228 number (r12) or the `extended arg' registers (r13, r14), even though
229 they are actually clobbered too (this is because gcc's `asm' statement
230 doesn't allow a clobber to be used as an input or output). */
231#define SYSCALL_CLOBBERS "r1", "r5", "r11", "r15", "r16", \
232 "r17", "r18", "r19"
233
234/* Registers clobbered by a `short' syscall. This includes all clobbers
235 except the syscall number (r12). */
236#define SYSCALL_SHORT_CLOBBERS SYSCALL_CLOBBERS, "r13", "r14"
237
238#ifdef __KERNEL__ 207#ifdef __KERNEL__
239 208
240#include <asm/clinkage.h>
241#include <linux/err.h>
242
243#define __syscall_return(type, res) \
244 do { \
245 /* user-visible error numbers are in the range -1 - -MAX_ERRNO: \
246 see <asm-v850/errno.h> */ \
247 if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO), 0)) { \
248 errno = -(res); \
249 res = -1; \
250 } \
251 return (type) (res); \
252 } while (0)
253
254
255#define _syscall0(type, name) \
256type name (void) \
257{ \
258 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
259 register unsigned long __ret __asm__ (SYSCALL_RET); \
260 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
261 : "=r" (__ret), "=r" (__syscall) \
262 : "1" (__syscall) \
263 : SYSCALL_SHORT_CLOBBERS); \
264 __syscall_return (type, __ret); \
265}
266
267#define _syscall1(type, name, atype, a) \
268type name (atype a) \
269{ \
270 register atype __a __asm__ (SYSCALL_ARG0) = a; \
271 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
272 register unsigned long __ret __asm__ (SYSCALL_RET); \
273 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
274 : "=r" (__ret), "=r" (__syscall) \
275 : "1" (__syscall), "r" (__a) \
276 : SYSCALL_SHORT_CLOBBERS); \
277 __syscall_return (type, __ret); \
278}
279
280#define _syscall2(type, name, atype, a, btype, b) \
281type name (atype a, btype b) \
282{ \
283 register atype __a __asm__ (SYSCALL_ARG0) = a; \
284 register btype __b __asm__ (SYSCALL_ARG1) = b; \
285 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
286 register unsigned long __ret __asm__ (SYSCALL_RET); \
287 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
288 : "=r" (__ret), "=r" (__syscall) \
289 : "1" (__syscall), "r" (__a), "r" (__b) \
290 : SYSCALL_SHORT_CLOBBERS); \
291 __syscall_return (type, __ret); \
292}
293
294#define _syscall3(type, name, atype, a, btype, b, ctype, c) \
295type name (atype a, btype b, ctype c) \
296{ \
297 register atype __a __asm__ (SYSCALL_ARG0) = a; \
298 register btype __b __asm__ (SYSCALL_ARG1) = b; \
299 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
300 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
301 register unsigned long __ret __asm__ (SYSCALL_RET); \
302 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
303 : "=r" (__ret), "=r" (__syscall) \
304 : "1" (__syscall), "r" (__a), "r" (__b), "r" (__c) \
305 : SYSCALL_SHORT_CLOBBERS); \
306 __syscall_return (type, __ret); \
307}
308
309#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
310type name (atype a, btype b, ctype c, dtype d) \
311{ \
312 register atype __a __asm__ (SYSCALL_ARG0) = a; \
313 register btype __b __asm__ (SYSCALL_ARG1) = b; \
314 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
315 register dtype __d __asm__ (SYSCALL_ARG3) = d; \
316 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
317 register unsigned long __ret __asm__ (SYSCALL_RET); \
318 __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP \
319 : "=r" (__ret), "=r" (__syscall) \
320 : "1" (__syscall), \
321 "r" (__a), "r" (__b), "r" (__c), "r" (__d) \
322 : SYSCALL_SHORT_CLOBBERS); \
323 __syscall_return (type, __ret); \
324}
325
326#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype,e)\
327type name (atype a, btype b, ctype c, dtype d, etype e) \
328{ \
329 register atype __a __asm__ (SYSCALL_ARG0) = a; \
330 register btype __b __asm__ (SYSCALL_ARG1) = b; \
331 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
332 register dtype __d __asm__ (SYSCALL_ARG3) = d; \
333 register etype __e __asm__ (SYSCALL_ARG4) = e; \
334 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
335 register unsigned long __ret __asm__ (SYSCALL_RET); \
336 __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP \
337 : "=r" (__ret), "=r" (__syscall), "=r" (__e) \
338 : "1" (__syscall), \
339 "r" (__a), "r" (__b), "r" (__c), "r" (__d), "2" (__e) \
340 : SYSCALL_CLOBBERS); \
341 __syscall_return (type, __ret); \
342}
343
344#define __SYSCALL6_TRAP(syscall, ret, a, b, c, d, e, f) \
345 __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP \
346 : "=r" (ret), "=r" (syscall), \
347 "=r" (e), "=r" (f) \
348 : "1" (syscall), \
349 "r" (a), "r" (b), "r" (c), "r" (d), \
350 "2" (e), "3" (f) \
351 : SYSCALL_CLOBBERS);
352
353#define _syscall6(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \
354type name (atype a, btype b, ctype c, dtype d, etype e, ftype f) \
355{ \
356 register atype __a __asm__ (SYSCALL_ARG0) = a; \
357 register btype __b __asm__ (SYSCALL_ARG1) = b; \
358 register ctype __c __asm__ (SYSCALL_ARG2) = c; \
359 register dtype __d __asm__ (SYSCALL_ARG3) = d; \
360 register etype __e __asm__ (SYSCALL_ARG4) = e; \
361 register etype __f __asm__ (SYSCALL_ARG5) = f; \
362 register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name; \
363 register unsigned long __ret __asm__ (SYSCALL_RET); \
364 __SYSCALL6_TRAP(__syscall, __ret, __a, __b, __c, __d, __e, __f); \
365 __syscall_return (type, __ret); \
366}
367
368
369#define __ARCH_WANT_IPC_PARSE_VERSION 209#define __ARCH_WANT_IPC_PARSE_VERSION
370#define __ARCH_WANT_OLD_READDIR 210#define __ARCH_WANT_OLD_READDIR
371#define __ARCH_WANT_STAT64 211#define __ARCH_WANT_STAT64
diff --git a/include/asm-x86_64/Kbuild b/include/asm-x86_64/Kbuild
index 1ee9b07f3fe6..ebd7117782a6 100644
--- a/include/asm-x86_64/Kbuild
+++ b/include/asm-x86_64/Kbuild
@@ -6,13 +6,11 @@ ALTARCHDEF := defined __i386__
6 6
7header-y += boot.h 7header-y += boot.h
8header-y += bootsetup.h 8header-y += bootsetup.h
9header-y += cpufeature.h
10header-y += debugreg.h 9header-y += debugreg.h
11header-y += ldt.h 10header-y += ldt.h
12header-y += msr.h 11header-y += msr.h
13header-y += prctl.h 12header-y += prctl.h
14header-y += ptrace-abi.h 13header-y += ptrace-abi.h
15header-y += setup.h
16header-y += sigcontext32.h 14header-y += sigcontext32.h
17header-y += ucontext.h 15header-y += ucontext.h
18header-y += vsyscall32.h 16header-y += vsyscall32.h
diff --git a/include/asm-x86_64/alternative.h b/include/asm-x86_64/alternative.h
index a584826cc570..a6657b4f3e0e 100644
--- a/include/asm-x86_64/alternative.h
+++ b/include/asm-x86_64/alternative.h
@@ -4,6 +4,7 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/stddef.h>
7#include <asm/cpufeature.h> 8#include <asm/cpufeature.h>
8 9
9struct alt_instr { 10struct alt_instr {
@@ -133,4 +134,15 @@ static inline void alternatives_smp_switch(int smp) {}
133#define LOCK_PREFIX "" 134#define LOCK_PREFIX ""
134#endif 135#endif
135 136
137struct paravirt_patch;
138#ifdef CONFIG_PARAVIRT
139void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end);
140#else
141static inline void
142apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
143{}
144#define __start_parainstructions NULL
145#define __stop_parainstructions NULL
146#endif
147
136#endif /* _X86_64_ALTERNATIVE_H */ 148#endif /* _X86_64_ALTERNATIVE_H */
diff --git a/include/asm-x86_64/atomic.h b/include/asm-x86_64/atomic.h
index 93849f7abc24..706ca4b60000 100644
--- a/include/asm-x86_64/atomic.h
+++ b/include/asm-x86_64/atomic.h
@@ -189,9 +189,9 @@ static __inline__ int atomic_add_return(int i, atomic_t *v)
189{ 189{
190 int __i = i; 190 int __i = i;
191 __asm__ __volatile__( 191 __asm__ __volatile__(
192 LOCK_PREFIX "xaddl %0, %1;" 192 LOCK_PREFIX "xaddl %0, %1"
193 :"=r"(i) 193 :"+r" (i), "+m" (v->counter)
194 :"m"(v->counter), "0"(i)); 194 : : "memory");
195 return i + __i; 195 return i + __i;
196} 196}
197 197
diff --git a/include/asm-x86_64/calgary.h b/include/asm-x86_64/calgary.h
index 6b93f5a3a5c8..7ee900645719 100644
--- a/include/asm-x86_64/calgary.h
+++ b/include/asm-x86_64/calgary.h
@@ -51,6 +51,8 @@ struct iommu_table {
51#define TCE_TABLE_SIZE_4M 6 51#define TCE_TABLE_SIZE_4M 6
52#define TCE_TABLE_SIZE_8M 7 52#define TCE_TABLE_SIZE_8M 7
53 53
54extern int use_calgary;
55
54#ifdef CONFIG_CALGARY_IOMMU 56#ifdef CONFIG_CALGARY_IOMMU
55extern int calgary_iommu_init(void); 57extern int calgary_iommu_init(void);
56extern void detect_calgary(void); 58extern void detect_calgary(void);
diff --git a/include/asm-x86_64/cpufeature.h b/include/asm-x86_64/cpufeature.h
index ee792faaca01..0b3c686139f1 100644
--- a/include/asm-x86_64/cpufeature.h
+++ b/include/asm-x86_64/cpufeature.h
@@ -29,7 +29,7 @@
29#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */ 29#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */
30#define X86_FEATURE_PN (0*32+18) /* Processor serial number */ 30#define X86_FEATURE_PN (0*32+18) /* Processor serial number */
31#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */ 31#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */
32#define X86_FEATURE_DTES (0*32+21) /* Debug Trace Store */ 32#define X86_FEATURE_DS (0*32+21) /* Debug Store */
33#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */ 33#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */
34#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */ 34#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
35#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */ 35#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
@@ -68,6 +68,8 @@
68#define X86_FEATURE_FXSAVE_LEAK (3*32+7) /* FIP/FOP/FDP leaks through FXSAVE */ 68#define X86_FEATURE_FXSAVE_LEAK (3*32+7) /* FIP/FOP/FDP leaks through FXSAVE */
69#define X86_FEATURE_UP (3*32+8) /* SMP kernel running on UP */ 69#define X86_FEATURE_UP (3*32+8) /* SMP kernel running on UP */
70#define X86_FEATURE_ARCH_PERFMON (3*32+9) /* Intel Architectural PerfMon */ 70#define X86_FEATURE_ARCH_PERFMON (3*32+9) /* Intel Architectural PerfMon */
71#define X86_FEATURE_PEBS (3*32+10) /* Precise-Event Based Sampling */
72#define X86_FEATURE_BTS (3*32+11) /* Branch Trace Store */
71 73
72/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */ 74/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
73#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */ 75#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
@@ -112,5 +114,8 @@
112#define cpu_has_cyrix_arr 0 114#define cpu_has_cyrix_arr 0
113#define cpu_has_centaur_mcr 0 115#define cpu_has_centaur_mcr 0
114#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH) 116#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
117#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
118#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
119#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
115 120
116#endif /* __ASM_X8664_CPUFEATURE_H */ 121#endif /* __ASM_X8664_CPUFEATURE_H */
diff --git a/include/asm-x86_64/delay.h b/include/asm-x86_64/delay.h
index 65f64acc5319..c2669f1f5529 100644
--- a/include/asm-x86_64/delay.h
+++ b/include/asm-x86_64/delay.h
@@ -7,18 +7,21 @@
7 * Delay routines calling functions in arch/x86_64/lib/delay.c 7 * Delay routines calling functions in arch/x86_64/lib/delay.c
8 */ 8 */
9 9
10/* Undefined functions to get compile-time errors */
10extern void __bad_udelay(void); 11extern void __bad_udelay(void);
11extern void __bad_ndelay(void); 12extern void __bad_ndelay(void);
12 13
13extern void __udelay(unsigned long usecs); 14extern void __udelay(unsigned long usecs);
14extern void __ndelay(unsigned long usecs); 15extern void __ndelay(unsigned long nsecs);
15extern void __const_udelay(unsigned long usecs); 16extern void __const_udelay(unsigned long usecs);
16extern void __delay(unsigned long loops); 17extern void __delay(unsigned long loops);
17 18
19/* 0x10c7 is 2**32 / 1000000 (rounded up) */
18#define udelay(n) (__builtin_constant_p(n) ? \ 20#define udelay(n) (__builtin_constant_p(n) ? \
19 ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \ 21 ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
20 __udelay(n)) 22 __udelay(n))
21 23
24/* 0x5 is 2**32 / 1000000000 (rounded up) */
22#define ndelay(n) (__builtin_constant_p(n) ? \ 25#define ndelay(n) (__builtin_constant_p(n) ? \
23 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ 26 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
24 __ndelay(n)) 27 __ndelay(n))
diff --git a/include/asm-x86_64/desc.h b/include/asm-x86_64/desc.h
index eb7723a46790..913d6ac00033 100644
--- a/include/asm-x86_64/desc.h
+++ b/include/asm-x86_64/desc.h
@@ -9,64 +9,13 @@
9 9
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/smp.h> 11#include <linux/smp.h>
12#include <asm/desc_defs.h>
12 13
13#include <asm/segment.h> 14#include <asm/segment.h>
14#include <asm/mmu.h> 15#include <asm/mmu.h>
15 16
16// 8 byte segment descriptor
17struct desc_struct {
18 u16 limit0;
19 u16 base0;
20 unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
21 unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8;
22} __attribute__((packed));
23
24struct n_desc_struct {
25 unsigned int a,b;
26};
27
28extern struct desc_struct cpu_gdt_table[GDT_ENTRIES]; 17extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
29 18
30enum {
31 GATE_INTERRUPT = 0xE,
32 GATE_TRAP = 0xF,
33 GATE_CALL = 0xC,
34};
35
36// 16byte gate
37struct gate_struct {
38 u16 offset_low;
39 u16 segment;
40 unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
41 u16 offset_middle;
42 u32 offset_high;
43 u32 zero1;
44} __attribute__((packed));
45
46#define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF)
47#define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF)
48#define PTR_HIGH(x) ((unsigned long)(x) >> 32)
49
50enum {
51 DESC_TSS = 0x9,
52 DESC_LDT = 0x2,
53};
54
55// LDT or TSS descriptor in the GDT. 16 bytes.
56struct ldttss_desc {
57 u16 limit0;
58 u16 base0;
59 unsigned base1 : 8, type : 5, dpl : 2, p : 1;
60 unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
61 u32 base3;
62 u32 zero1;
63} __attribute__((packed));
64
65struct desc_ptr {
66 unsigned short size;
67 unsigned long address;
68} __attribute__((packed)) ;
69
70#define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8)) 19#define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8))
71#define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8)) 20#define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8))
72#define clear_LDT() asm volatile("lldt %w0"::"r" (0)) 21#define clear_LDT() asm volatile("lldt %w0"::"r" (0))
diff --git a/include/asm-x86_64/desc_defs.h b/include/asm-x86_64/desc_defs.h
new file mode 100644
index 000000000000..089004070099
--- /dev/null
+++ b/include/asm-x86_64/desc_defs.h
@@ -0,0 +1,69 @@
1/* Written 2000 by Andi Kleen */
2#ifndef __ARCH_DESC_DEFS_H
3#define __ARCH_DESC_DEFS_H
4
5/*
6 * Segment descriptor structure definitions, usable from both x86_64 and i386
7 * archs.
8 */
9
10#ifndef __ASSEMBLY__
11
12#include <linux/types.h>
13
14// 8 byte segment descriptor
15struct desc_struct {
16 u16 limit0;
17 u16 base0;
18 unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
19 unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8;
20} __attribute__((packed));
21
22struct n_desc_struct {
23 unsigned int a,b;
24};
25
26enum {
27 GATE_INTERRUPT = 0xE,
28 GATE_TRAP = 0xF,
29 GATE_CALL = 0xC,
30};
31
32// 16byte gate
33struct gate_struct {
34 u16 offset_low;
35 u16 segment;
36 unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
37 u16 offset_middle;
38 u32 offset_high;
39 u32 zero1;
40} __attribute__((packed));
41
42#define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF)
43#define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF)
44#define PTR_HIGH(x) ((unsigned long)(x) >> 32)
45
46enum {
47 DESC_TSS = 0x9,
48 DESC_LDT = 0x2,
49};
50
51// LDT or TSS descriptor in the GDT. 16 bytes.
52struct ldttss_desc {
53 u16 limit0;
54 u16 base0;
55 unsigned base1 : 8, type : 5, dpl : 2, p : 1;
56 unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
57 u32 base3;
58 u32 zero1;
59} __attribute__((packed));
60
61struct desc_ptr {
62 unsigned short size;
63 unsigned long address;
64} __attribute__((packed)) ;
65
66
67#endif /* !__ASSEMBLY__ */
68
69#endif
diff --git a/include/asm-x86_64/dma-mapping.h b/include/asm-x86_64/dma-mapping.h
index 10174b110a5c..be9ec6890723 100644
--- a/include/asm-x86_64/dma-mapping.h
+++ b/include/asm-x86_64/dma-mapping.h
@@ -180,12 +180,13 @@ static inline int dma_get_cache_alignment(void)
180 return boot_cpu_data.x86_clflush_size; 180 return boot_cpu_data.x86_clflush_size;
181} 181}
182 182
183#define dma_is_consistent(h) 1 183#define dma_is_consistent(d, h) 1
184 184
185extern int dma_set_mask(struct device *dev, u64 mask); 185extern int dma_set_mask(struct device *dev, u64 mask);
186 186
187static inline void 187static inline void
188dma_cache_sync(void *vaddr, size_t size, enum dma_data_direction dir) 188dma_cache_sync(struct device *dev, void *vaddr, size_t size,
189 enum dma_data_direction dir)
189{ 190{
190 flush_write_buffers(); 191 flush_write_buffers();
191} 192}
diff --git a/include/asm-x86_64/futex.h b/include/asm-x86_64/futex.h
index 9804bf07b092..5cdfb08013c3 100644
--- a/include/asm-x86_64/futex.h
+++ b/include/asm-x86_64/futex.h
@@ -55,7 +55,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
55 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 55 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
56 return -EFAULT; 56 return -EFAULT;
57 57
58 inc_preempt_count(); 58 pagefault_disable();
59 59
60 switch (op) { 60 switch (op) {
61 case FUTEX_OP_SET: 61 case FUTEX_OP_SET:
@@ -78,7 +78,7 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
78 ret = -ENOSYS; 78 ret = -ENOSYS;
79 } 79 }
80 80
81 dec_preempt_count(); 81 pagefault_enable();
82 82
83 if (!ret) { 83 if (!ret) {
84 switch (cmp) { 84 switch (cmp) {
diff --git a/include/asm-x86_64/genapic.h b/include/asm-x86_64/genapic.h
index a0e9a4b93484..b80f4bb5f273 100644
--- a/include/asm-x86_64/genapic.h
+++ b/include/asm-x86_64/genapic.h
@@ -30,6 +30,6 @@ struct genapic {
30}; 30};
31 31
32 32
33extern struct genapic *genapic; 33extern struct genapic *genapic, *genapic_force, apic_flat;
34 34
35#endif 35#endif
diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
index 37e194169fac..952783d35c7b 100644
--- a/include/asm-x86_64/msr.h
+++ b/include/asm-x86_64/msr.h
@@ -169,8 +169,8 @@ static inline unsigned int cpuid_edx(unsigned int op)
169#define MSR_LSTAR 0xc0000082 /* long mode SYSCALL target */ 169#define MSR_LSTAR 0xc0000082 /* long mode SYSCALL target */
170#define MSR_CSTAR 0xc0000083 /* compatibility mode SYSCALL target */ 170#define MSR_CSTAR 0xc0000083 /* compatibility mode SYSCALL target */
171#define MSR_SYSCALL_MASK 0xc0000084 /* EFLAGS mask for syscall */ 171#define MSR_SYSCALL_MASK 0xc0000084 /* EFLAGS mask for syscall */
172#define MSR_FS_BASE 0xc0000100 /* 64bit GS base */ 172#define MSR_FS_BASE 0xc0000100 /* 64bit FS base */
173#define MSR_GS_BASE 0xc0000101 /* 64bit FS base */ 173#define MSR_GS_BASE 0xc0000101 /* 64bit GS base */
174#define MSR_KERNEL_GS_BASE 0xc0000102 /* SwapGS GS shadow (or USER_GS from kernel) */ 174#define MSR_KERNEL_GS_BASE 0xc0000102 /* SwapGS GS shadow (or USER_GS from kernel) */
175/* EFER bits: */ 175/* EFER bits: */
176#define _EFER_SCE 0 /* SYSCALL/SYSRET */ 176#define _EFER_SCE 0 /* SYSCALL/SYSRET */
@@ -210,6 +210,10 @@ static inline unsigned int cpuid_edx(unsigned int op)
210#define MSR_IA32_LASTINTFROMIP 0x1dd 210#define MSR_IA32_LASTINTFROMIP 0x1dd
211#define MSR_IA32_LASTINTTOIP 0x1de 211#define MSR_IA32_LASTINTTOIP 0x1de
212 212
213#define MSR_IA32_PEBS_ENABLE 0x3f1
214#define MSR_IA32_DS_AREA 0x600
215#define MSR_IA32_PERF_CAPABILITIES 0x345
216
213#define MSR_MTRRfix64K_00000 0x250 217#define MSR_MTRRfix64K_00000 0x250
214#define MSR_MTRRfix16K_80000 0x258 218#define MSR_MTRRfix16K_80000 0x258
215#define MSR_MTRRfix16K_A0000 0x259 219#define MSR_MTRRfix16K_A0000 0x259
@@ -407,4 +411,13 @@ static inline unsigned int cpuid_edx(unsigned int op)
407#define MSR_P4_U2L_ESCR0 0x3b0 411#define MSR_P4_U2L_ESCR0 0x3b0
408#define MSR_P4_U2L_ESCR1 0x3b1 412#define MSR_P4_U2L_ESCR1 0x3b1
409 413
414/* Intel Core-based CPU performance counters */
415#define MSR_CORE_PERF_FIXED_CTR0 0x309
416#define MSR_CORE_PERF_FIXED_CTR1 0x30a
417#define MSR_CORE_PERF_FIXED_CTR2 0x30b
418#define MSR_CORE_PERF_FIXED_CTR_CTRL 0x38d
419#define MSR_CORE_PERF_GLOBAL_STATUS 0x38e
420#define MSR_CORE_PERF_GLOBAL_CTRL 0x38f
421#define MSR_CORE_PERF_GLOBAL_OVF_CTRL 0x390
422
410#endif 423#endif
diff --git a/include/asm-x86_64/nmi.h b/include/asm-x86_64/nmi.h
index f367d4014b42..72375e7d32a8 100644
--- a/include/asm-x86_64/nmi.h
+++ b/include/asm-x86_64/nmi.h
@@ -77,4 +77,7 @@ extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
77 77
78extern int unknown_nmi_panic; 78extern int unknown_nmi_panic;
79 79
80void __trigger_all_cpu_backtrace(void);
81#define trigger_all_cpu_backtrace() __trigger_all_cpu_backtrace()
82
80#endif /* ASM_NMI_H */ 83#endif /* ASM_NMI_H */
diff --git a/include/asm-x86_64/pci-direct.h b/include/asm-x86_64/pci-direct.h
index eba9cb471df3..6823fa4f1afa 100644
--- a/include/asm-x86_64/pci-direct.h
+++ b/include/asm-x86_64/pci-direct.h
@@ -10,6 +10,7 @@ extern u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset);
10extern u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset); 10extern u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset);
11extern u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset); 11extern u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset);
12extern void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset, u32 val); 12extern void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset, u32 val);
13extern void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val);
13 14
14extern int early_pci_allowed(void); 15extern int early_pci_allowed(void);
15 16
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index 0555c1c4d8fa..59901c690a0d 100644
--- a/include/asm-x86_64/pgtable.h
+++ b/include/asm-x86_64/pgtable.h
@@ -221,20 +221,19 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long
221#define __S110 PAGE_SHARED_EXEC 221#define __S110 PAGE_SHARED_EXEC
222#define __S111 PAGE_SHARED_EXEC 222#define __S111 PAGE_SHARED_EXEC
223 223
224static inline unsigned long pgd_bad(pgd_t pgd) 224static inline unsigned long pgd_bad(pgd_t pgd)
225{ 225{
226 unsigned long val = pgd_val(pgd); 226 return pgd_val(pgd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
227 val &= ~PTE_MASK; 227}
228 val &= ~(_PAGE_USER | _PAGE_DIRTY);
229 return val & ~(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED);
230}
231 228
232static inline unsigned long pud_bad(pud_t pud) 229static inline unsigned long pud_bad(pud_t pud)
233{ 230{
234 unsigned long val = pud_val(pud); 231 return pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
235 val &= ~PTE_MASK; 232}
236 val &= ~(_PAGE_USER | _PAGE_DIRTY); 233
237 return val & ~(_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED); 234static inline unsigned long pmd_bad(pmd_t pmd)
235{
236 return pmd_val(pmd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
238} 237}
239 238
240#define pte_none(x) (!pte_val(x)) 239#define pte_none(x) (!pte_val(x))
@@ -347,7 +346,6 @@ static inline int pmd_large(pmd_t pte) {
347#define pmd_none(x) (!pmd_val(x)) 346#define pmd_none(x) (!pmd_val(x))
348#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 347#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
349#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0) 348#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
350#define pmd_bad(x) ((pmd_val(x) & (~PTE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE )
351#define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot))) 349#define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot)))
352#define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) 350#define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
353 351
diff --git a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
index cef17e0f828c..76552d72804c 100644
--- a/include/asm-x86_64/processor.h
+++ b/include/asm-x86_64/processor.h
@@ -475,6 +475,14 @@ static inline void __mwait(unsigned long eax, unsigned long ecx)
475 : :"a" (eax), "c" (ecx)); 475 : :"a" (eax), "c" (ecx));
476} 476}
477 477
478static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
479{
480 /* "mwait %eax,%ecx;" */
481 asm volatile(
482 "sti; .byte 0x0f,0x01,0xc9;"
483 : :"a" (eax), "c" (ecx));
484}
485
478extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx); 486extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
479 487
480#define stack_current() \ 488#define stack_current() \
diff --git a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h
index e72cfcdf5344..6d324b838972 100644
--- a/include/asm-x86_64/proto.h
+++ b/include/asm-x86_64/proto.h
@@ -61,7 +61,6 @@ extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn);
61extern unsigned long numa_free_all_bootmem(void); 61extern unsigned long numa_free_all_bootmem(void);
62 62
63extern void reserve_bootmem_generic(unsigned long phys, unsigned len); 63extern void reserve_bootmem_generic(unsigned long phys, unsigned len);
64extern void free_bootmem_generic(unsigned long phys, unsigned len);
65 64
66extern void load_gs_index(unsigned gs); 65extern void load_gs_index(unsigned gs);
67 66
@@ -88,6 +87,7 @@ extern void syscall32_cpu_init(void);
88extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long end); 87extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long end);
89 88
90extern void early_quirks(void); 89extern void early_quirks(void);
90extern void quirk_intel_irqbalance(void);
91extern void check_efer(void); 91extern void check_efer(void);
92 92
93extern int unhandled_signal(struct task_struct *tsk, int sig); 93extern int unhandled_signal(struct task_struct *tsk, int sig);
diff --git a/include/asm-x86_64/rio.h b/include/asm-x86_64/rio.h
new file mode 100644
index 000000000000..c7350f6d2015
--- /dev/null
+++ b/include/asm-x86_64/rio.h
@@ -0,0 +1,74 @@
1/*
2 * Derived from include/asm-i386/mach-summit/mach_mpparse.h
3 * and include/asm-i386/mach-default/bios_ebda.h
4 *
5 * Author: Laurent Vivier <Laurent.Vivier@bull.net>
6 */
7
8#ifndef __ASM_RIO_H
9#define __ASM_RIO_H
10
11#define RIO_TABLE_VERSION 3
12
13struct rio_table_hdr {
14 u8 version; /* Version number of this data structure */
15 u8 num_scal_dev; /* # of Scalability devices */
16 u8 num_rio_dev; /* # of RIO I/O devices */
17} __attribute__((packed));
18
19struct scal_detail {
20 u8 node_id; /* Scalability Node ID */
21 u32 CBAR; /* Address of 1MB register space */
22 u8 port0node; /* Node ID port connected to: 0xFF=None */
23 u8 port0port; /* Port num port connected to: 0,1,2, or */
24 /* 0xFF=None */
25 u8 port1node; /* Node ID port connected to: 0xFF = None */
26 u8 port1port; /* Port num port connected to: 0,1,2, or */
27 /* 0xFF=None */
28 u8 port2node; /* Node ID port connected to: 0xFF = None */
29 u8 port2port; /* Port num port connected to: 0,1,2, or */
30 /* 0xFF=None */
31 u8 chassis_num; /* 1 based Chassis number (1 = boot node) */
32} __attribute__((packed));
33
34struct rio_detail {
35 u8 node_id; /* RIO Node ID */
36 u32 BBAR; /* Address of 1MB register space */
37 u8 type; /* Type of device */
38 u8 owner_id; /* Node ID of Hurricane that owns this */
39 /* node */
40 u8 port0node; /* Node ID port connected to: 0xFF=None */
41 u8 port0port; /* Port num port connected to: 0,1,2, or */
42 /* 0xFF=None */
43 u8 port1node; /* Node ID port connected to: 0xFF=None */
44 u8 port1port; /* Port num port connected to: 0,1,2, or */
45 /* 0xFF=None */
46 u8 first_slot; /* Lowest slot number below this Calgary */
47 u8 status; /* Bit 0 = 1 : the XAPIC is used */
48 /* = 0 : the XAPIC is not used, ie: */
49 /* ints fwded to another XAPIC */
50 /* Bits1:7 Reserved */
51 u8 WP_index; /* instance index - lower ones have */
52 /* lower slot numbers/PCI bus numbers */
53 u8 chassis_num; /* 1 based Chassis number */
54} __attribute__((packed));
55
56enum {
57 HURR_SCALABILTY = 0, /* Hurricane Scalability info */
58 HURR_RIOIB = 2, /* Hurricane RIOIB info */
59 COMPAT_CALGARY = 4, /* Compatibility Calgary */
60 ALT_CALGARY = 5, /* Second Planar Calgary */
61};
62
63/*
64 * there is a real-mode segmented pointer pointing to the
65 * 4K EBDA area at 0x40E.
66 */
67static inline unsigned long get_bios_ebda(void)
68{
69 unsigned long address = *(unsigned short *)phys_to_virt(0x40EUL);
70 address <<= 4;
71 return address;
72}
73
74#endif /* __ASM_RIO_H */
diff --git a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
index d6b7c057edba..e17b9ec42e98 100644
--- a/include/asm-x86_64/smp.h
+++ b/include/asm-x86_64/smp.h
@@ -82,11 +82,6 @@ extern u8 x86_cpu_to_apicid[NR_CPUS]; /* physical ID */
82extern u8 x86_cpu_to_log_apicid[NR_CPUS]; 82extern u8 x86_cpu_to_log_apicid[NR_CPUS];
83extern u8 bios_cpu_apicid[]; 83extern u8 bios_cpu_apicid[];
84 84
85static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
86{
87 return cpus_addr(cpumask)[0];
88}
89
90static inline int cpu_present_to_apicid(int mps_cpu) 85static inline int cpu_present_to_apicid(int mps_cpu)
91{ 86{
92 if (mps_cpu < NR_CPUS) 87 if (mps_cpu < NR_CPUS)
@@ -118,13 +113,6 @@ static __inline int logical_smp_processor_id(void)
118#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu] 113#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
119#else 114#else
120#define cpu_physical_id(cpu) boot_cpu_id 115#define cpu_physical_id(cpu) boot_cpu_id
121static inline int smp_call_function_single(int cpuid, void (*func) (void *info),
122 void *info, int retry, int wait)
123{
124 /* Disable interrupts here? */
125 func(info);
126 return 0;
127}
128#endif /* !CONFIG_SMP */ 116#endif /* !CONFIG_SMP */
129#endif 117#endif
130 118
diff --git a/include/asm-x86_64/spinlock.h b/include/asm-x86_64/spinlock.h
index 05ef097ba55b..88bf981e73cf 100644
--- a/include/asm-x86_64/spinlock.h
+++ b/include/asm-x86_64/spinlock.h
@@ -36,7 +36,34 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)
36 "2:\t" : "=m" (lock->slock) : : "memory"); 36 "2:\t" : "=m" (lock->slock) : : "memory");
37} 37}
38 38
39#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) 39/*
40 * Same as __raw_spin_lock, but reenable interrupts during spinning.
41 */
42#ifndef CONFIG_PROVE_LOCKING
43static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
44{
45 asm volatile(
46 "\n1:\t"
47 LOCK_PREFIX " ; decl %0\n\t"
48 "jns 5f\n"
49 "testl $0x200, %1\n\t" /* interrupts were disabled? */
50 "jz 4f\n\t"
51 "sti\n"
52 "3:\t"
53 "rep;nop\n\t"
54 "cmpl $0, %0\n\t"
55 "jle 3b\n\t"
56 "cli\n\t"
57 "jmp 1b\n"
58 "4:\t"
59 "rep;nop\n\t"
60 "cmpl $0, %0\n\t"
61 "jg 1b\n\t"
62 "jmp 4b\n"
63 "5:\n\t"
64 : "+m" (lock->slock) : "r" ((unsigned)flags) : "memory");
65}
66#endif
40 67
41static inline int __raw_spin_trylock(raw_spinlock_t *lock) 68static inline int __raw_spin_trylock(raw_spinlock_t *lock)
42{ 69{
diff --git a/include/asm-x86_64/stacktrace.h b/include/asm-x86_64/stacktrace.h
index 5eb9799bef76..6f0b54594307 100644
--- a/include/asm-x86_64/stacktrace.h
+++ b/include/asm-x86_64/stacktrace.h
@@ -1,6 +1,8 @@
1#ifndef _ASM_STACKTRACE_H 1#ifndef _ASM_STACKTRACE_H
2#define _ASM_STACKTRACE_H 1 2#define _ASM_STACKTRACE_H 1
3 3
4extern int kstack_depth_to_print;
5
4/* Generic stack tracer with callbacks */ 6/* Generic stack tracer with callbacks */
5 7
6struct stacktrace_ops { 8struct stacktrace_ops {
diff --git a/include/asm-x86_64/unistd.h b/include/asm-x86_64/unistd.h
index 777288eb7e75..c5f596e71faa 100644
--- a/include/asm-x86_64/unistd.h
+++ b/include/asm-x86_64/unistd.h
@@ -622,25 +622,7 @@ __SYSCALL(__NR_move_pages, sys_move_pages)
622 622
623#define __NR_syscall_max __NR_move_pages 623#define __NR_syscall_max __NR_move_pages
624 624
625#ifdef __KERNEL__
626#include <linux/err.h>
627#endif
628
629#ifndef __NO_STUBS 625#ifndef __NO_STUBS
630
631/* user-visible error numbers are in the range -1 - -MAX_ERRNO */
632
633#define __syscall_clobber "r11","rcx","memory"
634
635#define __syscall_return(type, res) \
636do { \
637 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
638 errno = -(res); \
639 res = -1; \
640 } \
641 return (type) (res); \
642} while (0)
643
644#define __ARCH_WANT_OLD_READDIR 626#define __ARCH_WANT_OLD_READDIR
645#define __ARCH_WANT_OLD_STAT 627#define __ARCH_WANT_OLD_STAT
646#define __ARCH_WANT_SYS_ALARM 628#define __ARCH_WANT_SYS_ALARM
@@ -664,87 +646,6 @@ do { \
664#define __ARCH_WANT_SYS_TIME 646#define __ARCH_WANT_SYS_TIME
665#define __ARCH_WANT_COMPAT_SYS_TIME 647#define __ARCH_WANT_COMPAT_SYS_TIME
666 648
667#define __syscall "syscall"
668
669#define _syscall0(type,name) \
670type name(void) \
671{ \
672long __res; \
673__asm__ volatile (__syscall \
674 : "=a" (__res) \
675 : "0" (__NR_##name) : __syscall_clobber ); \
676__syscall_return(type,__res); \
677}
678
679#define _syscall1(type,name,type1,arg1) \
680type name(type1 arg1) \
681{ \
682long __res; \
683__asm__ volatile (__syscall \
684 : "=a" (__res) \
685 : "0" (__NR_##name),"D" ((long)(arg1)) : __syscall_clobber ); \
686__syscall_return(type,__res); \
687}
688
689#define _syscall2(type,name,type1,arg1,type2,arg2) \
690type name(type1 arg1,type2 arg2) \
691{ \
692long __res; \
693__asm__ volatile (__syscall \
694 : "=a" (__res) \
695 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)) : __syscall_clobber ); \
696__syscall_return(type,__res); \
697}
698
699#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
700type name(type1 arg1,type2 arg2,type3 arg3) \
701{ \
702long __res; \
703__asm__ volatile (__syscall \
704 : "=a" (__res) \
705 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
706 "d" ((long)(arg3)) : __syscall_clobber); \
707__syscall_return(type,__res); \
708}
709
710#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
711type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
712{ \
713long __res; \
714__asm__ volatile ("movq %5,%%r10 ;" __syscall \
715 : "=a" (__res) \
716 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
717 "d" ((long)(arg3)),"g" ((long)(arg4)) : __syscall_clobber,"r10" ); \
718__syscall_return(type,__res); \
719}
720
721#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
722 type5,arg5) \
723type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
724{ \
725long __res; \
726__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall \
727 : "=a" (__res) \
728 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
729 "d" ((long)(arg3)),"g" ((long)(arg4)),"g" ((long)(arg5)) : \
730 __syscall_clobber,"r8","r10" ); \
731__syscall_return(type,__res); \
732}
733
734#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
735 type5,arg5,type6,arg6) \
736type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
737{ \
738long __res; \
739__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; movq %7,%%r9 ; " __syscall \
740 : "=a" (__res) \
741 : "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
742 "d" ((long)(arg3)), "g" ((long)(arg4)), "g" ((long)(arg5)), \
743 "g" ((long)(arg6)) : \
744 __syscall_clobber,"r8","r10","r9" ); \
745__syscall_return(type,__res); \
746}
747
748#ifdef __KERNEL__ 649#ifdef __KERNEL__
749#ifndef __ASSEMBLY__ 650#ifndef __ASSEMBLY__
750 651
diff --git a/include/asm-x86_64/unwind.h b/include/asm-x86_64/unwind.h
index 2e7ff10fd775..2f6349e48717 100644
--- a/include/asm-x86_64/unwind.h
+++ b/include/asm-x86_64/unwind.h
@@ -87,14 +87,10 @@ extern int arch_unwind_init_running(struct unwind_frame_info *,
87 87
88static inline int arch_unw_user_mode(const struct unwind_frame_info *info) 88static inline int arch_unw_user_mode(const struct unwind_frame_info *info)
89{ 89{
90#if 0 /* This can only work when selector register saves/restores 90 return user_mode(&info->regs)
91 are properly annotated (and tracked in UNW_REGISTER_INFO). */ 91 || (long)info->regs.rip >= 0
92 return user_mode(&info->regs);
93#else
94 return (long)info->regs.rip >= 0
95 || (info->regs.rip >= VSYSCALL_START && info->regs.rip < VSYSCALL_END) 92 || (info->regs.rip >= VSYSCALL_START && info->regs.rip < VSYSCALL_END)
96 || (long)info->regs.rsp >= 0; 93 || (long)info->regs.rsp >= 0;
97#endif
98} 94}
99 95
100#else 96#else
diff --git a/include/asm-x86_64/vsyscall.h b/include/asm-x86_64/vsyscall.h
index 01d1c17e2849..05cb8dd200de 100644
--- a/include/asm-x86_64/vsyscall.h
+++ b/include/asm-x86_64/vsyscall.h
@@ -10,6 +10,7 @@ enum vsyscall_num {
10#define VSYSCALL_START (-10UL << 20) 10#define VSYSCALL_START (-10UL << 20)
11#define VSYSCALL_SIZE 1024 11#define VSYSCALL_SIZE 1024
12#define VSYSCALL_END (-2UL << 20) 12#define VSYSCALL_END (-2UL << 20)
13#define VSYSCALL_MAPPED_PAGES 1
13#define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr)) 14#define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))
14 15
15#ifdef __KERNEL__ 16#ifdef __KERNEL__
diff --git a/include/asm-xtensa/dma-mapping.h b/include/asm-xtensa/dma-mapping.h
index c39c91dfcc69..82b03b3a2ee6 100644
--- a/include/asm-xtensa/dma-mapping.h
+++ b/include/asm-xtensa/dma-mapping.h
@@ -170,10 +170,10 @@ dma_get_cache_alignment(void)
170 return L1_CACHE_BYTES; 170 return L1_CACHE_BYTES;
171} 171}
172 172
173#define dma_is_consistent(d) (1) 173#define dma_is_consistent(d, h) (1)
174 174
175static inline void 175static inline void
176dma_cache_sync(void *vaddr, size_t size, 176dma_cache_sync(struct device *dev, void *vaddr, size_t size,
177 enum dma_data_direction direction) 177 enum dma_data_direction direction)
178{ 178{
179 consistent_sync(vaddr, size, direction); 179 consistent_sync(vaddr, size, direction);
diff --git a/include/asm-xtensa/unistd.h b/include/asm-xtensa/unistd.h
index 411f810a55c6..2e1a1b997e7d 100644
--- a/include/asm-xtensa/unistd.h
+++ b/include/asm-xtensa/unistd.h
@@ -218,190 +218,6 @@
218 218
219#define SYSXTENSA_COUNT 5 /* count of syscall0 functions*/ 219#define SYSXTENSA_COUNT 5 /* count of syscall0 functions*/
220 220
221#ifdef __KERNEL__
222#include <linux/linkage.h>
223
224#define __syscall_return(type, res) return ((type)(res))
225
226/* Tensilica's xt-xcc compiler is much more agressive at code
227 * optimization than gcc. Multiple __asm__ statements are
228 * insufficient for xt-xcc because subsequent optimization passes
229 * (beyond the front-end that knows of __asm__ statements and other
230 * such GNU Extensions to C) can modify the register selection for
231 * containment of C variables.
232 *
233 * xt-xcc cannot modify the contents of a single __asm__ statement, so
234 * we create single-asm versions of the syscall macros that are
235 * suitable and optimal for both xt-xcc and gcc.
236 *
237 * Linux takes system-call arguments in registers. The following
238 * design is optimized for user-land apps (e.g., glibc) which
239 * typically have a function wrapper around the "syscall" assembly
240 * instruction. It satisfies the Xtensa ABI while minizing argument
241 * shifting.
242 *
243 * The Xtensa ABI and software conventions require the system-call
244 * number in a2. If an argument exists in a2, we move it to the next
245 * available register. Note that for improved efficiency, we do NOT
246 * shift all parameters down one register to maintain the original
247 * order.
248 *
249 * At best case (zero arguments), we just write the syscall number to
250 * a2. At worst case (1 to 6 arguments), we move the argument in a2
251 * to the next available register, then write the syscall number to
252 * a2.
253 *
254 * For clarity, the following truth table enumerates all possibilities.
255 *
256 * arguments syscall number arg0, arg1, arg2, arg3, arg4, arg5
257 * --------- -------------- ----------------------------------
258 * 0 a2
259 * 1 a2 a3
260 * 2 a2 a4, a3
261 * 3 a2 a5, a3, a4
262 * 4 a2 a6, a3, a4, a5
263 * 5 a2 a7, a3, a4, a5, a6
264 * 6 a2 a8, a3, a4, a5, a6, a7
265 */
266
267#define _syscall0(type,name) \
268type name(void) \
269{ \
270long __res; \
271__asm__ __volatile__ ( \
272 " movi a2, %1 \n" \
273 " syscall \n" \
274 " mov %0, a2 \n" \
275 : "=a" (__res) \
276 : "i" (__NR_##name) \
277 : "a2" \
278 ); \
279__syscall_return(type,__res); \
280}
281
282#define _syscall1(type,name,type0,arg0) \
283type name(type0 arg0) \
284{ \
285long __res; \
286__asm__ __volatile__ ( \
287 " mov a3, %2 \n" \
288 " movi a2, %1 \n" \
289 " syscall \n" \
290 " mov %0, a2 \n" \
291 : "=a" (__res) \
292 : "i" (__NR_##name), "a" (arg0) \
293 : "a2", "a3" \
294 ); \
295__syscall_return(type,__res); \
296}
297
298#define _syscall2(type,name,type0,arg0,type1,arg1) \
299type name(type0 arg0,type1 arg1) \
300{ \
301long __res; \
302__asm__ __volatile__ ( \
303 " mov a4, %2 \n" \
304 " mov a3, %3 \n" \
305 " movi a2, %1 \n" \
306 " syscall \n" \
307 " mov %0, a2 \n" \
308 : "=a" (__res) \
309 : "i" (__NR_##name), "a" (arg0), "a" (arg1) \
310 : "a2", "a3", "a4" \
311 ); \
312__syscall_return(type,__res); \
313}
314
315#define _syscall3(type,name,type0,arg0,type1,arg1,type2,arg2) \
316type name(type0 arg0,type1 arg1,type2 arg2) \
317{ \
318long __res; \
319__asm__ __volatile__ ( \
320 " mov a5, %2 \n" \
321 " mov a4, %4 \n" \
322 " mov a3, %3 \n" \
323 " movi a2, %1 \n" \
324 " syscall \n" \
325 " mov %0, a2 \n" \
326 : "=a" (__res) \
327 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2) \
328 : "a2", "a3", "a4", "a5" \
329 ); \
330__syscall_return(type,__res); \
331}
332
333#define _syscall4(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3) \
334type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3) \
335{ \
336long __res; \
337__asm__ __volatile__ ( \
338 " mov a6, %2 \n" \
339 " mov a5, %5 \n" \
340 " mov a4, %4 \n" \
341 " mov a3, %3 \n" \
342 " movi a2, %1 \n" \
343 " syscall \n" \
344 " mov %0, a2 \n" \
345 : "=a" (__res) \
346 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), "a" (arg3) \
347 : "a2", "a3", "a4", "a5", "a6" \
348 ); \
349__syscall_return(type,__res); \
350}
351
352/* Note that we save and restore the a7 frame pointer.
353 * Including a7 in the clobber list doesn't do what you'd expect.
354 */
355#define _syscall5(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
356type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
357{ \
358long __res; \
359__asm__ __volatile__ ( \
360 " mov a9, a7 \n" \
361 " mov a7, %2 \n" \
362 " mov a6, %6 \n" \
363 " mov a5, %5 \n" \
364 " mov a4, %4 \n" \
365 " mov a3, %3 \n" \
366 " movi a2, %1 \n" \
367 " syscall \n" \
368 " mov a7, a9 \n" \
369 " mov %0, a2 \n" \
370 : "=a" (__res) \
371 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
372 "a" (arg3), "a" (arg4) \
373 : "a2", "a3", "a4", "a5", "a6", "a9" \
374 ); \
375__syscall_return(type,__res); \
376}
377
378/* Note that we save and restore the a7 frame pointer.
379 * Including a7 in the clobber list doesn't do what you'd expect.
380 */
381#define _syscall6(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
382type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
383{ \
384long __res; \
385__asm__ __volatile__ ( \
386 " mov a9, a7 \n" \
387 " mov a8, %2 \n" \
388 " mov a7, %7 \n" \
389 " mov a6, %6 \n" \
390 " mov a5, %5 \n" \
391 " mov a4, %4 \n" \
392 " mov a3, %3 \n" \
393 " movi a2, %1 \n" \
394 " syscall \n" \
395 " mov a7, a9 \n" \
396 " mov %0, a2 \n" \
397 : "=a" (__res) \
398 : "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
399 "a" (arg3), "a" (arg4), "a" (arg5) \
400 : "a2", "a3", "a4", "a5", "a6", "a8", "a9" \
401 ); \
402__syscall_return(type,__res); \
403}
404
405/* 221/*
406 * "Conditional" syscalls 222 * "Conditional" syscalls
407 * 223 *
diff --git a/include/crypto/b128ops.h b/include/crypto/b128ops.h
new file mode 100644
index 000000000000..0b8e6bc55301
--- /dev/null
+++ b/include/crypto/b128ops.h
@@ -0,0 +1,80 @@
1/* b128ops.h - common 128-bit block operations
2 *
3 * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.
4 * Copyright (c) 2006, Rik Snel <rsnel@cube.dyndns.org>
5 *
6 * Based on Dr Brian Gladman's (GPL'd) work published at
7 * http://fp.gladman.plus.com/cryptography_technology/index.htm
8 * See the original copyright notice below.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 */
15/*
16 ---------------------------------------------------------------------------
17 Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.
18
19 LICENSE TERMS
20
21 The free distribution and use of this software in both source and binary
22 form is allowed (with or without changes) provided that:
23
24 1. distributions of this source code include the above copyright
25 notice, this list of conditions and the following disclaimer;
26
27 2. distributions in binary form include the above copyright
28 notice, this list of conditions and the following disclaimer
29 in the documentation and/or other associated materials;
30
31 3. the copyright holder's name is not used to endorse products
32 built using this software without specific written permission.
33
34 ALTERNATIVELY, provided that this notice is retained in full, this product
35 may be distributed under the terms of the GNU General Public License (GPL),
36 in which case the provisions of the GPL apply INSTEAD OF those given above.
37
38 DISCLAIMER
39
40 This software is provided 'as is' with no explicit or implied warranties
41 in respect of its properties, including, but not limited to, correctness
42 and/or fitness for purpose.
43 ---------------------------------------------------------------------------
44 Issue Date: 13/06/2006
45*/
46
47#ifndef _CRYPTO_B128OPS_H
48#define _CRYPTO_B128OPS_H
49
50#include <linux/types.h>
51
52typedef struct {
53 u64 a, b;
54} u128;
55
56typedef struct {
57 __be64 a, b;
58} be128;
59
60typedef struct {
61 __le64 b, a;
62} le128;
63
64static inline void u128_xor(u128 *r, const u128 *p, const u128 *q)
65{
66 r->a = p->a ^ q->a;
67 r->b = p->b ^ q->b;
68}
69
70static inline void be128_xor(be128 *r, const be128 *p, const be128 *q)
71{
72 u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
73}
74
75static inline void le128_xor(le128 *r, const le128 *p, const le128 *q)
76{
77 u128_xor((u128 *)r, (u128 *)p, (u128 *)q);
78}
79
80#endif /* _CRYPTO_B128OPS_H */
diff --git a/include/crypto/gf128mul.h b/include/crypto/gf128mul.h
new file mode 100644
index 000000000000..4fd315202442
--- /dev/null
+++ b/include/crypto/gf128mul.h
@@ -0,0 +1,198 @@
1/* gf128mul.h - GF(2^128) multiplication functions
2 *
3 * Copyright (c) 2003, Dr Brian Gladman, Worcester, UK.
4 * Copyright (c) 2006 Rik Snel <rsnel@cube.dyndns.org>
5 *
6 * Based on Dr Brian Gladman's (GPL'd) work published at
7 * http://fp.gladman.plus.com/cryptography_technology/index.htm
8 * See the original copyright notice below.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version.
14 */
15/*
16 ---------------------------------------------------------------------------
17 Copyright (c) 2003, Dr Brian Gladman, Worcester, UK. All rights reserved.
18
19 LICENSE TERMS
20
21 The free distribution and use of this software in both source and binary
22 form is allowed (with or without changes) provided that:
23
24 1. distributions of this source code include the above copyright
25 notice, this list of conditions and the following disclaimer;
26
27 2. distributions in binary form include the above copyright
28 notice, this list of conditions and the following disclaimer
29 in the documentation and/or other associated materials;
30
31 3. the copyright holder's name is not used to endorse products
32 built using this software without specific written permission.
33
34 ALTERNATIVELY, provided that this notice is retained in full, this product
35 may be distributed under the terms of the GNU General Public License (GPL),
36 in which case the provisions of the GPL apply INSTEAD OF those given above.
37
38 DISCLAIMER
39
40 This software is provided 'as is' with no explicit or implied warranties
41 in respect of its properties, including, but not limited to, correctness
42 and/or fitness for purpose.
43 ---------------------------------------------------------------------------
44 Issue Date: 31/01/2006
45
46 An implementation of field multiplication in Galois Field GF(128)
47*/
48
49#ifndef _CRYPTO_GF128MUL_H
50#define _CRYPTO_GF128MUL_H
51
52#include <crypto/b128ops.h>
53#include <linux/slab.h>
54
55/* Comment by Rik:
56 *
57 * For some background on GF(2^128) see for example: http://-
58 * csrc.nist.gov/CryptoToolkit/modes/proposedmodes/gcm/gcm-revised-spec.pdf
59 *
60 * The elements of GF(2^128) := GF(2)[X]/(X^128-X^7-X^2-X^1-1) can
61 * be mapped to computer memory in a variety of ways. Let's examine
62 * three common cases.
63 *
64 * Take a look at the 16 binary octets below in memory order. The msb's
65 * are left and the lsb's are right. char b[16] is an array and b[0] is
66 * the first octet.
67 *
68 * 80000000 00000000 00000000 00000000 .... 00000000 00000000 00000000
69 * b[0] b[1] b[2] b[3] b[13] b[14] b[15]
70 *
71 * Every bit is a coefficient of some power of X. We can store the bits
72 * in every byte in little-endian order and the bytes themselves also in
73 * little endian order. I will call this lle (little-little-endian).
74 * The above buffer represents the polynomial 1, and X^7+X^2+X^1+1 looks
75 * like 11100001 00000000 .... 00000000 = { 0xE1, 0x00, }.
76 * This format was originally implemented in gf128mul and is used
77 * in GCM (Galois/Counter mode) and in ABL (Arbitrary Block Length).
78 *
79 * Another convention says: store the bits in bigendian order and the
80 * bytes also. This is bbe (big-big-endian). Now the buffer above
81 * represents X^127. X^7+X^2+X^1+1 looks like 00000000 .... 10000111,
82 * b[15] = 0x87 and the rest is 0. LRW uses this convention and bbe
83 * is partly implemented.
84 *
85 * Both of the above formats are easy to implement on big-endian
86 * machines.
87 *
88 * EME (which is patent encumbered) uses the ble format (bits are stored
89 * in big endian order and the bytes in little endian). The above buffer
90 * represents X^7 in this case and the primitive polynomial is b[0] = 0x87.
91 *
92 * The common machine word-size is smaller than 128 bits, so to make
93 * an efficient implementation we must split into machine word sizes.
94 * This file uses one 32bit for the moment. Machine endianness comes into
95 * play. The lle format in relation to machine endianness is discussed
96 * below by the original author of gf128mul Dr Brian Gladman.
97 *
98 * Let's look at the bbe and ble format on a little endian machine.
99 *
100 * bbe on a little endian machine u32 x[4]:
101 *
102 * MS x[0] LS MS x[1] LS
103 * ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
104 * 103..96 111.104 119.112 127.120 71...64 79...72 87...80 95...88
105 *
106 * MS x[2] LS MS x[3] LS
107 * ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
108 * 39...32 47...40 55...48 63...56 07...00 15...08 23...16 31...24
109 *
110 * ble on a little endian machine
111 *
112 * MS x[0] LS MS x[1] LS
113 * ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
114 * 31...24 23...16 15...08 07...00 63...56 55...48 47...40 39...32
115 *
116 * MS x[2] LS MS x[3] LS
117 * ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
118 * 95...88 87...80 79...72 71...64 127.120 199.112 111.104 103..96
119 *
120 * Multiplications in GF(2^128) are mostly bit-shifts, so you see why
121 * ble (and lbe also) are easier to implement on a little-endian
122 * machine than on a big-endian machine. The converse holds for bbe
123 * and lle.
124 *
125 * Note: to have good alignment, it seems to me that it is sufficient
126 * to keep elements of GF(2^128) in type u64[2]. On 32-bit wordsize
127 * machines this will automatically aligned to wordsize and on a 64-bit
128 * machine also.
129 */
130/* Multiply a GF128 field element by x. Field elements are held in arrays
131 of bytes in which field bits 8n..8n + 7 are held in byte[n], with lower
132 indexed bits placed in the more numerically significant bit positions
133 within bytes.
134
135 On little endian machines the bit indexes translate into the bit
136 positions within four 32-bit words in the following way
137
138 MS x[0] LS MS x[1] LS
139 ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
140 24...31 16...23 08...15 00...07 56...63 48...55 40...47 32...39
141
142 MS x[2] LS MS x[3] LS
143 ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
144 88...95 80...87 72...79 64...71 120.127 112.119 104.111 96..103
145
146 On big endian machines the bit indexes translate into the bit
147 positions within four 32-bit words in the following way
148
149 MS x[0] LS MS x[1] LS
150 ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
151 00...07 08...15 16...23 24...31 32...39 40...47 48...55 56...63
152
153 MS x[2] LS MS x[3] LS
154 ms ls ms ls ms ls ms ls ms ls ms ls ms ls ms ls
155 64...71 72...79 80...87 88...95 96..103 104.111 112.119 120.127
156*/
157
158/* A slow generic version of gf_mul, implemented for lle and bbe
159 * It multiplies a and b and puts the result in a */
160void gf128mul_lle(be128 *a, const be128 *b);
161
162void gf128mul_bbe(be128 *a, const be128 *b);
163
164
165/* 4k table optimization */
166
167struct gf128mul_4k {
168 be128 t[256];
169};
170
171struct gf128mul_4k *gf128mul_init_4k_lle(const be128 *g);
172struct gf128mul_4k *gf128mul_init_4k_bbe(const be128 *g);
173void gf128mul_4k_lle(be128 *a, struct gf128mul_4k *t);
174void gf128mul_4k_bbe(be128 *a, struct gf128mul_4k *t);
175
176static inline void gf128mul_free_4k(struct gf128mul_4k *t)
177{
178 kfree(t);
179}
180
181
182/* 64k table optimization, implemented for lle and bbe */
183
184struct gf128mul_64k {
185 struct gf128mul_4k *t[16];
186};
187
188/* first initialize with the constant factor with which you
189 * want to multiply and then call gf128_64k_lle with the other
190 * factor in the first argument, the table in the second and a
191 * scratch register in the third. Afterwards *a = *r. */
192struct gf128mul_64k *gf128mul_init_64k_lle(const be128 *g);
193struct gf128mul_64k *gf128mul_init_64k_bbe(const be128 *g);
194void gf128mul_free_64k(struct gf128mul_64k *t);
195void gf128mul_64k_lle(be128 *a, struct gf128mul_64k *t);
196void gf128mul_64k_bbe(be128 *a, struct gf128mul_64k *t);
197
198#endif /* _CRYPTO_GF128MUL_H */
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index ff433126361f..e618b25b5add 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -221,6 +221,7 @@ unifdef-y += if_bridge.h
221unifdef-y += if_ec.h 221unifdef-y += if_ec.h
222unifdef-y += if_eql.h 222unifdef-y += if_eql.h
223unifdef-y += if_ether.h 223unifdef-y += if_ether.h
224unifdef-y += if_fddi.h
224unifdef-y += if_frad.h 225unifdef-y += if_frad.h
225unifdef-y += if_ltalk.h 226unifdef-y += if_ltalk.h
226unifdef-y += if_pppox.h 227unifdef-y += if_pppox.h
@@ -282,6 +283,7 @@ unifdef-y += nvram.h
282unifdef-y += parport.h 283unifdef-y += parport.h
283unifdef-y += patchkey.h 284unifdef-y += patchkey.h
284unifdef-y += pci.h 285unifdef-y += pci.h
286unifdef-y += personality.h
285unifdef-y += pktcdvd.h 287unifdef-y += pktcdvd.h
286unifdef-y += pmu.h 288unifdef-y += pmu.h
287unifdef-y += poll.h 289unifdef-y += poll.h
@@ -337,6 +339,7 @@ unifdef-y += videodev.h
337unifdef-y += wait.h 339unifdef-y += wait.h
338unifdef-y += wanrouter.h 340unifdef-y += wanrouter.h
339unifdef-y += watchdog.h 341unifdef-y += watchdog.h
342unifdef-y += wireless.h
340unifdef-y += xfrm.h 343unifdef-y += xfrm.h
341 344
342objhdr-y += version.h 345objhdr-y += version.h
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 9e350fd44d77..3372ec6bf53a 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -111,7 +111,6 @@ struct kiocb {
111 size_t ki_nbytes; /* copy of iocb->aio_nbytes */ 111 size_t ki_nbytes; /* copy of iocb->aio_nbytes */
112 char __user *ki_buf; /* remaining iocb->aio_buf */ 112 char __user *ki_buf; /* remaining iocb->aio_buf */
113 size_t ki_left; /* remaining bytes */ 113 size_t ki_left; /* remaining bytes */
114 long ki_retried; /* just for testing */
115 struct iovec ki_inline_vec; /* inline vector */ 114 struct iovec ki_inline_vec; /* inline vector */
116 struct iovec *ki_iovec; 115 struct iovec *ki_iovec;
117 unsigned long ki_nr_segs; 116 unsigned long ki_nr_segs;
@@ -238,7 +237,6 @@ do { \
238} while (0) 237} while (0)
239 238
240#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait) 239#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
241#define is_retried_kiocb(iocb) ((iocb)->ki_retried > 1)
242 240
243#include <linux/aio_abi.h> 241#include <linux/aio_abi.h>
244 242
diff --git a/include/linux/audit.h b/include/linux/audit.h
index b2ca666d9997..0e07db6cc0d0 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -101,6 +101,10 @@
101#define AUDIT_MAC_CIPSOV4_DEL 1408 /* NetLabel: del CIPSOv4 DOI entry */ 101#define AUDIT_MAC_CIPSOV4_DEL 1408 /* NetLabel: del CIPSOv4 DOI entry */
102#define AUDIT_MAC_MAP_ADD 1409 /* NetLabel: add LSM domain mapping */ 102#define AUDIT_MAC_MAP_ADD 1409 /* NetLabel: add LSM domain mapping */
103#define AUDIT_MAC_MAP_DEL 1410 /* NetLabel: del LSM domain mapping */ 103#define AUDIT_MAC_MAP_DEL 1410 /* NetLabel: del LSM domain mapping */
104#define AUDIT_MAC_IPSEC_ADDSA 1411 /* Add a XFRM state */
105#define AUDIT_MAC_IPSEC_DELSA 1412 /* Delete a XFRM state */
106#define AUDIT_MAC_IPSEC_ADDSPD 1413 /* Add a XFRM policy */
107#define AUDIT_MAC_IPSEC_DELSPD 1414 /* Delete a XFRM policy */
104 108
105#define AUDIT_FIRST_KERN_ANOM_MSG 1700 109#define AUDIT_FIRST_KERN_ANOM_MSG 1700
106#define AUDIT_LAST_KERN_ANOM_MSG 1799 110#define AUDIT_LAST_KERN_ANOM_MSG 1799
@@ -377,6 +381,7 @@ extern void auditsc_get_stamp(struct audit_context *ctx,
377 struct timespec *t, unsigned int *serial); 381 struct timespec *t, unsigned int *serial);
378extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid); 382extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid);
379extern uid_t audit_get_loginuid(struct audit_context *ctx); 383extern uid_t audit_get_loginuid(struct audit_context *ctx);
384extern void audit_log_task_context(struct audit_buffer *ab);
380extern int __audit_ipc_obj(struct kern_ipc_perm *ipcp); 385extern int __audit_ipc_obj(struct kern_ipc_perm *ipcp);
381extern int __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode); 386extern int __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode);
382extern int audit_bprm(struct linux_binprm *bprm); 387extern int audit_bprm(struct linux_binprm *bprm);
@@ -449,6 +454,7 @@ extern int audit_n_rules;
449#define audit_inode_update(i) do { ; } while (0) 454#define audit_inode_update(i) do { ; } while (0)
450#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) 455#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
451#define audit_get_loginuid(c) ({ -1; }) 456#define audit_get_loginuid(c) ({ -1; })
457#define audit_log_task_context(b) do { ; } while (0)
452#define audit_ipc_obj(i) ({ 0; }) 458#define audit_ipc_obj(i) ({ 0; })
453#define audit_ipc_set_perm(q,u,g,m) ({ 0; }) 459#define audit_ipc_set_perm(q,u,g,m) ({ 0; })
454#define audit_bprm(p) ({ 0; }) 460#define audit_bprm(p) ({ 0; })
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 31e9abb6d977..2275f2748708 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -119,8 +119,7 @@ extern void *alloc_large_system_hash(const char *tablename,
119 unsigned int *_hash_mask, 119 unsigned int *_hash_mask,
120 unsigned long limit); 120 unsigned long limit);
121 121
122#define HASH_HIGHMEM 0x00000001 /* Consider highmem? */ 122#define HASH_EARLY 0x00000001 /* Allocating during early boot? */
123#define HASH_EARLY 0x00000002 /* Allocating during early boot? */
124 123
125/* Only NUMA needs hash distribution. 124/* Only NUMA needs hash distribution.
126 * IA64 is known to have sufficient vmalloc space. 125 * IA64 is known to have sufficient vmalloc space.
diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h
new file mode 100644
index 000000000000..777dbf695d44
--- /dev/null
+++ b/include/linux/bottom_half.h
@@ -0,0 +1,10 @@
1#ifndef _LINUX_BH_H
2#define _LINUX_BH_H
3
4extern void local_bh_disable(void);
5extern void __local_bh_enable(void);
6extern void _local_bh_enable(void);
7extern void local_bh_enable(void);
8extern void local_bh_enable_ip(unsigned long ip);
9
10#endif /* _LINUX_BH_H */
diff --git a/include/linux/carta_random32.h b/include/linux/carta_random32.h
deleted file mode 100644
index f6f3bd9f20b5..000000000000
--- a/include/linux/carta_random32.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Fast, simple, yet decent quality random number generator based on
3 * a paper by David G. Carta ("Two Fast Implementations of the
4 * `Minimal Standard' Random Number Generator," Communications of the
5 * ACM, January, 1990).
6 *
7 * Copyright (c) 2002-2006 Hewlett-Packard Development Company, L.P.
8 * Contributed by Stephane Eranian <eranian@hpl.hp.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 * 02111-1307 USA
23 */
24#ifndef _LINUX_CARTA_RANDOM32_H_
25#define _LINUX_CARTA_RANDOM32_H_
26
27u64 carta_random32(u64 seed);
28
29#endif /* _LINUX_CARTA_RANDOM32_H_ */
diff --git a/include/linux/cciss_ioctl.h b/include/linux/cciss_ioctl.h
index 6e27f42e3a57..cb57c30081a8 100644
--- a/include/linux/cciss_ioctl.h
+++ b/include/linux/cciss_ioctl.h
@@ -80,7 +80,7 @@ typedef __u32 DriverVer_type;
80#define HWORD __u16 80#define HWORD __u16
81#define DWORD __u32 81#define DWORD __u32
82 82
83#define CISS_MAX_LUN 16 83#define CISS_MAX_LUN 1024
84 84
85#define LEVEL2LUN 1 // index into Target(x) structure, due to byte swapping 85#define LEVEL2LUN 1 // index into Target(x) structure, due to byte swapping
86#define LEVEL3LUN 0 86#define LEVEL3LUN 0
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
index ee5f53f2ca15..f309b00e986e 100644
--- a/include/linux/cdev.h
+++ b/include/linux/cdev.h
@@ -2,6 +2,10 @@
2#define _LINUX_CDEV_H 2#define _LINUX_CDEV_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <linux/kobject.h>
6#include <linux/kdev_t.h>
7#include <linux/list.h>
8
5struct cdev { 9struct cdev {
6 struct kobject kobj; 10 struct kobject kobj;
7 struct module *owner; 11 struct module *owner;
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index f02d71bf6894..bfb520212d71 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -24,10 +24,11 @@
24#include <linux/compiler.h> 24#include <linux/compiler.h>
25#include <linux/cpumask.h> 25#include <linux/cpumask.h>
26#include <asm/semaphore.h> 26#include <asm/semaphore.h>
27#include <linux/mutex.h>
27 28
28struct cpu { 29struct cpu {
29 int node_id; /* The node which contains the CPU */ 30 int node_id; /* The node which contains the CPU */
30 int no_control; /* Should the sysfs control file be created? */ 31 int hotpluggable; /* creates sysfs control file if hotpluggable */
31 struct sys_device sysdev; 32 struct sys_device sysdev;
32}; 33};
33 34
@@ -74,6 +75,17 @@ extern struct sysdev_class cpu_sysdev_class;
74 75
75#ifdef CONFIG_HOTPLUG_CPU 76#ifdef CONFIG_HOTPLUG_CPU
76/* Stop CPUs going up and down. */ 77/* Stop CPUs going up and down. */
78
79static inline void cpuhotplug_mutex_lock(struct mutex *cpu_hp_mutex)
80{
81 mutex_lock(cpu_hp_mutex);
82}
83
84static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
85{
86 mutex_unlock(cpu_hp_mutex);
87}
88
77extern void lock_cpu_hotplug(void); 89extern void lock_cpu_hotplug(void);
78extern void unlock_cpu_hotplug(void); 90extern void unlock_cpu_hotplug(void);
79#define hotcpu_notifier(fn, pri) { \ 91#define hotcpu_notifier(fn, pri) { \
@@ -85,17 +97,24 @@ extern void unlock_cpu_hotplug(void);
85#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb) 97#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb)
86int cpu_down(unsigned int cpu); 98int cpu_down(unsigned int cpu);
87#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) 99#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
88#else 100
101#else /* CONFIG_HOTPLUG_CPU */
102
103static inline void cpuhotplug_mutex_lock(struct mutex *cpu_hp_mutex)
104{ }
105static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
106{ }
107
89#define lock_cpu_hotplug() do { } while (0) 108#define lock_cpu_hotplug() do { } while (0)
90#define unlock_cpu_hotplug() do { } while (0) 109#define unlock_cpu_hotplug() do { } while (0)
91#define lock_cpu_hotplug_interruptible() 0 110#define lock_cpu_hotplug_interruptible() 0
92#define hotcpu_notifier(fn, pri) do { } while (0) 111#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
93#define register_hotcpu_notifier(nb) do { } while (0) 112#define register_hotcpu_notifier(nb) do { (void)(nb); } while (0)
94#define unregister_hotcpu_notifier(nb) do { } while (0) 113#define unregister_hotcpu_notifier(nb) do { (void)(nb); } while (0)
95 114
96/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */ 115/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */
97static inline int cpu_is_offline(int cpu) { return 0; } 116static inline int cpu_is_offline(int cpu) { return 0; }
98#endif 117#endif /* CONFIG_HOTPLUG_CPU */
99 118
100#ifdef CONFIG_SUSPEND_SMP 119#ifdef CONFIG_SUSPEND_SMP
101extern int disable_nonboot_cpus(void); 120extern int disable_nonboot_cpus(void);
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 4d8adf663681..8821e1f75b44 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -23,6 +23,7 @@ extern void cpuset_fork(struct task_struct *p);
23extern void cpuset_exit(struct task_struct *p); 23extern void cpuset_exit(struct task_struct *p);
24extern cpumask_t cpuset_cpus_allowed(struct task_struct *p); 24extern cpumask_t cpuset_cpus_allowed(struct task_struct *p);
25extern nodemask_t cpuset_mems_allowed(struct task_struct *p); 25extern nodemask_t cpuset_mems_allowed(struct task_struct *p);
26#define cpuset_current_mems_allowed (current->mems_allowed)
26void cpuset_init_current_mems_allowed(void); 27void cpuset_init_current_mems_allowed(void);
27void cpuset_update_task_memory_state(void); 28void cpuset_update_task_memory_state(void);
28#define cpuset_nodes_subset_current_mems_allowed(nodes) \ 29#define cpuset_nodes_subset_current_mems_allowed(nodes) \
@@ -45,7 +46,7 @@ extern int cpuset_excl_nodes_overlap(const struct task_struct *p);
45extern int cpuset_memory_pressure_enabled; 46extern int cpuset_memory_pressure_enabled;
46extern void __cpuset_memory_pressure_bump(void); 47extern void __cpuset_memory_pressure_bump(void);
47 48
48extern struct file_operations proc_cpuset_operations; 49extern const struct file_operations proc_cpuset_operations;
49extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer); 50extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
50 51
51extern void cpuset_lock(void); 52extern void cpuset_lock(void);
@@ -83,6 +84,7 @@ static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
83 return node_possible_map; 84 return node_possible_map;
84} 85}
85 86
87#define cpuset_current_mems_allowed (node_online_map)
86static inline void cpuset_init_current_mems_allowed(void) {} 88static inline void cpuset_init_current_mems_allowed(void) {}
87static inline void cpuset_update_task_memory_state(void) {} 89static inline void cpuset_update_task_memory_state(void) {}
88#define cpuset_nodes_subset_current_mems_allowed(nodes) (1) 90#define cpuset_nodes_subset_current_mems_allowed(nodes) (1)
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 6485e9716b36..4aa9046601da 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -241,12 +241,8 @@ int crypto_unregister_alg(struct crypto_alg *alg);
241 * Algorithm query interface. 241 * Algorithm query interface.
242 */ 242 */
243#ifdef CONFIG_CRYPTO 243#ifdef CONFIG_CRYPTO
244int crypto_alg_available(const char *name, u32 flags)
245 __deprecated_for_modules;
246int crypto_has_alg(const char *name, u32 type, u32 mask); 244int crypto_has_alg(const char *name, u32 type, u32 mask);
247#else 245#else
248static int crypto_alg_available(const char *name, u32 flags)
249 __deprecated_for_modules;
250static inline int crypto_alg_available(const char *name, u32 flags) 246static inline int crypto_alg_available(const char *name, u32 flags)
251{ 247{
252 return 0; 248 return 0;
@@ -707,16 +703,6 @@ static inline void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
707 dst, src); 703 dst, src);
708} 704}
709 705
710void crypto_digest_init(struct crypto_tfm *tfm) __deprecated_for_modules;
711void crypto_digest_update(struct crypto_tfm *tfm,
712 struct scatterlist *sg, unsigned int nsg)
713 __deprecated_for_modules;
714void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
715 __deprecated_for_modules;
716void crypto_digest_digest(struct crypto_tfm *tfm,
717 struct scatterlist *sg, unsigned int nsg, u8 *out)
718 __deprecated_for_modules;
719
720static inline struct crypto_hash *__crypto_hash_cast(struct crypto_tfm *tfm) 706static inline struct crypto_hash *__crypto_hash_cast(struct crypto_tfm *tfm)
721{ 707{
722 return (struct crypto_hash *)tfm; 708 return (struct crypto_hash *)tfm;
@@ -729,14 +715,6 @@ static inline struct crypto_hash *crypto_hash_cast(struct crypto_tfm *tfm)
729 return __crypto_hash_cast(tfm); 715 return __crypto_hash_cast(tfm);
730} 716}
731 717
732static int crypto_digest_setkey(struct crypto_tfm *tfm, const u8 *key,
733 unsigned int keylen) __deprecated;
734static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
735 const u8 *key, unsigned int keylen)
736{
737 return tfm->crt_hash.setkey(crypto_hash_cast(tfm), key, keylen);
738}
739
740static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name, 718static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name,
741 u32 type, u32 mask) 719 u32 type, u32 mask)
742{ 720{
diff --git a/include/linux/debug_locks.h b/include/linux/debug_locks.h
index 952bee79a8f3..a1c10b0c4cf0 100644
--- a/include/linux/debug_locks.h
+++ b/include/linux/debug_locks.h
@@ -24,7 +24,7 @@ extern int debug_locks_off(void);
24 int __ret = 0; \ 24 int __ret = 0; \
25 \ 25 \
26 if (unlikely(c)) { \ 26 if (unlikely(c)) { \
27 if (debug_locks_off()) \ 27 if (debug_locks_silent || debug_locks_off()) \
28 WARN_ON(1); \ 28 WARN_ON(1); \
29 __ret = 1; \ 29 __ret = 1; \
30 } \ 30 } \
diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
index 561e2a77805c..55d1ca5e60f5 100644
--- a/include/linux/delayacct.h
+++ b/include/linux/delayacct.h
@@ -30,7 +30,7 @@
30#ifdef CONFIG_TASK_DELAY_ACCT 30#ifdef CONFIG_TASK_DELAY_ACCT
31 31
32extern int delayacct_on; /* Delay accounting turned on/off */ 32extern int delayacct_on; /* Delay accounting turned on/off */
33extern kmem_cache_t *delayacct_cache; 33extern struct kmem_cache *delayacct_cache;
34extern void delayacct_init(void); 34extern void delayacct_init(void);
35extern void __delayacct_tsk_init(struct task_struct *); 35extern void __delayacct_tsk_init(struct task_struct *);
36extern void __delayacct_tsk_exit(struct task_struct *); 36extern void __delayacct_tsk_exit(struct task_struct *);
diff --git a/include/linux/device.h b/include/linux/device.h
index 583a341e016c..49ab53ce92dc 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -371,6 +371,9 @@ struct device {
371 core doesn't touch it */ 371 core doesn't touch it */
372 struct dev_pm_info power; 372 struct dev_pm_info power;
373 373
374#ifdef CONFIG_NUMA
375 int numa_node; /* NUMA node this device is close to */
376#endif
374 u64 *dma_mask; /* dma mask (if dma'able device) */ 377 u64 *dma_mask; /* dma mask (if dma'able device) */
375 u64 coherent_dma_mask;/* Like dma_mask, but for 378 u64 coherent_dma_mask;/* Like dma_mask, but for
376 alloc_coherent mappings as 379 alloc_coherent mappings as
@@ -394,6 +397,25 @@ struct device {
394 void (*release)(struct device * dev); 397 void (*release)(struct device * dev);
395}; 398};
396 399
400#ifdef CONFIG_NUMA
401static inline int dev_to_node(struct device *dev)
402{
403 return dev->numa_node;
404}
405static inline void set_dev_node(struct device *dev, int node)
406{
407 dev->numa_node = node;
408}
409#else
410static inline int dev_to_node(struct device *dev)
411{
412 return -1;
413}
414static inline void set_dev_node(struct device *dev, int node)
415{
416}
417#endif
418
397static inline void * 419static inline void *
398dev_get_drvdata (struct device *dev) 420dev_get_drvdata (struct device *dev)
399{ 421{
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 66d621dbcb6c..df1c91855f0e 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -300,8 +300,9 @@ extern int efi_mem_attribute_range (unsigned long phys_addr, unsigned long size,
300extern int __init efi_uart_console_only (void); 300extern int __init efi_uart_console_only (void);
301extern void efi_initialize_iomem_resources(struct resource *code_resource, 301extern void efi_initialize_iomem_resources(struct resource *code_resource,
302 struct resource *data_resource); 302 struct resource *data_resource);
303extern unsigned long __init efi_get_time(void); 303extern unsigned long efi_get_time(void);
304extern int __init efi_set_rtc_mmss(unsigned long nowtime); 304extern int __init efi_set_rtc_mmss(unsigned long nowtime);
305extern int is_available_memory(efi_memory_desc_t * md);
305extern struct efi_memory_map memmap; 306extern struct efi_memory_map memmap;
306 307
307/** 308/**
diff --git a/include/linux/elf.h b/include/linux/elf.h
index 743d5c8e6d36..60713e6ea297 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -6,6 +6,8 @@
6#include <linux/elf-em.h> 6#include <linux/elf-em.h>
7#include <asm/elf.h> 7#include <asm/elf.h>
8 8
9struct file;
10
9#ifndef elf_read_implies_exec 11#ifndef elf_read_implies_exec
10 /* Executables for which elf_read_implies_exec() returns TRUE will 12 /* Executables for which elf_read_implies_exec() returns TRUE will
11 have the READ_IMPLIES_EXEC personality flag set automatically. 13 have the READ_IMPLIES_EXEC personality flag set automatically.
@@ -358,6 +360,7 @@ extern Elf32_Dyn _DYNAMIC [];
358#define elfhdr elf32_hdr 360#define elfhdr elf32_hdr
359#define elf_phdr elf32_phdr 361#define elf_phdr elf32_phdr
360#define elf_note elf32_note 362#define elf_note elf32_note
363#define elf_addr_t Elf32_Off
361 364
362#else 365#else
363 366
@@ -365,6 +368,7 @@ extern Elf64_Dyn _DYNAMIC [];
365#define elfhdr elf64_hdr 368#define elfhdr elf64_hdr
366#define elf_phdr elf64_phdr 369#define elf_phdr elf64_phdr
367#define elf_note elf64_note 370#define elf_note elf64_note
371#define elf_addr_t Elf64_Off
368 372
369#endif 373#endif
370 374
diff --git a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h
index ce0e6109aff0..8c43b13a02fe 100644
--- a/include/linux/ext3_jbd.h
+++ b/include/linux/ext3_jbd.h
@@ -109,74 +109,32 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode);
109 * been done yet. 109 * been done yet.
110 */ 110 */
111 111
112void ext3_journal_abort_handle(const char *caller, const char *err_fn, 112static inline void ext3_journal_release_buffer(handle_t *handle,
113 struct buffer_head *bh, handle_t *handle, int err); 113 struct buffer_head *bh)
114
115static inline int
116__ext3_journal_get_undo_access(const char *where, handle_t *handle,
117 struct buffer_head *bh)
118{ 114{
119 int err = journal_get_undo_access(handle, bh); 115 journal_release_buffer(handle, bh);
120 if (err)
121 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
122 return err;
123} 116}
124 117
125static inline int 118void ext3_journal_abort_handle(const char *caller, const char *err_fn,
126__ext3_journal_get_write_access(const char *where, handle_t *handle, 119 struct buffer_head *bh, handle_t *handle, int err);
127 struct buffer_head *bh)
128{
129 int err = journal_get_write_access(handle, bh);
130 if (err)
131 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
132 return err;
133}
134 120
135static inline void 121int __ext3_journal_get_undo_access(const char *where, handle_t *handle,
136ext3_journal_release_buffer(handle_t *handle, struct buffer_head *bh) 122 struct buffer_head *bh);
137{
138 journal_release_buffer(handle, bh);
139}
140 123
141static inline int 124int __ext3_journal_get_write_access(const char *where, handle_t *handle,
142__ext3_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh) 125 struct buffer_head *bh);
143{
144 int err = journal_forget(handle, bh);
145 if (err)
146 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
147 return err;
148}
149 126
150static inline int 127int __ext3_journal_forget(const char *where, handle_t *handle,
151__ext3_journal_revoke(const char *where, handle_t *handle, 128 struct buffer_head *bh);
152 unsigned long blocknr, struct buffer_head *bh)
153{
154 int err = journal_revoke(handle, blocknr, bh);
155 if (err)
156 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
157 return err;
158}
159 129
160static inline int 130int __ext3_journal_revoke(const char *where, handle_t *handle,
161__ext3_journal_get_create_access(const char *where, 131 unsigned long blocknr, struct buffer_head *bh);
162 handle_t *handle, struct buffer_head *bh)
163{
164 int err = journal_get_create_access(handle, bh);
165 if (err)
166 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
167 return err;
168}
169 132
170static inline int 133int __ext3_journal_get_create_access(const char *where,
171__ext3_journal_dirty_metadata(const char *where, 134 handle_t *handle, struct buffer_head *bh);
172 handle_t *handle, struct buffer_head *bh)
173{
174 int err = journal_dirty_metadata(handle, bh);
175 if (err)
176 ext3_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
177 return err;
178}
179 135
136int __ext3_journal_dirty_metadata(const char *where,
137 handle_t *handle, struct buffer_head *bh);
180 138
181#define ext3_journal_get_undo_access(handle, bh) \ 139#define ext3_journal_get_undo_access(handle, bh) \
182 __ext3_journal_get_undo_access(__FUNCTION__, (handle), (bh)) 140 __ext3_journal_get_undo_access(__FUNCTION__, (handle), (bh))
diff --git a/include/linux/ext4_jbd2.h b/include/linux/ext4_jbd2.h
index 72dd631912e4..d716e6392cf6 100644
--- a/include/linux/ext4_jbd2.h
+++ b/include/linux/ext4_jbd2.h
@@ -114,74 +114,32 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode);
114 * been done yet. 114 * been done yet.
115 */ 115 */
116 116
117void ext4_journal_abort_handle(const char *caller, const char *err_fn, 117static inline void ext4_journal_release_buffer(handle_t *handle,
118 struct buffer_head *bh, handle_t *handle, int err); 118 struct buffer_head *bh)
119
120static inline int
121__ext4_journal_get_undo_access(const char *where, handle_t *handle,
122 struct buffer_head *bh)
123{ 119{
124 int err = jbd2_journal_get_undo_access(handle, bh); 120 jbd2_journal_release_buffer(handle, bh);
125 if (err)
126 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
127 return err;
128} 121}
129 122
130static inline int 123void ext4_journal_abort_handle(const char *caller, const char *err_fn,
131__ext4_journal_get_write_access(const char *where, handle_t *handle, 124 struct buffer_head *bh, handle_t *handle, int err);
132 struct buffer_head *bh)
133{
134 int err = jbd2_journal_get_write_access(handle, bh);
135 if (err)
136 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
137 return err;
138}
139 125
140static inline void 126int __ext4_journal_get_undo_access(const char *where, handle_t *handle,
141ext4_journal_release_buffer(handle_t *handle, struct buffer_head *bh) 127 struct buffer_head *bh);
142{
143 jbd2_journal_release_buffer(handle, bh);
144}
145 128
146static inline int 129int __ext4_journal_get_write_access(const char *where, handle_t *handle,
147__ext4_journal_forget(const char *where, handle_t *handle, struct buffer_head *bh) 130 struct buffer_head *bh);
148{
149 int err = jbd2_journal_forget(handle, bh);
150 if (err)
151 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
152 return err;
153}
154 131
155static inline int 132int __ext4_journal_forget(const char *where, handle_t *handle,
156__ext4_journal_revoke(const char *where, handle_t *handle, 133 struct buffer_head *bh);
157 ext4_fsblk_t blocknr, struct buffer_head *bh)
158{
159 int err = jbd2_journal_revoke(handle, blocknr, bh);
160 if (err)
161 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
162 return err;
163}
164 134
165static inline int 135int __ext4_journal_revoke(const char *where, handle_t *handle,
166__ext4_journal_get_create_access(const char *where, 136 ext4_fsblk_t blocknr, struct buffer_head *bh);
167 handle_t *handle, struct buffer_head *bh)
168{
169 int err = jbd2_journal_get_create_access(handle, bh);
170 if (err)
171 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
172 return err;
173}
174 137
175static inline int 138int __ext4_journal_get_create_access(const char *where,
176__ext4_journal_dirty_metadata(const char *where, 139 handle_t *handle, struct buffer_head *bh);
177 handle_t *handle, struct buffer_head *bh)
178{
179 int err = jbd2_journal_dirty_metadata(handle, bh);
180 if (err)
181 ext4_journal_abort_handle(where, __FUNCTION__, bh, handle,err);
182 return err;
183}
184 140
141int __ext4_journal_dirty_metadata(const char *where,
142 handle_t *handle, struct buffer_head *bh);
185 143
186#define ext4_journal_get_undo_access(handle, bh) \ 144#define ext4_journal_get_undo_access(handle, bh) \
187 __ext4_journal_get_undo_access(__FUNCTION__, (handle), (bh)) 145 __ext4_journal_get_undo_access(__FUNCTION__, (handle), (bh))
diff --git a/include/linux/file.h b/include/linux/file.h
index 74183e6f7f45..6e77b9177f9e 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -64,6 +64,8 @@ struct files_struct {
64 64
65#define files_fdtable(files) (rcu_dereference((files)->fdt)) 65#define files_fdtable(files) (rcu_dereference((files)->fdt))
66 66
67extern struct kmem_cache *filp_cachep;
68
67extern void FASTCALL(__fput(struct file *)); 69extern void FASTCALL(__fput(struct file *));
68extern void FASTCALL(fput(struct file *)); 70extern void FASTCALL(fput(struct file *));
69 71
@@ -114,4 +116,6 @@ struct files_struct *get_files_struct(struct task_struct *);
114void FASTCALL(put_files_struct(struct files_struct *fs)); 116void FASTCALL(put_files_struct(struct files_struct *fs));
115void reset_files_struct(struct task_struct *, struct files_struct *); 117void reset_files_struct(struct task_struct *, struct files_struct *);
116 118
119extern struct kmem_cache *files_cachep;
120
117#endif /* __LINUX_FILE_H */ 121#endif /* __LINUX_FILE_H */
diff --git a/include/linux/freezer.h b/include/linux/freezer.h
new file mode 100644
index 000000000000..6e05e3e7ce39
--- /dev/null
+++ b/include/linux/freezer.h
@@ -0,0 +1,87 @@
1/* Freezer declarations */
2
3#ifdef CONFIG_PM
4/*
5 * Check if a process has been frozen
6 */
7static inline int frozen(struct task_struct *p)
8{
9 return p->flags & PF_FROZEN;
10}
11
12/*
13 * Check if there is a request to freeze a process
14 */
15static inline int freezing(struct task_struct *p)
16{
17 return p->flags & PF_FREEZE;
18}
19
20/*
21 * Request that a process be frozen
22 * FIXME: SMP problem. We may not modify other process' flags!
23 */
24static inline void freeze(struct task_struct *p)
25{
26 p->flags |= PF_FREEZE;
27}
28
29/*
30 * Sometimes we may need to cancel the previous 'freeze' request
31 */
32static inline void do_not_freeze(struct task_struct *p)
33{
34 p->flags &= ~PF_FREEZE;
35}
36
37/*
38 * Wake up a frozen process
39 */
40static inline int thaw_process(struct task_struct *p)
41{
42 if (frozen(p)) {
43 p->flags &= ~PF_FROZEN;
44 wake_up_process(p);
45 return 1;
46 }
47 return 0;
48}
49
50/*
51 * freezing is complete, mark process as frozen
52 */
53static inline void frozen_process(struct task_struct *p)
54{
55 p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
56}
57
58extern void refrigerator(void);
59extern int freeze_processes(void);
60extern void thaw_processes(void);
61
62static inline int try_to_freeze(void)
63{
64 if (freezing(current)) {
65 refrigerator();
66 return 1;
67 } else
68 return 0;
69}
70
71extern void thaw_some_processes(int all);
72
73#else
74static inline int frozen(struct task_struct *p) { return 0; }
75static inline int freezing(struct task_struct *p) { return 0; }
76static inline void freeze(struct task_struct *p) { BUG(); }
77static inline int thaw_process(struct task_struct *p) { return 1; }
78static inline void frozen_process(struct task_struct *p) { BUG(); }
79
80static inline void refrigerator(void) {}
81static inline int freeze_processes(void) { BUG(); return 0; }
82static inline void thaw_processes(void) {}
83
84static inline int try_to_freeze(void) { return 0; }
85
86
87#endif
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cac7b1ef9543..70b99fbb560b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -543,19 +543,22 @@ struct inode {
543 struct list_head i_dentry; 543 struct list_head i_dentry;
544 unsigned long i_ino; 544 unsigned long i_ino;
545 atomic_t i_count; 545 atomic_t i_count;
546 umode_t i_mode;
547 unsigned int i_nlink; 546 unsigned int i_nlink;
548 uid_t i_uid; 547 uid_t i_uid;
549 gid_t i_gid; 548 gid_t i_gid;
550 dev_t i_rdev; 549 dev_t i_rdev;
550 unsigned long i_version;
551 loff_t i_size; 551 loff_t i_size;
552#ifdef __NEED_I_SIZE_ORDERED
553 seqcount_t i_size_seqcount;
554#endif
552 struct timespec i_atime; 555 struct timespec i_atime;
553 struct timespec i_mtime; 556 struct timespec i_mtime;
554 struct timespec i_ctime; 557 struct timespec i_ctime;
555 unsigned int i_blkbits; 558 unsigned int i_blkbits;
556 unsigned long i_version;
557 blkcnt_t i_blocks; 559 blkcnt_t i_blocks;
558 unsigned short i_bytes; 560 unsigned short i_bytes;
561 umode_t i_mode;
559 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ 562 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
560 struct mutex i_mutex; 563 struct mutex i_mutex;
561 struct rw_semaphore i_alloc_sem; 564 struct rw_semaphore i_alloc_sem;
@@ -598,9 +601,6 @@ struct inode {
598 void *i_security; 601 void *i_security;
599#endif 602#endif
600 void *i_private; /* fs or device private pointer */ 603 void *i_private; /* fs or device private pointer */
601#ifdef __NEED_I_SIZE_ORDERED
602 seqcount_t i_size_seqcount;
603#endif
604}; 604};
605 605
606/* 606/*
@@ -636,7 +636,7 @@ extern void inode_double_unlock(struct inode *inode1, struct inode *inode2);
636 * cmpxchg8b without the need of the lock prefix). For SMP compiles 636 * cmpxchg8b without the need of the lock prefix). For SMP compiles
637 * and 64bit archs it makes no difference if preempt is enabled or not. 637 * and 64bit archs it makes no difference if preempt is enabled or not.
638 */ 638 */
639static inline loff_t i_size_read(struct inode *inode) 639static inline loff_t i_size_read(const struct inode *inode)
640{ 640{
641#if BITS_PER_LONG==32 && defined(CONFIG_SMP) 641#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
642 loff_t i_size; 642 loff_t i_size;
@@ -679,12 +679,12 @@ static inline void i_size_write(struct inode *inode, loff_t i_size)
679#endif 679#endif
680} 680}
681 681
682static inline unsigned iminor(struct inode *inode) 682static inline unsigned iminor(const struct inode *inode)
683{ 683{
684 return MINOR(inode->i_rdev); 684 return MINOR(inode->i_rdev);
685} 685}
686 686
687static inline unsigned imajor(struct inode *inode) 687static inline unsigned imajor(const struct inode *inode)
688{ 688{
689 return MAJOR(inode->i_rdev); 689 return MAJOR(inode->i_rdev);
690} 690}
@@ -1481,7 +1481,9 @@ extern char * getname(const char __user *);
1481extern void __init vfs_caches_init_early(void); 1481extern void __init vfs_caches_init_early(void);
1482extern void __init vfs_caches_init(unsigned long); 1482extern void __init vfs_caches_init(unsigned long);
1483 1483
1484#define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL) 1484extern struct kmem_cache *names_cachep;
1485
1486#define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL)
1485#define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) 1487#define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
1486#ifndef CONFIG_AUDITSYSCALL 1488#ifndef CONFIG_AUDITSYSCALL
1487#define putname(name) __putname(name) 1489#define putname(name) __putname(name)
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
index c623d12a486e..11a36ceddf73 100644
--- a/include/linux/fs_struct.h
+++ b/include/linux/fs_struct.h
@@ -18,6 +18,8 @@ struct fs_struct {
18 .umask = 0022, \ 18 .umask = 0022, \
19} 19}
20 20
21extern struct kmem_cache *fs_cachep;
22
21extern void exit_fs(struct task_struct *); 23extern void exit_fs(struct task_struct *);
22extern void set_fs_altroot(void); 24extern void set_fs_altroot(void);
23extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *); 25extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *);
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index 9fc48a674b82..534744efe30d 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -15,7 +15,7 @@
15#define FUSE_KERNEL_VERSION 7 15#define FUSE_KERNEL_VERSION 7
16 16
17/** Minor version number of this interface */ 17/** Minor version number of this interface */
18#define FUSE_KERNEL_MINOR_VERSION 7 18#define FUSE_KERNEL_MINOR_VERSION 8
19 19
20/** The node ID of the root inode */ 20/** The node ID of the root inode */
21#define FUSE_ROOT_ID 1 21#define FUSE_ROOT_ID 1
@@ -92,6 +92,11 @@ struct fuse_file_lock {
92#define FUSE_ASYNC_READ (1 << 0) 92#define FUSE_ASYNC_READ (1 << 0)
93#define FUSE_POSIX_LOCKS (1 << 1) 93#define FUSE_POSIX_LOCKS (1 << 1)
94 94
95/**
96 * Release flags
97 */
98#define FUSE_RELEASE_FLUSH (1 << 0)
99
95enum fuse_opcode { 100enum fuse_opcode {
96 FUSE_LOOKUP = 1, 101 FUSE_LOOKUP = 1,
97 FUSE_FORGET = 2, /* no reply */ 102 FUSE_FORGET = 2, /* no reply */
@@ -127,6 +132,8 @@ enum fuse_opcode {
127 FUSE_ACCESS = 34, 132 FUSE_ACCESS = 34,
128 FUSE_CREATE = 35, 133 FUSE_CREATE = 35,
129 FUSE_INTERRUPT = 36, 134 FUSE_INTERRUPT = 36,
135 FUSE_BMAP = 37,
136 FUSE_DESTROY = 38,
130}; 137};
131 138
132/* The read buffer is required to be at least 8k, but may be much larger */ 139/* The read buffer is required to be at least 8k, but may be much larger */
@@ -205,12 +212,13 @@ struct fuse_open_out {
205struct fuse_release_in { 212struct fuse_release_in {
206 __u64 fh; 213 __u64 fh;
207 __u32 flags; 214 __u32 flags;
208 __u32 padding; 215 __u32 release_flags;
216 __u64 lock_owner;
209}; 217};
210 218
211struct fuse_flush_in { 219struct fuse_flush_in {
212 __u64 fh; 220 __u64 fh;
213 __u32 flush_flags; 221 __u32 unused;
214 __u32 padding; 222 __u32 padding;
215 __u64 lock_owner; 223 __u64 lock_owner;
216}; 224};
@@ -296,6 +304,16 @@ struct fuse_interrupt_in {
296 __u64 unique; 304 __u64 unique;
297}; 305};
298 306
307struct fuse_bmap_in {
308 __u64 block;
309 __u32 blocksize;
310 __u32 padding;
311};
312
313struct fuse_bmap_out {
314 __u64 block;
315};
316
299struct fuse_in_header { 317struct fuse_in_header {
300 __u32 len; 318 __u32 len;
301 __u32 opcode; 319 __u32 opcode;
diff --git a/include/linux/genetlink.h b/include/linux/genetlink.h
index 9049dc65ae51..f7a93770e1be 100644
--- a/include/linux/genetlink.h
+++ b/include/linux/genetlink.h
@@ -17,6 +17,9 @@ struct genlmsghdr {
17#define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr)) 17#define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr))
18 18
19#define GENL_ADMIN_PERM 0x01 19#define GENL_ADMIN_PERM 0x01
20#define GENL_CMD_CAP_DO 0x02
21#define GENL_CMD_CAP_DUMP 0x04
22#define GENL_CMD_CAP_HASPOL 0x08
20 23
21/* 24/*
22 * List of reserved static generic netlink identifiers: 25 * List of reserved static generic netlink identifiers:
@@ -58,9 +61,6 @@ enum {
58 CTRL_ATTR_OP_UNSPEC, 61 CTRL_ATTR_OP_UNSPEC,
59 CTRL_ATTR_OP_ID, 62 CTRL_ATTR_OP_ID,
60 CTRL_ATTR_OP_FLAGS, 63 CTRL_ATTR_OP_FLAGS,
61 CTRL_ATTR_OP_POLICY,
62 CTRL_ATTR_OP_DOIT,
63 CTRL_ATTR_OP_DUMPIT,
64 __CTRL_ATTR_OP_MAX, 64 __CTRL_ATTR_OP_MAX,
65}; 65};
66 66
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index bf2b6bc3f6fd..00c314aedab7 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -116,6 +116,9 @@ static inline enum zone_type gfp_zone(gfp_t flags)
116#ifndef HAVE_ARCH_FREE_PAGE 116#ifndef HAVE_ARCH_FREE_PAGE
117static inline void arch_free_page(struct page *page, int order) { } 117static inline void arch_free_page(struct page *page, int order) { }
118#endif 118#endif
119#ifndef HAVE_ARCH_ALLOC_PAGE
120static inline void arch_alloc_page(struct page *page, int order) { }
121#endif
119 122
120extern struct page * 123extern struct page *
121FASTCALL(__alloc_pages(gfp_t, unsigned int, struct zonelist *)); 124FASTCALL(__alloc_pages(gfp_t, unsigned int, struct zonelist *));
diff --git a/include/linux/gfs2_ondisk.h b/include/linux/gfs2_ondisk.h
index a7ae7c177cac..8b7e4c1e32ae 100644
--- a/include/linux/gfs2_ondisk.h
+++ b/include/linux/gfs2_ondisk.h
@@ -54,8 +54,13 @@ struct gfs2_inum {
54 __be64 no_addr; 54 __be64 no_addr;
55}; 55};
56 56
57static inline int gfs2_inum_equal(const struct gfs2_inum *ino1, 57struct gfs2_inum_host {
58 const struct gfs2_inum *ino2) 58 __u64 no_formal_ino;
59 __u64 no_addr;
60};
61
62static inline int gfs2_inum_equal(const struct gfs2_inum_host *ino1,
63 const struct gfs2_inum_host *ino2)
59{ 64{
60 return ino1->no_formal_ino == ino2->no_formal_ino && 65 return ino1->no_formal_ino == ino2->no_formal_ino &&
61 ino1->no_addr == ino2->no_addr; 66 ino1->no_addr == ino2->no_addr;
@@ -89,6 +94,12 @@ struct gfs2_meta_header {
89 __be32 __pad1; /* Was incarnation number in gfs1 */ 94 __be32 __pad1; /* Was incarnation number in gfs1 */
90}; 95};
91 96
97struct gfs2_meta_header_host {
98 __u32 mh_magic;
99 __u32 mh_type;
100 __u32 mh_format;
101};
102
92/* 103/*
93 * super-block structure 104 * super-block structure
94 * 105 *
@@ -128,6 +139,23 @@ struct gfs2_sb {
128 /* In gfs1, quota and license dinodes followed */ 139 /* In gfs1, quota and license dinodes followed */
129}; 140};
130 141
142struct gfs2_sb_host {
143 struct gfs2_meta_header_host sb_header;
144
145 __u32 sb_fs_format;
146 __u32 sb_multihost_format;
147
148 __u32 sb_bsize;
149 __u32 sb_bsize_shift;
150
151 struct gfs2_inum_host sb_master_dir; /* Was jindex dinode in gfs1 */
152 struct gfs2_inum_host sb_root_dir;
153
154 char sb_lockproto[GFS2_LOCKNAME_LEN];
155 char sb_locktable[GFS2_LOCKNAME_LEN];
156 /* In gfs1, quota and license dinodes followed */
157};
158
131/* 159/*
132 * resource index structure 160 * resource index structure
133 */ 161 */
@@ -145,6 +173,14 @@ struct gfs2_rindex {
145 __u8 ri_reserved[64]; 173 __u8 ri_reserved[64];
146}; 174};
147 175
176struct gfs2_rindex_host {
177 __u64 ri_addr; /* grp block disk address */
178 __u64 ri_data0; /* first data location */
179 __u32 ri_length; /* length of rgrp header in fs blocks */
180 __u32 ri_data; /* num of data blocks in rgrp */
181 __u32 ri_bitbytes; /* number of bytes in data bitmaps */
182};
183
148/* 184/*
149 * resource group header structure 185 * resource group header structure
150 */ 186 */
@@ -176,6 +212,13 @@ struct gfs2_rgrp {
176 __u8 rg_reserved[80]; /* Several fields from gfs1 now reserved */ 212 __u8 rg_reserved[80]; /* Several fields from gfs1 now reserved */
177}; 213};
178 214
215struct gfs2_rgrp_host {
216 __u32 rg_flags;
217 __u32 rg_free;
218 __u32 rg_dinodes;
219 __u64 rg_igeneration;
220};
221
179/* 222/*
180 * quota structure 223 * quota structure
181 */ 224 */
@@ -187,6 +230,12 @@ struct gfs2_quota {
187 __u8 qu_reserved[64]; 230 __u8 qu_reserved[64];
188}; 231};
189 232
233struct gfs2_quota_host {
234 __u64 qu_limit;
235 __u64 qu_warn;
236 __u64 qu_value;
237};
238
190/* 239/*
191 * dinode structure 240 * dinode structure
192 */ 241 */
@@ -270,6 +319,27 @@ struct gfs2_dinode {
270 __u8 di_reserved[56]; 319 __u8 di_reserved[56];
271}; 320};
272 321
322struct gfs2_dinode_host {
323 __u64 di_size; /* number of bytes in file */
324 __u64 di_blocks; /* number of blocks in file */
325
326 /* This section varies from gfs1. Padding added to align with
327 * remainder of dinode
328 */
329 __u64 di_goal_meta; /* rgrp to alloc from next */
330 __u64 di_goal_data; /* data block goal */
331 __u64 di_generation; /* generation number for NFS */
332
333 __u32 di_flags; /* GFS2_DIF_... */
334 __u16 di_height; /* height of metadata */
335
336 /* These only apply to directories */
337 __u16 di_depth; /* Number of bits in the table */
338 __u32 di_entries; /* The number of entries in the directory */
339
340 __u64 di_eattr; /* extended attribute block number */
341};
342
273/* 343/*
274 * directory structure - many of these per directory file 344 * directory structure - many of these per directory file
275 */ 345 */
@@ -344,6 +414,16 @@ struct gfs2_log_header {
344 __be32 lh_hash; 414 __be32 lh_hash;
345}; 415};
346 416
417struct gfs2_log_header_host {
418 struct gfs2_meta_header_host lh_header;
419
420 __u64 lh_sequence; /* Sequence number of this transaction */
421 __u32 lh_flags; /* GFS2_LOG_HEAD_... */
422 __u32 lh_tail; /* Block number of log tail */
423 __u32 lh_blkno;
424 __u32 lh_hash;
425};
426
347/* 427/*
348 * Log type descriptor 428 * Log type descriptor
349 */ 429 */
@@ -384,6 +464,11 @@ struct gfs2_inum_range {
384 __be64 ir_length; 464 __be64 ir_length;
385}; 465};
386 466
467struct gfs2_inum_range_host {
468 __u64 ir_start;
469 __u64 ir_length;
470};
471
387/* 472/*
388 * Statfs change 473 * Statfs change
389 * Describes an change to the pool of free and allocated 474 * Describes an change to the pool of free and allocated
@@ -396,6 +481,12 @@ struct gfs2_statfs_change {
396 __be64 sc_dinodes; 481 __be64 sc_dinodes;
397}; 482};
398 483
484struct gfs2_statfs_change_host {
485 __u64 sc_total;
486 __u64 sc_free;
487 __u64 sc_dinodes;
488};
489
399/* 490/*
400 * Quota change 491 * Quota change
401 * Describes an allocation change for a particular 492 * Describes an allocation change for a particular
@@ -410,33 +501,38 @@ struct gfs2_quota_change {
410 __be32 qc_id; 501 __be32 qc_id;
411}; 502};
412 503
504struct gfs2_quota_change_host {
505 __u64 qc_change;
506 __u32 qc_flags; /* GFS2_QCF_... */
507 __u32 qc_id;
508};
509
413#ifdef __KERNEL__ 510#ifdef __KERNEL__
414/* Translation functions */ 511/* Translation functions */
415 512
416extern void gfs2_inum_in(struct gfs2_inum *no, const void *buf); 513extern void gfs2_inum_in(struct gfs2_inum_host *no, const void *buf);
417extern void gfs2_inum_out(const struct gfs2_inum *no, void *buf); 514extern void gfs2_inum_out(const struct gfs2_inum_host *no, void *buf);
418extern void gfs2_sb_in(struct gfs2_sb *sb, const void *buf); 515extern void gfs2_sb_in(struct gfs2_sb_host *sb, const void *buf);
419extern void gfs2_rindex_in(struct gfs2_rindex *ri, const void *buf); 516extern void gfs2_rindex_in(struct gfs2_rindex_host *ri, const void *buf);
420extern void gfs2_rindex_out(const struct gfs2_rindex *ri, void *buf); 517extern void gfs2_rindex_out(const struct gfs2_rindex_host *ri, void *buf);
421extern void gfs2_rgrp_in(struct gfs2_rgrp *rg, const void *buf); 518extern void gfs2_rgrp_in(struct gfs2_rgrp_host *rg, const void *buf);
422extern void gfs2_rgrp_out(const struct gfs2_rgrp *rg, void *buf); 519extern void gfs2_rgrp_out(const struct gfs2_rgrp_host *rg, void *buf);
423extern void gfs2_quota_in(struct gfs2_quota *qu, const void *buf); 520extern void gfs2_quota_in(struct gfs2_quota_host *qu, const void *buf);
424extern void gfs2_quota_out(const struct gfs2_quota *qu, void *buf); 521struct gfs2_inode;
425extern void gfs2_dinode_in(struct gfs2_dinode *di, const void *buf); 522extern void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
426extern void gfs2_dinode_out(const struct gfs2_dinode *di, void *buf);
427extern void gfs2_ea_header_in(struct gfs2_ea_header *ea, const void *buf); 523extern void gfs2_ea_header_in(struct gfs2_ea_header *ea, const void *buf);
428extern void gfs2_ea_header_out(const struct gfs2_ea_header *ea, void *buf); 524extern void gfs2_ea_header_out(const struct gfs2_ea_header *ea, void *buf);
429extern void gfs2_log_header_in(struct gfs2_log_header *lh, const void *buf); 525extern void gfs2_log_header_in(struct gfs2_log_header_host *lh, const void *buf);
430extern void gfs2_inum_range_in(struct gfs2_inum_range *ir, const void *buf); 526extern void gfs2_inum_range_in(struct gfs2_inum_range_host *ir, const void *buf);
431extern void gfs2_inum_range_out(const struct gfs2_inum_range *ir, void *buf); 527extern void gfs2_inum_range_out(const struct gfs2_inum_range_host *ir, void *buf);
432extern void gfs2_statfs_change_in(struct gfs2_statfs_change *sc, const void *buf); 528extern void gfs2_statfs_change_in(struct gfs2_statfs_change_host *sc, const void *buf);
433extern void gfs2_statfs_change_out(const struct gfs2_statfs_change *sc, void *buf); 529extern void gfs2_statfs_change_out(const struct gfs2_statfs_change_host *sc, void *buf);
434extern void gfs2_quota_change_in(struct gfs2_quota_change *qc, const void *buf); 530extern void gfs2_quota_change_in(struct gfs2_quota_change_host *qc, const void *buf);
435 531
436/* Printing functions */ 532/* Printing functions */
437 533
438extern void gfs2_rindex_print(const struct gfs2_rindex *ri); 534extern void gfs2_rindex_print(const struct gfs2_rindex_host *ri);
439extern void gfs2_dinode_print(const struct gfs2_dinode *di); 535extern void gfs2_dinode_print(const struct gfs2_inode *ip);
440 536
441#endif /* __KERNEL__ */ 537#endif /* __KERNEL__ */
442 538
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index fd7d12daa94f..3d8768b619e9 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/fs.h> 4#include <linux/fs.h>
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <linux/uaccess.h>
6 7
7#include <asm/cacheflush.h> 8#include <asm/cacheflush.h>
8 9
@@ -41,9 +42,10 @@ static inline void *kmap(struct page *page)
41 42
42#define kunmap(page) do { (void) (page); } while (0) 43#define kunmap(page) do { (void) (page); } while (0)
43 44
44#define kmap_atomic(page, idx) page_address(page) 45#define kmap_atomic(page, idx) \
45#define kunmap_atomic(addr, idx) do { } while (0) 46 ({ pagefault_disable(); page_address(page); })
46#define kmap_atomic_pfn(pfn, idx) page_address(pfn_to_page(pfn)) 47#define kunmap_atomic(addr, idx) do { pagefault_enable(); } while (0)
48#define kmap_atomic_pfn(pfn, idx) kmap_atomic(pfn_to_page(pfn), (idx))
47#define kmap_atomic_to_page(ptr) virt_to_page(ptr) 49#define kmap_atomic_to_page(ptr) virt_to_page(ptr)
48#endif 50#endif
49 51
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index ace64e57e17f..a60995afe334 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -35,6 +35,7 @@ extern int sysctl_hugetlb_shm_group;
35 35
36pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr); 36pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr);
37pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr); 37pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr);
38int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep);
38struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address, 39struct page *follow_huge_addr(struct mm_struct *mm, unsigned long address,
39 int write); 40 int write);
40struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address, 41struct page *follow_huge_pmd(struct mm_struct *mm, unsigned long address,
diff --git a/include/linux/i2o.h b/include/linux/i2o.h
index 1fb02e17f6f6..52f53e2e70c3 100644
--- a/include/linux/i2o.h
+++ b/include/linux/i2o.h
@@ -490,7 +490,7 @@ struct i2o_dma {
490 */ 490 */
491struct i2o_pool { 491struct i2o_pool {
492 char *name; 492 char *name;
493 kmem_cache_t *slab; 493 struct kmem_cache *slab;
494 mempool_t *mempool; 494 mempool_t *mempool;
495}; 495};
496 496
@@ -986,7 +986,8 @@ extern void i2o_driver_unregister(struct i2o_driver *);
986 986
987/** 987/**
988 * i2o_driver_notify_controller_add - Send notification of added controller 988 * i2o_driver_notify_controller_add - Send notification of added controller
989 * to a single I2O driver 989 * @drv: I2O driver
990 * @c: I2O controller
990 * 991 *
991 * Send notification of added controller to a single registered driver. 992 * Send notification of added controller to a single registered driver.
992 */ 993 */
@@ -998,8 +999,9 @@ static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv,
998}; 999};
999 1000
1000/** 1001/**
1001 * i2o_driver_notify_controller_remove - Send notification of removed 1002 * i2o_driver_notify_controller_remove - Send notification of removed controller
1002 * controller to a single I2O driver 1003 * @drv: I2O driver
1004 * @c: I2O controller
1003 * 1005 *
1004 * Send notification of removed controller to a single registered driver. 1006 * Send notification of removed controller to a single registered driver.
1005 */ 1007 */
@@ -1011,8 +1013,9 @@ static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv,
1011}; 1013};
1012 1014
1013/** 1015/**
1014 * i2o_driver_notify_device_add - Send notification of added device to a 1016 * i2o_driver_notify_device_add - Send notification of added device
1015 * single I2O driver 1017 * @drv: I2O driver
1018 * @i2o_dev: the added i2o_device
1016 * 1019 *
1017 * Send notification of added device to a single registered driver. 1020 * Send notification of added device to a single registered driver.
1018 */ 1021 */
@@ -1025,7 +1028,8 @@ static inline void i2o_driver_notify_device_add(struct i2o_driver *drv,
1025 1028
1026/** 1029/**
1027 * i2o_driver_notify_device_remove - Send notification of removed device 1030 * i2o_driver_notify_device_remove - Send notification of removed device
1028 * to a single I2O driver 1031 * @drv: I2O driver
1032 * @i2o_dev: the added i2o_device
1029 * 1033 *
1030 * Send notification of removed device to a single registered driver. 1034 * Send notification of removed device to a single registered driver.
1031 */ 1035 */
@@ -1148,7 +1152,7 @@ static inline void i2o_msg_post(struct i2o_controller *c,
1148/** 1152/**
1149 * i2o_msg_post_wait - Post and wait a message and wait until return 1153 * i2o_msg_post_wait - Post and wait a message and wait until return
1150 * @c: controller 1154 * @c: controller
1151 * @m: message to post 1155 * @msg: message to post
1152 * @timeout: time in seconds to wait 1156 * @timeout: time in seconds to wait
1153 * 1157 *
1154 * This API allows an OSM to post a message and then be told whether or 1158 * This API allows an OSM to post a message and then be told whether or
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 33c5daacc743..733790d4f7db 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -73,7 +73,7 @@
73extern struct nsproxy init_nsproxy; 73extern struct nsproxy init_nsproxy;
74#define INIT_NSPROXY(nsproxy) { \ 74#define INIT_NSPROXY(nsproxy) { \
75 .count = ATOMIC_INIT(1), \ 75 .count = ATOMIC_INIT(1), \
76 .nslock = SPIN_LOCK_UNLOCKED, \ 76 .nslock = __SPIN_LOCK_UNLOCKED(nsproxy.nslock), \
77 .uts_ns = &init_uts_ns, \ 77 .uts_ns = &init_uts_ns, \
78 .namespace = NULL, \ 78 .namespace = NULL, \
79 INIT_IPC_NS(ipc_ns) \ 79 INIT_IPC_NS(ipc_ns) \
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 5b83e7b59621..de7593f4e895 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -11,6 +11,7 @@
11#include <linux/hardirq.h> 11#include <linux/hardirq.h>
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/irqflags.h> 13#include <linux/irqflags.h>
14#include <linux/bottom_half.h>
14#include <asm/atomic.h> 15#include <asm/atomic.h>
15#include <asm/ptrace.h> 16#include <asm/ptrace.h>
16#include <asm/system.h> 17#include <asm/system.h>
@@ -217,12 +218,6 @@ static inline void __deprecated save_and_cli(unsigned long *x)
217#define save_and_cli(x) save_and_cli(&x) 218#define save_and_cli(x) save_and_cli(&x)
218#endif /* CONFIG_SMP */ 219#endif /* CONFIG_SMP */
219 220
220extern void local_bh_disable(void);
221extern void __local_bh_enable(void);
222extern void _local_bh_enable(void);
223extern void local_bh_enable(void);
224extern void local_bh_enable_ip(unsigned long ip);
225
226/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high 221/* PLEASE, avoid to allocate new softirqs, if you need not _really_ high
227 frequency threaded job scheduling. For almost all the purposes 222 frequency threaded job scheduling. For almost all the purposes
228 tasklets are more than enough. F.e. all serial device BHs et 223 tasklets are more than enough. F.e. all serial device BHs et
diff --git a/include/linux/ipmi.h b/include/linux/ipmi.h
index 796ca009fd46..7a9db390c56a 100644
--- a/include/linux/ipmi.h
+++ b/include/linux/ipmi.h
@@ -208,6 +208,15 @@ struct kernel_ipmi_msg
208 code as the first byte of the incoming data, unlike a response. */ 208 code as the first byte of the incoming data, unlike a response. */
209 209
210 210
211/*
212 * Modes for ipmi_set_maint_mode() and the userland IOCTL. The AUTO
213 * setting is the default and means it will be set on certain
214 * commands. Hard setting it on and off will override automatic
215 * operation.
216 */
217#define IPMI_MAINTENANCE_MODE_AUTO 0
218#define IPMI_MAINTENANCE_MODE_OFF 1
219#define IPMI_MAINTENANCE_MODE_ON 2
211 220
212#ifdef __KERNEL__ 221#ifdef __KERNEL__
213 222
@@ -374,6 +383,35 @@ int ipmi_unregister_for_cmd(ipmi_user_t user,
374 unsigned int chans); 383 unsigned int chans);
375 384
376/* 385/*
386 * Go into a mode where the driver will not autonomously attempt to do
387 * things with the interface. It will still respond to attentions and
388 * interrupts, and it will expect that commands will complete. It
389 * will not automatcially check for flags, events, or things of that
390 * nature.
391 *
392 * This is primarily used for firmware upgrades. The idea is that
393 * when you go into firmware upgrade mode, you do this operation
394 * and the driver will not attempt to do anything but what you tell
395 * it or what the BMC asks for.
396 *
397 * Note that if you send a command that resets the BMC, the driver
398 * will still expect a response from that command. So the BMC should
399 * reset itself *after* the response is sent. Resetting before the
400 * response is just silly.
401 *
402 * If in auto maintenance mode, the driver will automatically go into
403 * maintenance mode for 30 seconds if it sees a cold reset, a warm
404 * reset, or a firmware NetFN. This means that code that uses only
405 * firmware NetFN commands to do upgrades will work automatically
406 * without change, assuming it sends a message every 30 seconds or
407 * less.
408 *
409 * See the IPMI_MAINTENANCE_MODE_xxx defines for what the mode means.
410 */
411int ipmi_get_maintenance_mode(ipmi_user_t user);
412int ipmi_set_maintenance_mode(ipmi_user_t user, int mode);
413
414/*
377 * Allow run-to-completion mode to be set for the interface of 415 * Allow run-to-completion mode to be set for the interface of
378 * a specific user. 416 * a specific user.
379 */ 417 */
@@ -656,4 +694,11 @@ struct ipmi_timing_parms
656#define IPMICTL_GET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 23, \ 694#define IPMICTL_GET_TIMING_PARMS_CMD _IOR(IPMI_IOC_MAGIC, 23, \
657 struct ipmi_timing_parms) 695 struct ipmi_timing_parms)
658 696
697/*
698 * Set the maintenance mode. See ipmi_set_maintenance_mode() above
699 * for a description of what this does.
700 */
701#define IPMICTL_GET_MAINTENANCE_MODE_CMD _IOR(IPMI_IOC_MAGIC, 30, int)
702#define IPMICTL_SET_MAINTENANCE_MODE_CMD _IOW(IPMI_IOC_MAGIC, 31, int)
703
659#endif /* __LINUX_IPMI_H */ 704#endif /* __LINUX_IPMI_H */
diff --git a/include/linux/ipmi_msgdefs.h b/include/linux/ipmi_msgdefs.h
index 4d04d8b58a0a..b56a158d587a 100644
--- a/include/linux/ipmi_msgdefs.h
+++ b/include/linux/ipmi_msgdefs.h
@@ -46,6 +46,8 @@
46#define IPMI_NETFN_APP_REQUEST 0x06 46#define IPMI_NETFN_APP_REQUEST 0x06
47#define IPMI_NETFN_APP_RESPONSE 0x07 47#define IPMI_NETFN_APP_RESPONSE 0x07
48#define IPMI_GET_DEVICE_ID_CMD 0x01 48#define IPMI_GET_DEVICE_ID_CMD 0x01
49#define IPMI_COLD_RESET_CMD 0x02
50#define IPMI_WARM_RESET_CMD 0x03
49#define IPMI_CLEAR_MSG_FLAGS_CMD 0x30 51#define IPMI_CLEAR_MSG_FLAGS_CMD 0x30
50#define IPMI_GET_DEVICE_GUID_CMD 0x08 52#define IPMI_GET_DEVICE_GUID_CMD 0x08
51#define IPMI_GET_MSG_FLAGS_CMD 0x31 53#define IPMI_GET_MSG_FLAGS_CMD 0x31
@@ -60,20 +62,27 @@
60#define IPMI_NETFN_STORAGE_RESPONSE 0x0b 62#define IPMI_NETFN_STORAGE_RESPONSE 0x0b
61#define IPMI_ADD_SEL_ENTRY_CMD 0x44 63#define IPMI_ADD_SEL_ENTRY_CMD 0x44
62 64
65#define IPMI_NETFN_FIRMWARE_REQUEST 0x08
66#define IPMI_NETFN_FIRMWARE_RESPONSE 0x09
67
63/* The default slave address */ 68/* The default slave address */
64#define IPMI_BMC_SLAVE_ADDR 0x20 69#define IPMI_BMC_SLAVE_ADDR 0x20
65 70
66/* The BT interface on high-end HP systems supports up to 255 bytes in 71/* The BT interface on high-end HP systems supports up to 255 bytes in
67 * one transfer. Its "virtual" BMC supports some commands that are longer 72 * one transfer. Its "virtual" BMC supports some commands that are longer
68 * than 128 bytes. Use the full 256, plus NetFn/LUN, Cmd, cCode, plus 73 * than 128 bytes. Use the full 256, plus NetFn/LUN, Cmd, cCode, plus
69 * some overhead. It would be nice to base this on the "BT Capabilities" 74 * some overhead; it's not worth the effort to dynamically size this based
70 * but that's too hard to propagate to the rest of the driver. */ 75 * on the results of the "Get BT Capabilities" command. */
71#define IPMI_MAX_MSG_LENGTH 272 /* multiple of 16 */ 76#define IPMI_MAX_MSG_LENGTH 272 /* multiple of 16 */
72 77
73#define IPMI_CC_NO_ERROR 0x00 78#define IPMI_CC_NO_ERROR 0x00
74#define IPMI_NODE_BUSY_ERR 0xc0 79#define IPMI_NODE_BUSY_ERR 0xc0
75#define IPMI_INVALID_COMMAND_ERR 0xc1 80#define IPMI_INVALID_COMMAND_ERR 0xc1
81#define IPMI_TIMEOUT_ERR 0xc3
76#define IPMI_ERR_MSG_TRUNCATED 0xc6 82#define IPMI_ERR_MSG_TRUNCATED 0xc6
83#define IPMI_REQ_LEN_INVALID_ERR 0xc7
84#define IPMI_REQ_LEN_EXCEEDED_ERR 0xc8
85#define IPMI_NOT_IN_MY_STATE_ERR 0xd5 /* IPMI 2.0 */
77#define IPMI_LOST_ARBITRATION_ERR 0x81 86#define IPMI_LOST_ARBITRATION_ERR 0x81
78#define IPMI_BUS_ERR 0x82 87#define IPMI_BUS_ERR 0x82
79#define IPMI_NAK_ON_WRITE_ERR 0x83 88#define IPMI_NAK_ON_WRITE_ERR 0x83
diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
index 6d9c7e4da472..c0633108d05d 100644
--- a/include/linux/ipmi_smi.h
+++ b/include/linux/ipmi_smi.h
@@ -115,6 +115,13 @@ struct ipmi_smi_handlers
115 poll for operations during things like crash dumps. */ 115 poll for operations during things like crash dumps. */
116 void (*poll)(void *send_info); 116 void (*poll)(void *send_info);
117 117
118 /* Enable/disable firmware maintenance mode. Note that this
119 is *not* the modes defined, this is simply an on/off
120 setting. The message handler does the mode handling. Note
121 that this is called from interupt context, so it cannot
122 block. */
123 void (*set_maintenance_mode)(void *send_info, int enable);
124
118 /* Tell the handler that we are using it/not using it. The 125 /* Tell the handler that we are using it/not using it. The
119 message handler get the modules that this handler belongs 126 message handler get the modules that this handler belongs
120 to; this function lets the SMI claim any modules that it 127 to; this function lets the SMI claim any modules that it
@@ -173,6 +180,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
173 void *send_info, 180 void *send_info,
174 struct ipmi_device_id *device_id, 181 struct ipmi_device_id *device_id,
175 struct device *dev, 182 struct device *dev,
183 const char *sysfs_name,
176 unsigned char slave_addr); 184 unsigned char slave_addr);
177 185
178/* 186/*
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index fe89444b1c6f..452737551260 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -839,7 +839,6 @@ struct journal_s
839 */ 839 */
840 840
841/* Filing buffers */ 841/* Filing buffers */
842extern void __journal_temp_unlink_buffer(struct journal_head *jh);
843extern void journal_unfile_buffer(journal_t *, struct journal_head *); 842extern void journal_unfile_buffer(journal_t *, struct journal_head *);
844extern void __journal_unfile_buffer(struct journal_head *); 843extern void __journal_unfile_buffer(struct journal_head *);
845extern void __journal_refile_buffer(struct journal_head *); 844extern void __journal_refile_buffer(struct journal_head *);
@@ -949,7 +948,7 @@ void journal_put_journal_head(struct journal_head *jh);
949/* 948/*
950 * handle management 949 * handle management
951 */ 950 */
952extern kmem_cache_t *jbd_handle_cache; 951extern struct kmem_cache *jbd_handle_cache;
953 952
954static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags) 953static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
955{ 954{
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index ddb128795781..0e0fedd2039a 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -848,7 +848,6 @@ struct journal_s
848 */ 848 */
849 849
850/* Filing buffers */ 850/* Filing buffers */
851extern void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh);
852extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *); 851extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *);
853extern void __jbd2_journal_unfile_buffer(struct journal_head *); 852extern void __jbd2_journal_unfile_buffer(struct journal_head *);
854extern void __jbd2_journal_refile_buffer(struct journal_head *); 853extern void __jbd2_journal_refile_buffer(struct journal_head *);
@@ -958,7 +957,7 @@ void jbd2_journal_put_journal_head(struct journal_head *jh);
958/* 957/*
959 * handle management 958 * handle management
960 */ 959 */
961extern kmem_cache_t *jbd2_handle_cache; 960extern struct kmem_cache *jbd2_handle_cache;
962 961
963static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags) 962static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
964{ 963{
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index a4ede62b339d..e3abcec6c51c 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -105,6 +105,7 @@ extern struct page *kimage_alloc_control_pages(struct kimage *image,
105 unsigned int order); 105 unsigned int order);
106extern void crash_kexec(struct pt_regs *); 106extern void crash_kexec(struct pt_regs *);
107int kexec_should_crash(struct task_struct *); 107int kexec_should_crash(struct task_struct *);
108void crash_save_cpu(struct pt_regs *regs, int cpu);
108extern struct kimage *kexec_image; 109extern struct kimage *kexec_image;
109extern struct kimage *kexec_crash_image; 110extern struct kimage *kexec_crash_image;
110 111
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index ac4c0559f751..769be39b9681 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -165,7 +165,7 @@ extern void arch_disarm_kprobe(struct kprobe *p);
165extern int arch_init_kprobes(void); 165extern int arch_init_kprobes(void);
166extern void show_registers(struct pt_regs *regs); 166extern void show_registers(struct pt_regs *regs);
167extern kprobe_opcode_t *get_insn_slot(void); 167extern kprobe_opcode_t *get_insn_slot(void);
168extern void free_insn_slot(kprobe_opcode_t *slot); 168extern void free_insn_slot(kprobe_opcode_t *slot, int dirty);
169extern void kprobes_inc_nmissed_count(struct kprobe *p); 169extern void kprobes_inc_nmissed_count(struct kprobe *p);
170 170
171/* Get the kprobe at this addr (if any) - called with preemption disabled */ 171/* Get the kprobe at this addr (if any) - called with preemption disabled */
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 84eeecd60a02..611f17f79eef 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -248,9 +248,9 @@ static inline struct timeval ktime_to_timeval(const ktime_t kt)
248 * 248 *
249 * Returns the scalar nanoseconds representation of kt 249 * Returns the scalar nanoseconds representation of kt
250 */ 250 */
251static inline u64 ktime_to_ns(const ktime_t kt) 251static inline s64 ktime_to_ns(const ktime_t kt)
252{ 252{
253 return (u64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec; 253 return (s64) kt.tv.sec * NSEC_PER_SEC + kt.tv.nsec;
254} 254}
255 255
256#endif 256#endif
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index 862d9730a60d..8c39654549d8 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -164,14 +164,12 @@ void nlmclnt_next_cookie(struct nlm_cookie *);
164 */ 164 */
165struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int, const char *, int); 165struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int, const char *, int);
166struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *, const char *, int); 166struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *, const char *, int);
167struct nlm_host * nlm_lookup_host(int server, const struct sockaddr_in *, int, int, const char *, int);
168struct rpc_clnt * nlm_bind_host(struct nlm_host *); 167struct rpc_clnt * nlm_bind_host(struct nlm_host *);
169void nlm_rebind_host(struct nlm_host *); 168void nlm_rebind_host(struct nlm_host *);
170struct nlm_host * nlm_get_host(struct nlm_host *); 169struct nlm_host * nlm_get_host(struct nlm_host *);
171void nlm_release_host(struct nlm_host *); 170void nlm_release_host(struct nlm_host *);
172void nlm_shutdown_hosts(void); 171void nlm_shutdown_hosts(void);
173extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, int, u32); 172extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, int, u32);
174struct nsm_handle *nsm_find(const struct sockaddr_in *, const char *, int);
175void nsm_release(struct nsm_handle *); 173void nsm_release(struct nsm_handle *);
176 174
177 175
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 819f08f1310d..498bfbd3b4e1 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -193,7 +193,6 @@ extern void lockdep_free_key_range(void *start, unsigned long size);
193 193
194extern void lockdep_off(void); 194extern void lockdep_off(void);
195extern void lockdep_on(void); 195extern void lockdep_on(void);
196extern int lockdep_internal(void);
197 196
198/* 197/*
199 * These methods are used by specific locking variants (spinlocks, 198 * These methods are used by specific locking variants (spinlocks,
@@ -243,6 +242,8 @@ extern void lock_release(struct lockdep_map *lock, int nested,
243 242
244# define INIT_LOCKDEP .lockdep_recursion = 0, 243# define INIT_LOCKDEP .lockdep_recursion = 0,
245 244
245#define lockdep_depth(tsk) ((tsk)->lockdep_depth)
246
246#else /* !LOCKDEP */ 247#else /* !LOCKDEP */
247 248
248static inline void lockdep_off(void) 249static inline void lockdep_off(void)
@@ -253,11 +254,6 @@ static inline void lockdep_on(void)
253{ 254{
254} 255}
255 256
256static inline int lockdep_internal(void)
257{
258 return 0;
259}
260
261# define lock_acquire(l, s, t, r, c, i) do { } while (0) 257# define lock_acquire(l, s, t, r, c, i) do { } while (0)
262# define lock_release(l, n, i) do { } while (0) 258# define lock_release(l, n, i) do { } while (0)
263# define lockdep_init() do { } while (0) 259# define lockdep_init() do { } while (0)
@@ -277,6 +273,9 @@ static inline int lockdep_internal(void)
277 * The class key takes no space if lockdep is disabled: 273 * The class key takes no space if lockdep is disabled:
278 */ 274 */
279struct lock_class_key { }; 275struct lock_class_key { };
276
277#define lockdep_depth(tsk) (0)
278
280#endif /* !LOCKDEP */ 279#endif /* !LOCKDEP */
281 280
282#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS) 281#if defined(CONFIG_TRACE_IRQFLAGS) && defined(CONFIG_GENERIC_HARDIRQS)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index d538de901965..a17b147c61e7 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -114,6 +114,8 @@ struct vm_area_struct {
114#endif 114#endif
115}; 115};
116 116
117extern struct kmem_cache *vm_area_cachep;
118
117/* 119/*
118 * This struct defines the per-mm list of VMAs for uClinux. If CONFIG_MMU is 120 * This struct defines the per-mm list of VMAs for uClinux. If CONFIG_MMU is
119 * disabled, then there's a single shared list of VMAs maintained by the 121 * disabled, then there's a single shared list of VMAs maintained by the
@@ -294,6 +296,24 @@ void put_pages_list(struct list_head *pages);
294void split_page(struct page *page, unsigned int order); 296void split_page(struct page *page, unsigned int order);
295 297
296/* 298/*
299 * Compound pages have a destructor function. Provide a
300 * prototype for that function and accessor functions.
301 * These are _only_ valid on the head of a PG_compound page.
302 */
303typedef void compound_page_dtor(struct page *);
304
305static inline void set_compound_page_dtor(struct page *page,
306 compound_page_dtor *dtor)
307{
308 page[1].lru.next = (void *)dtor;
309}
310
311static inline compound_page_dtor *get_compound_page_dtor(struct page *page)
312{
313 return (compound_page_dtor *)page[1].lru.next;
314}
315
316/*
297 * Multiple processes may "see" the same page. E.g. for untouched 317 * Multiple processes may "see" the same page. E.g. for untouched
298 * mappings of /dev/null, all processes see the same page full of 318 * mappings of /dev/null, all processes see the same page full of
299 * zeroes, and text pages of executables and shared libraries have 319 * zeroes, and text pages of executables and shared libraries have
@@ -396,7 +416,9 @@ void split_page(struct page *page, unsigned int order);
396 * We are going to use the flags for the page to node mapping if its in 416 * We are going to use the flags for the page to node mapping if its in
397 * there. This includes the case where there is no node, so it is implicit. 417 * there. This includes the case where there is no node, so it is implicit.
398 */ 418 */
399#define FLAGS_HAS_NODE (NODES_WIDTH > 0 || NODES_SHIFT == 0) 419#if !(NODES_WIDTH > 0 || NODES_SHIFT == 0)
420#define NODE_NOT_IN_PAGE_FLAGS
421#endif
400 422
401#ifndef PFN_SECTION_SHIFT 423#ifndef PFN_SECTION_SHIFT
402#define PFN_SECTION_SHIFT 0 424#define PFN_SECTION_SHIFT 0
@@ -411,13 +433,18 @@ void split_page(struct page *page, unsigned int order);
411#define NODES_PGSHIFT (NODES_PGOFF * (NODES_WIDTH != 0)) 433#define NODES_PGSHIFT (NODES_PGOFF * (NODES_WIDTH != 0))
412#define ZONES_PGSHIFT (ZONES_PGOFF * (ZONES_WIDTH != 0)) 434#define ZONES_PGSHIFT (ZONES_PGOFF * (ZONES_WIDTH != 0))
413 435
414/* NODE:ZONE or SECTION:ZONE is used to lookup the zone from a page. */ 436/* NODE:ZONE or SECTION:ZONE is used to ID a zone for the buddy allcator */
415#if FLAGS_HAS_NODE 437#ifdef NODE_NOT_IN_PAGEFLAGS
416#define ZONETABLE_SHIFT (NODES_SHIFT + ZONES_SHIFT) 438#define ZONEID_SHIFT (SECTIONS_SHIFT + ZONES_SHIFT)
439#else
440#define ZONEID_SHIFT (NODES_SHIFT + ZONES_SHIFT)
441#endif
442
443#if ZONES_WIDTH > 0
444#define ZONEID_PGSHIFT ZONES_PGSHIFT
417#else 445#else
418#define ZONETABLE_SHIFT (SECTIONS_SHIFT + ZONES_SHIFT) 446#define ZONEID_PGSHIFT NODES_PGOFF
419#endif 447#endif
420#define ZONETABLE_PGSHIFT ZONES_PGSHIFT
421 448
422#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED 449#if SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
423#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED 450#error SECTIONS_WIDTH+NODES_WIDTH+ZONES_WIDTH > FLAGS_RESERVED
@@ -426,26 +453,28 @@ void split_page(struct page *page, unsigned int order);
426#define ZONES_MASK ((1UL << ZONES_WIDTH) - 1) 453#define ZONES_MASK ((1UL << ZONES_WIDTH) - 1)
427#define NODES_MASK ((1UL << NODES_WIDTH) - 1) 454#define NODES_MASK ((1UL << NODES_WIDTH) - 1)
428#define SECTIONS_MASK ((1UL << SECTIONS_WIDTH) - 1) 455#define SECTIONS_MASK ((1UL << SECTIONS_WIDTH) - 1)
429#define ZONETABLE_MASK ((1UL << ZONETABLE_SHIFT) - 1) 456#define ZONEID_MASK ((1UL << ZONEID_SHIFT) - 1)
430 457
431static inline enum zone_type page_zonenum(struct page *page) 458static inline enum zone_type page_zonenum(struct page *page)
432{ 459{
433 return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK; 460 return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK;
434} 461}
435 462
436struct zone; 463/*
437extern struct zone *zone_table[]; 464 * The identification function is only used by the buddy allocator for
438 465 * determining if two pages could be buddies. We are not really
466 * identifying a zone since we could be using a the section number
467 * id if we have not node id available in page flags.
468 * We guarantee only that it will return the same value for two
469 * combinable pages in a zone.
470 */
439static inline int page_zone_id(struct page *page) 471static inline int page_zone_id(struct page *page)
440{ 472{
441 return (page->flags >> ZONETABLE_PGSHIFT) & ZONETABLE_MASK; 473 BUILD_BUG_ON(ZONEID_PGSHIFT == 0 && ZONEID_MASK);
442} 474 return (page->flags >> ZONEID_PGSHIFT) & ZONEID_MASK;
443static inline struct zone *page_zone(struct page *page)
444{
445 return zone_table[page_zone_id(page)];
446} 475}
447 476
448static inline unsigned long zone_to_nid(struct zone *zone) 477static inline int zone_to_nid(struct zone *zone)
449{ 478{
450#ifdef CONFIG_NUMA 479#ifdef CONFIG_NUMA
451 return zone->node; 480 return zone->node;
@@ -454,13 +483,20 @@ static inline unsigned long zone_to_nid(struct zone *zone)
454#endif 483#endif
455} 484}
456 485
457static inline unsigned long page_to_nid(struct page *page) 486#ifdef NODE_NOT_IN_PAGE_FLAGS
487extern int page_to_nid(struct page *page);
488#else
489static inline int page_to_nid(struct page *page)
490{
491 return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
492}
493#endif
494
495static inline struct zone *page_zone(struct page *page)
458{ 496{
459 if (FLAGS_HAS_NODE) 497 return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)];
460 return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
461 else
462 return zone_to_nid(page_zone(page));
463} 498}
499
464static inline unsigned long page_to_section(struct page *page) 500static inline unsigned long page_to_section(struct page *page)
465{ 501{
466 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK; 502 return (page->flags >> SECTIONS_PGSHIFT) & SECTIONS_MASK;
@@ -477,6 +513,7 @@ static inline void set_page_node(struct page *page, unsigned long node)
477 page->flags &= ~(NODES_MASK << NODES_PGSHIFT); 513 page->flags &= ~(NODES_MASK << NODES_PGSHIFT);
478 page->flags |= (node & NODES_MASK) << NODES_PGSHIFT; 514 page->flags |= (node & NODES_MASK) << NODES_PGSHIFT;
479} 515}
516
480static inline void set_page_section(struct page *page, unsigned long section) 517static inline void set_page_section(struct page *page, unsigned long section)
481{ 518{
482 page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT); 519 page->flags &= ~(SECTIONS_MASK << SECTIONS_PGSHIFT);
@@ -947,8 +984,6 @@ extern void mem_init(void);
947extern void show_mem(void); 984extern void show_mem(void);
948extern void si_meminfo(struct sysinfo * val); 985extern void si_meminfo(struct sysinfo * val);
949extern void si_meminfo_node(struct sysinfo *val, int nid); 986extern void si_meminfo_node(struct sysinfo *val, int nid);
950extern void zonetable_add(struct zone *zone, int nid, enum zone_type zid,
951 unsigned long pfn, unsigned long size);
952 987
953#ifdef CONFIG_NUMA 988#ifdef CONFIG_NUMA
954extern void setup_per_cpu_pageset(void); 989extern void setup_per_cpu_pageset(void);
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index e06683e2bea3..e339a7345f25 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -278,7 +278,7 @@ struct zone {
278 /* 278 /*
279 * rarely used fields: 279 * rarely used fields:
280 */ 280 */
281 char *name; 281 const char *name;
282} ____cacheline_internodealigned_in_smp; 282} ____cacheline_internodealigned_in_smp;
283 283
284/* 284/*
@@ -288,19 +288,94 @@ struct zone {
288 */ 288 */
289#define DEF_PRIORITY 12 289#define DEF_PRIORITY 12
290 290
291/* Maximum number of zones on a zonelist */
292#define MAX_ZONES_PER_ZONELIST (MAX_NUMNODES * MAX_NR_ZONES)
293
294#ifdef CONFIG_NUMA
295/*
296 * We cache key information from each zonelist for smaller cache
297 * footprint when scanning for free pages in get_page_from_freelist().
298 *
299 * 1) The BITMAP fullzones tracks which zones in a zonelist have come
300 * up short of free memory since the last time (last_fullzone_zap)
301 * we zero'd fullzones.
302 * 2) The array z_to_n[] maps each zone in the zonelist to its node
303 * id, so that we can efficiently evaluate whether that node is
304 * set in the current tasks mems_allowed.
305 *
306 * Both fullzones and z_to_n[] are one-to-one with the zonelist,
307 * indexed by a zones offset in the zonelist zones[] array.
308 *
309 * The get_page_from_freelist() routine does two scans. During the
310 * first scan, we skip zones whose corresponding bit in 'fullzones'
311 * is set or whose corresponding node in current->mems_allowed (which
312 * comes from cpusets) is not set. During the second scan, we bypass
313 * this zonelist_cache, to ensure we look methodically at each zone.
314 *
315 * Once per second, we zero out (zap) fullzones, forcing us to
316 * reconsider nodes that might have regained more free memory.
317 * The field last_full_zap is the time we last zapped fullzones.
318 *
319 * This mechanism reduces the amount of time we waste repeatedly
320 * reexaming zones for free memory when they just came up low on
321 * memory momentarilly ago.
322 *
323 * The zonelist_cache struct members logically belong in struct
324 * zonelist. However, the mempolicy zonelists constructed for
325 * MPOL_BIND are intentionally variable length (and usually much
326 * shorter). A general purpose mechanism for handling structs with
327 * multiple variable length members is more mechanism than we want
328 * here. We resort to some special case hackery instead.
329 *
330 * The MPOL_BIND zonelists don't need this zonelist_cache (in good
331 * part because they are shorter), so we put the fixed length stuff
332 * at the front of the zonelist struct, ending in a variable length
333 * zones[], as is needed by MPOL_BIND.
334 *
335 * Then we put the optional zonelist cache on the end of the zonelist
336 * struct. This optional stuff is found by a 'zlcache_ptr' pointer in
337 * the fixed length portion at the front of the struct. This pointer
338 * both enables us to find the zonelist cache, and in the case of
339 * MPOL_BIND zonelists, (which will just set the zlcache_ptr to NULL)
340 * to know that the zonelist cache is not there.
341 *
342 * The end result is that struct zonelists come in two flavors:
343 * 1) The full, fixed length version, shown below, and
344 * 2) The custom zonelists for MPOL_BIND.
345 * The custom MPOL_BIND zonelists have a NULL zlcache_ptr and no zlcache.
346 *
347 * Even though there may be multiple CPU cores on a node modifying
348 * fullzones or last_full_zap in the same zonelist_cache at the same
349 * time, we don't lock it. This is just hint data - if it is wrong now
350 * and then, the allocator will still function, perhaps a bit slower.
351 */
352
353
354struct zonelist_cache {
355 unsigned short z_to_n[MAX_ZONES_PER_ZONELIST]; /* zone->nid */
356 DECLARE_BITMAP(fullzones, MAX_ZONES_PER_ZONELIST); /* zone full? */
357 unsigned long last_full_zap; /* when last zap'd (jiffies) */
358};
359#else
360struct zonelist_cache;
361#endif
362
291/* 363/*
292 * One allocation request operates on a zonelist. A zonelist 364 * One allocation request operates on a zonelist. A zonelist
293 * is a list of zones, the first one is the 'goal' of the 365 * is a list of zones, the first one is the 'goal' of the
294 * allocation, the other zones are fallback zones, in decreasing 366 * allocation, the other zones are fallback zones, in decreasing
295 * priority. 367 * priority.
296 * 368 *
297 * Right now a zonelist takes up less than a cacheline. We never 369 * If zlcache_ptr is not NULL, then it is just the address of zlcache,
298 * modify it apart from boot-up, and only a few indices are used, 370 * as explained above. If zlcache_ptr is NULL, there is no zlcache.
299 * so despite the zonelist table being relatively big, the cache
300 * footprint of this construct is very small.
301 */ 371 */
372
302struct zonelist { 373struct zonelist {
303 struct zone *zones[MAX_NUMNODES * MAX_NR_ZONES + 1]; // NULL delimited 374 struct zonelist_cache *zlcache_ptr; // NULL or &zlcache
375 struct zone *zones[MAX_ZONES_PER_ZONELIST + 1]; // NULL delimited
376#ifdef CONFIG_NUMA
377 struct zonelist_cache zlcache; // optional ...
378#endif
304}; 379};
305 380
306#ifdef CONFIG_ARCH_POPULATES_NODE_MAP 381#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 7c0c2c198f1f..4a189dadb160 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -63,6 +63,9 @@ struct kparam_array
63 not there, read bits mean it's readable, write bits mean it's 63 not there, read bits mean it's readable, write bits mean it's
64 writable. */ 64 writable. */
65#define __module_param_call(prefix, name, set, get, arg, perm) \ 65#define __module_param_call(prefix, name, set, get, arg, perm) \
66 /* Default value instead of permissions? */ \
67 static int __param_perm_check_##name __attribute__((unused)) = \
68 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \
66 static char __param_str_##name[] = prefix #name; \ 69 static char __param_str_##name[] = prefix #name; \
67 static struct kernel_param const __param_##name \ 70 static struct kernel_param const __param_##name \
68 __attribute_used__ \ 71 __attribute_used__ \
diff --git a/include/linux/msg.h b/include/linux/msg.h
index acc7c174ff00..f1b60740d641 100644
--- a/include/linux/msg.h
+++ b/include/linux/msg.h
@@ -92,6 +92,12 @@ struct msg_queue {
92 struct list_head q_senders; 92 struct list_head q_senders;
93}; 93};
94 94
95/* Helper routines for sys_msgsnd and sys_msgrcv */
96extern long do_msgsnd(int msqid, long mtype, void __user *mtext,
97 size_t msgsz, int msgflg);
98extern long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
99 size_t msgsz, long msgtyp, int msgflg);
100
95#endif /* __KERNEL__ */ 101#endif /* __KERNEL__ */
96 102
97#endif /* _LINUX_MSG_H */ 103#endif /* _LINUX_MSG_H */
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index 27c48daa3183..b2b91c477563 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -94,7 +94,7 @@ do { \
94 94
95#define __MUTEX_INITIALIZER(lockname) \ 95#define __MUTEX_INITIALIZER(lockname) \
96 { .count = ATOMIC_INIT(1) \ 96 { .count = ATOMIC_INIT(1) \
97 , .wait_lock = SPIN_LOCK_UNLOCKED \ 97 , .wait_lock = __SPIN_LOCK_UNLOCKED(lockname.wait_lock) \
98 , .wait_list = LIST_HEAD_INIT(lockname.wait_list) \ 98 , .wait_list = LIST_HEAD_INIT(lockname.wait_list) \
99 __DEBUG_MUTEX_INITIALIZER(lockname) \ 99 __DEBUG_MUTEX_INITIALIZER(lockname) \
100 __DEP_MAP_MUTEX_INITIALIZER(lockname) } 100 __DEP_MAP_MUTEX_INITIALIZER(lockname) }
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index d6b6dc09ad97..0f3e69302540 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -64,6 +64,7 @@ struct nbd_device {
64 struct gendisk *disk; 64 struct gendisk *disk;
65 int blksize; 65 int blksize;
66 u64 bytesize; 66 u64 bytesize;
67 pid_t pid; /* pid of nbd-client, if attached */
67}; 68};
68 69
69#endif 70#endif
diff --git a/include/linux/netfilter/nf_conntrack_pptp.h b/include/linux/netfilter/nf_conntrack_pptp.h
index fb049ec11ff2..9d8144a488cd 100644
--- a/include/linux/netfilter/nf_conntrack_pptp.h
+++ b/include/linux/netfilter/nf_conntrack_pptp.h
@@ -2,6 +2,8 @@
2#ifndef _NF_CONNTRACK_PPTP_H 2#ifndef _NF_CONNTRACK_PPTP_H
3#define _NF_CONNTRACK_PPTP_H 3#define _NF_CONNTRACK_PPTP_H
4 4
5#include <linux/netfilter/nf_conntrack_common.h>
6
5/* state of the control session */ 7/* state of the control session */
6enum pptp_ctrlsess_state { 8enum pptp_ctrlsess_state {
7 PPTP_SESSION_NONE, /* no session present */ 9 PPTP_SESSION_NONE, /* no session present */
@@ -295,7 +297,6 @@ union pptp_ctrl_union {
295/* crap needed for nf_conntrack_compat.h */ 297/* crap needed for nf_conntrack_compat.h */
296struct nf_conn; 298struct nf_conn;
297struct nf_conntrack_expect; 299struct nf_conntrack_expect;
298enum ip_conntrack_info;
299 300
300extern int 301extern int
301(*nf_nat_pptp_hook_outbound)(struct sk_buff **pskb, 302(*nf_nat_pptp_hook_outbound)(struct sk_buff **pskb,
diff --git a/include/linux/nmi.h b/include/linux/nmi.h
index e16904e28c3a..acb4ed130247 100644
--- a/include/linux/nmi.h
+++ b/include/linux/nmi.h
@@ -15,9 +15,14 @@
15 * disables interrupts for a long time. This call is stateless. 15 * disables interrupts for a long time. This call is stateless.
16 */ 16 */
17#ifdef ARCH_HAS_NMI_WATCHDOG 17#ifdef ARCH_HAS_NMI_WATCHDOG
18#include <asm/nmi.h>
18extern void touch_nmi_watchdog(void); 19extern void touch_nmi_watchdog(void);
19#else 20#else
20# define touch_nmi_watchdog() touch_softlockup_watchdog() 21# define touch_nmi_watchdog() touch_softlockup_watchdog()
21#endif 22#endif
22 23
24#ifndef trigger_all_cpu_backtrace
25#define trigger_all_cpu_backtrace() do { } while (0)
26#endif
27
23#endif 28#endif
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index c09da1e30c54..4d972bbef316 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -390,7 +390,7 @@
390#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d 390#define PCI_DEVICE_ID_NS_CS5535_IDE 0x002d
391#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e 391#define PCI_DEVICE_ID_NS_CS5535_AUDIO 0x002e
392#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f 392#define PCI_DEVICE_ID_NS_CS5535_USB 0x002f
393#define PCI_DEVICE_ID_NS_CS5535_VIDEO 0x0030 393#define PCI_DEVICE_ID_NS_GX_VIDEO 0x0030
394#define PCI_DEVICE_ID_NS_SATURN 0x0035 394#define PCI_DEVICE_ID_NS_SATURN 0x0035
395#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500 395#define PCI_DEVICE_ID_NS_SCx200_BRIDGE 0x0500
396#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501 396#define PCI_DEVICE_ID_NS_SCx200_SMI 0x0501
@@ -403,8 +403,7 @@
403#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515 403#define PCI_DEVICE_ID_NS_SC1100_XBUS 0x0515
404#define PCI_DEVICE_ID_NS_87410 0xd001 404#define PCI_DEVICE_ID_NS_87410 0xd001
405 405
406#define PCI_DEVICE_ID_NS_CS5535_HOST_BRIDGE 0x0028 406#define PCI_DEVICE_ID_NS_GX_HOST_BRIDGE 0x0028
407#define PCI_DEVICE_ID_NS_CS5535_ISA_BRIDGE 0x002b
408 407
409#define PCI_VENDOR_ID_TSENG 0x100c 408#define PCI_VENDOR_ID_TSENG 0x100c
410#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202 409#define PCI_DEVICE_ID_TSENG_W32P_2 0x3202
@@ -1864,6 +1863,7 @@
1864#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511 1863#define PCI_DEVICE_ID_OXSEMI_16PCI95N 0x9511
1865#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513 1864#define PCI_DEVICE_ID_OXSEMI_16PCI954PP 0x9513
1866#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x9521 1865#define PCI_DEVICE_ID_OXSEMI_16PCI952 0x9521
1866#define PCI_DEVICE_ID_OXSEMI_16PCI952PP 0x9523
1867 1867
1868#define PCI_VENDOR_ID_SAMSUNG 0x144d 1868#define PCI_VENDOR_ID_SAMSUNG 0x144d
1869 1869
@@ -1931,6 +1931,7 @@
1931#define PCI_DEVICE_ID_TIGON3_5750M 0x167c 1931#define PCI_DEVICE_ID_TIGON3_5750M 0x167c
1932#define PCI_DEVICE_ID_TIGON3_5751M 0x167d 1932#define PCI_DEVICE_ID_TIGON3_5751M 0x167d
1933#define PCI_DEVICE_ID_TIGON3_5751F 0x167e 1933#define PCI_DEVICE_ID_TIGON3_5751F 0x167e
1934#define PCI_DEVICE_ID_TIGON3_5787F 0x167f
1934#define PCI_DEVICE_ID_TIGON3_5787M 0x1693 1935#define PCI_DEVICE_ID_TIGON3_5787M 0x1693
1935#define PCI_DEVICE_ID_TIGON3_5782 0x1696 1936#define PCI_DEVICE_ID_TIGON3_5782 0x1696
1936#define PCI_DEVICE_ID_TIGON3_5786 0x169a 1937#define PCI_DEVICE_ID_TIGON3_5786 0x169a
@@ -2002,6 +2003,8 @@
2002#define PCI_DEVICE_ID_FARSITE_TE1 0x1610 2003#define PCI_DEVICE_ID_FARSITE_TE1 0x1610
2003#define PCI_DEVICE_ID_FARSITE_TE1C 0x1612 2004#define PCI_DEVICE_ID_FARSITE_TE1C 0x1612
2004 2005
2006#define PCI_VENDOR_ID_ARIMA 0x161f
2007
2005#define PCI_VENDOR_ID_SIBYTE 0x166d 2008#define PCI_VENDOR_ID_SIBYTE 0x166d
2006#define PCI_DEVICE_ID_BCM1250_PCI 0x0001 2009#define PCI_DEVICE_ID_BCM1250_PCI 0x0001
2007#define PCI_DEVICE_ID_BCM1250_HT 0x0002 2010#define PCI_DEVICE_ID_BCM1250_HT 0x0002
diff --git a/include/linux/pfkeyv2.h b/include/linux/pfkeyv2.h
index 0f0b880c4280..265bafab6494 100644
--- a/include/linux/pfkeyv2.h
+++ b/include/linux/pfkeyv2.h
@@ -285,6 +285,7 @@ struct sadb_x_sec_ctx {
285#define SADB_X_AALG_SHA2_384HMAC 6 285#define SADB_X_AALG_SHA2_384HMAC 6
286#define SADB_X_AALG_SHA2_512HMAC 7 286#define SADB_X_AALG_SHA2_512HMAC 7
287#define SADB_X_AALG_RIPEMD160HMAC 8 287#define SADB_X_AALG_RIPEMD160HMAC 8
288#define SADB_X_AALG_AES_XCBC_MAC 9
288#define SADB_X_AALG_NULL 251 /* kame */ 289#define SADB_X_AALG_NULL 251 /* kame */
289#define SADB_AALG_MAX 251 290#define SADB_AALG_MAX 251
290 291
diff --git a/include/linux/profile.h b/include/linux/profile.h
index acce53fd38b6..5670b340c4ef 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -6,10 +6,15 @@
6#include <linux/kernel.h> 6#include <linux/kernel.h>
7#include <linux/init.h> 7#include <linux/init.h>
8#include <linux/cpumask.h> 8#include <linux/cpumask.h>
9#include <linux/cache.h>
10
9#include <asm/errno.h> 11#include <asm/errno.h>
10 12
13extern int prof_on __read_mostly;
14
11#define CPU_PROFILING 1 15#define CPU_PROFILING 1
12#define SCHED_PROFILING 2 16#define SCHED_PROFILING 2
17#define SLEEP_PROFILING 3
13 18
14struct proc_dir_entry; 19struct proc_dir_entry;
15struct pt_regs; 20struct pt_regs;
@@ -18,7 +23,24 @@ struct notifier_block;
18/* init basic kernel profiler */ 23/* init basic kernel profiler */
19void __init profile_init(void); 24void __init profile_init(void);
20void profile_tick(int); 25void profile_tick(int);
21void profile_hit(int, void *); 26
27/*
28 * Add multiple profiler hits to a given address:
29 */
30void profile_hits(int, void *ip, unsigned int nr_hits);
31
32/*
33 * Single profiler hit:
34 */
35static inline void profile_hit(int type, void *ip)
36{
37 /*
38 * Speedup for the common (no profiling enabled) case:
39 */
40 if (unlikely(prof_on == type))
41 profile_hits(type, ip, 1);
42}
43
22#ifdef CONFIG_PROC_FS 44#ifdef CONFIG_PROC_FS
23void create_prof_cpu_mask(struct proc_dir_entry *); 45void create_prof_cpu_mask(struct proc_dir_entry *);
24#else 46#else
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 5110201a4159..90c23f690c0d 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -37,6 +37,9 @@ extern int dquot_release(struct dquot *dquot);
37extern int dquot_commit_info(struct super_block *sb, int type); 37extern int dquot_commit_info(struct super_block *sb, int type);
38extern int dquot_mark_dquot_dirty(struct dquot *dquot); 38extern int dquot_mark_dquot_dirty(struct dquot *dquot);
39 39
40int remove_inode_dquot_ref(struct inode *inode, int type,
41 struct list_head *tofree_head);
42
40extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path); 43extern int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path);
41extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name, 44extern int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
42 int format_id, int type); 45 int format_id, int type);
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index cbfa11537421..0deb842541ac 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (C) 2001 Momchil Velikov 2 * Copyright (C) 2001 Momchil Velikov
3 * Portions Copyright (C) 2001 Christoph Hellwig 3 * Portions Copyright (C) 2001 Christoph Hellwig
4 * Copyright (C) 2006 Nick Piggin
4 * 5 *
5 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
@@ -21,6 +22,35 @@
21 22
22#include <linux/preempt.h> 23#include <linux/preempt.h>
23#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/kernel.h>
26#include <linux/rcupdate.h>
27
28/*
29 * A direct pointer (root->rnode pointing directly to a data item,
30 * rather than another radix_tree_node) is signalled by the low bit
31 * set in the root->rnode pointer.
32 *
33 * In this case root->height is also NULL, but the direct pointer tests are
34 * needed for RCU lookups when root->height is unreliable.
35 */
36#define RADIX_TREE_DIRECT_PTR 1
37
38static inline void *radix_tree_ptr_to_direct(void *ptr)
39{
40 return (void *)((unsigned long)ptr | RADIX_TREE_DIRECT_PTR);
41}
42
43static inline void *radix_tree_direct_to_ptr(void *ptr)
44{
45 return (void *)((unsigned long)ptr & ~RADIX_TREE_DIRECT_PTR);
46}
47
48static inline int radix_tree_is_direct_ptr(void *ptr)
49{
50 return (int)((unsigned long)ptr & RADIX_TREE_DIRECT_PTR);
51}
52
53/*** radix-tree API starts here ***/
24 54
25#define RADIX_TREE_MAX_TAGS 2 55#define RADIX_TREE_MAX_TAGS 2
26 56
@@ -47,6 +77,77 @@ do { \
47 (root)->rnode = NULL; \ 77 (root)->rnode = NULL; \
48} while (0) 78} while (0)
49 79
80/**
81 * Radix-tree synchronization
82 *
83 * The radix-tree API requires that users provide all synchronisation (with
84 * specific exceptions, noted below).
85 *
86 * Synchronization of access to the data items being stored in the tree, and
87 * management of their lifetimes must be completely managed by API users.
88 *
89 * For API usage, in general,
90 * - any function _modifying_ the the tree or tags (inserting or deleting
91 * items, setting or clearing tags must exclude other modifications, and
92 * exclude any functions reading the tree.
93 * - any function _reading_ the the tree or tags (looking up items or tags,
94 * gang lookups) must exclude modifications to the tree, but may occur
95 * concurrently with other readers.
96 *
97 * The notable exceptions to this rule are the following functions:
98 * radix_tree_lookup
99 * radix_tree_tag_get
100 * radix_tree_gang_lookup
101 * radix_tree_gang_lookup_tag
102 * radix_tree_tagged
103 *
104 * The first 4 functions are able to be called locklessly, using RCU. The
105 * caller must ensure calls to these functions are made within rcu_read_lock()
106 * regions. Other readers (lock-free or otherwise) and modifications may be
107 * running concurrently.
108 *
109 * It is still required that the caller manage the synchronization and lifetimes
110 * of the items. So if RCU lock-free lookups are used, typically this would mean
111 * that the items have their own locks, or are amenable to lock-free access; and
112 * that the items are freed by RCU (or only freed after having been deleted from
113 * the radix tree *and* a synchronize_rcu() grace period).
114 *
115 * (Note, rcu_assign_pointer and rcu_dereference are not needed to control
116 * access to data items when inserting into or looking up from the radix tree)
117 *
118 * radix_tree_tagged is able to be called without locking or RCU.
119 */
120
121/**
122 * radix_tree_deref_slot - dereference a slot
123 * @pslot: pointer to slot, returned by radix_tree_lookup_slot
124 * Returns: item that was stored in that slot with any direct pointer flag
125 * removed.
126 *
127 * For use with radix_tree_lookup_slot(). Caller must hold tree at least read
128 * locked across slot lookup and dereference. More likely, will be used with
129 * radix_tree_replace_slot(), as well, so caller will hold tree write locked.
130 */
131static inline void *radix_tree_deref_slot(void **pslot)
132{
133 return radix_tree_direct_to_ptr(*pslot);
134}
135/**
136 * radix_tree_replace_slot - replace item in a slot
137 * @pslot: pointer to slot, returned by radix_tree_lookup_slot
138 * @item: new item to store in the slot.
139 *
140 * For use with radix_tree_lookup_slot(). Caller must hold tree write locked
141 * across slot lookup and replacement.
142 */
143static inline void radix_tree_replace_slot(void **pslot, void *item)
144{
145 BUG_ON(radix_tree_is_direct_ptr(item));
146 rcu_assign_pointer(*pslot,
147 (void *)((unsigned long)item |
148 ((unsigned long)*pslot & RADIX_TREE_DIRECT_PTR)));
149}
150
50int radix_tree_insert(struct radix_tree_root *, unsigned long, void *); 151int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
51void *radix_tree_lookup(struct radix_tree_root *, unsigned long); 152void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
52void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long); 153void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long);
diff --git a/include/linux/raid/raid5.h b/include/linux/raid/raid5.h
index f13299a15591..03636d7918fe 100644
--- a/include/linux/raid/raid5.h
+++ b/include/linux/raid/raid5.h
@@ -235,7 +235,7 @@ struct raid5_private_data {
235 */ 235 */
236 int active_name; 236 int active_name;
237 char cache_name[2][20]; 237 char cache_name[2][20];
238 kmem_cache_t *slab_cache; /* for allocating stripes */ 238 struct kmem_cache *slab_cache; /* for allocating stripes */
239 239
240 int seq_flush, seq_write; 240 int seq_flush, seq_write;
241 int quiesce; 241 int quiesce;
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index 7bc6bfb86253..d0e4dce33ad5 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -739,7 +739,7 @@ struct block_head {
739#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0) 739#define PUT_B_FREE_SPACE(p_s_bh,val) do { set_blkh_free_space(B_BLK_HEAD(p_s_bh),val); } while (0)
740 740
741/* Get right delimiting key. -- little endian */ 741/* Get right delimiting key. -- little endian */
742#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh)) 742#define B_PRIGHT_DELIM_KEY(p_s_bh) (&(blk_right_delim_key(B_BLK_HEAD(p_s_bh))))
743 743
744/* Does the buffer contain a disk leaf. */ 744/* Does the buffer contain a disk leaf. */
745#define B_IS_ITEMS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL) 745#define B_IS_ITEMS_LEVEL(p_s_bh) (B_LEVEL(p_s_bh) == DISK_LEAF_NODE_LEVEL)
diff --git a/include/linux/relay.h b/include/linux/relay.h
index 0e3d91b76996..c6a48bfc8b14 100644
--- a/include/linux/relay.h
+++ b/include/linux/relay.h
@@ -274,7 +274,7 @@ static inline void subbuf_start_reserve(struct rchan_buf *buf,
274/* 274/*
275 * exported relay file operations, kernel/relay.c 275 * exported relay file operations, kernel/relay.c
276 */ 276 */
277extern struct file_operations relay_file_operations; 277extern const struct file_operations relay_file_operations;
278 278
279#endif /* _LINUX_RELAY_H */ 279#endif /* _LINUX_RELAY_H */
280 280
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index db2c1df4fef9..36f850373d2c 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -30,11 +30,11 @@ struct anon_vma {
30 30
31#ifdef CONFIG_MMU 31#ifdef CONFIG_MMU
32 32
33extern kmem_cache_t *anon_vma_cachep; 33extern struct kmem_cache *anon_vma_cachep;
34 34
35static inline struct anon_vma *anon_vma_alloc(void) 35static inline struct anon_vma *anon_vma_alloc(void)
36{ 36{
37 return kmem_cache_alloc(anon_vma_cachep, SLAB_KERNEL); 37 return kmem_cache_alloc(anon_vma_cachep, GFP_KERNEL);
38} 38}
39 39
40static inline void anon_vma_free(struct anon_vma *anon_vma) 40static inline void anon_vma_free(struct anon_vma *anon_vma)
diff --git a/include/linux/rtmutex.h b/include/linux/rtmutex.h
index 5d41dee82f80..b0090e9f7884 100644
--- a/include/linux/rtmutex.h
+++ b/include/linux/rtmutex.h
@@ -63,7 +63,7 @@ struct hrtimer_sleeper;
63#endif 63#endif
64 64
65#define __RT_MUTEX_INITIALIZER(mutexname) \ 65#define __RT_MUTEX_INITIALIZER(mutexname) \
66 { .wait_lock = SPIN_LOCK_UNLOCKED \ 66 { .wait_lock = __SPIN_LOCK_UNLOCKED(mutexname.wait_lock) \
67 , .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \ 67 , .wait_list = PLIST_HEAD_INIT(mutexname.wait_list, mutexname.wait_lock) \
68 , .owner = NULL \ 68 , .owner = NULL \
69 __DEBUG_RT_MUTEX_INITIALIZER(mutexname)} 69 __DEBUG_RT_MUTEX_INITIALIZER(mutexname)}
diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h
index ae1fcadd598e..813cee13da0d 100644
--- a/include/linux/rwsem-spinlock.h
+++ b/include/linux/rwsem-spinlock.h
@@ -44,7 +44,8 @@ struct rw_semaphore {
44#endif 44#endif
45 45
46#define __RWSEM_INITIALIZER(name) \ 46#define __RWSEM_INITIALIZER(name) \
47{ 0, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) } 47{ 0, __SPIN_LOCK_UNLOCKED(name.wait_lock), LIST_HEAD_INIT((name).wait_list) \
48 __RWSEM_DEP_MAP_INIT(name) }
48 49
49#define DECLARE_RWSEM(name) \ 50#define DECLARE_RWSEM(name) \
50 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 51 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index eafe4a7b8237..dede82c63445 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -194,7 +194,16 @@ extern void init_idle(struct task_struct *idle, int cpu);
194 194
195extern cpumask_t nohz_cpu_mask; 195extern cpumask_t nohz_cpu_mask;
196 196
197extern void show_state(void); 197/*
198 * Only dump TASK_* tasks. (-1 for all tasks)
199 */
200extern void show_state_filter(unsigned long state_filter);
201
202static inline void show_state(void)
203{
204 show_state_filter(-1);
205}
206
198extern void show_regs(struct pt_regs *); 207extern void show_regs(struct pt_regs *);
199 208
200/* 209/*
@@ -338,15 +347,23 @@ struct mm_struct {
338 347
339 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */ 348 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
340 349
341 unsigned dumpable:2;
342 cpumask_t cpu_vm_mask; 350 cpumask_t cpu_vm_mask;
343 351
344 /* Architecture-specific MM context */ 352 /* Architecture-specific MM context */
345 mm_context_t context; 353 mm_context_t context;
346 354
347 /* Token based thrashing protection. */ 355 /* Swap token stuff */
348 unsigned long swap_token_time; 356 /*
349 char recent_pagein; 357 * Last value of global fault stamp as seen by this process.
358 * In other words, this value gives an indication of how long
359 * it has been since this task got the token.
360 * Look at mm/thrash.c
361 */
362 unsigned int faultstamp;
363 unsigned int token_priority;
364 unsigned int last_interval;
365
366 unsigned char dumpable:2;
350 367
351 /* coredumping support */ 368 /* coredumping support */
352 int core_waiters; 369 int core_waiters;
@@ -556,7 +573,7 @@ struct sched_info {
556#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */ 573#endif /* defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) */
557 574
558#ifdef CONFIG_SCHEDSTATS 575#ifdef CONFIG_SCHEDSTATS
559extern struct file_operations proc_schedstat_operations; 576extern const struct file_operations proc_schedstat_operations;
560#endif /* CONFIG_SCHEDSTATS */ 577#endif /* CONFIG_SCHEDSTATS */
561 578
562#ifdef CONFIG_TASK_DELAY_ACCT 579#ifdef CONFIG_TASK_DELAY_ACCT
@@ -1288,7 +1305,6 @@ extern int kill_pgrp(struct pid *pid, int sig, int priv);
1288extern int kill_pid(struct pid *pid, int sig, int priv); 1305extern int kill_pid(struct pid *pid, int sig, int priv);
1289extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp); 1306extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
1290extern int kill_pg_info(int, struct siginfo *, pid_t); 1307extern int kill_pg_info(int, struct siginfo *, pid_t);
1291extern int kill_proc_info(int, struct siginfo *, pid_t);
1292extern void do_notify_parent(struct task_struct *, int); 1308extern void do_notify_parent(struct task_struct *, int);
1293extern void force_sig(int, struct task_struct *); 1309extern void force_sig(int, struct task_struct *);
1294extern void force_sig_specific(int, struct task_struct *); 1310extern void force_sig_specific(int, struct task_struct *);
@@ -1610,87 +1626,6 @@ extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
1610 1626
1611extern void normalize_rt_tasks(void); 1627extern void normalize_rt_tasks(void);
1612 1628
1613#ifdef CONFIG_PM
1614/*
1615 * Check if a process has been frozen
1616 */
1617static inline int frozen(struct task_struct *p)
1618{
1619 return p->flags & PF_FROZEN;
1620}
1621
1622/*
1623 * Check if there is a request to freeze a process
1624 */
1625static inline int freezing(struct task_struct *p)
1626{
1627 return p->flags & PF_FREEZE;
1628}
1629
1630/*
1631 * Request that a process be frozen
1632 * FIXME: SMP problem. We may not modify other process' flags!
1633 */
1634static inline void freeze(struct task_struct *p)
1635{
1636 p->flags |= PF_FREEZE;
1637}
1638
1639/*
1640 * Sometimes we may need to cancel the previous 'freeze' request
1641 */
1642static inline void do_not_freeze(struct task_struct *p)
1643{
1644 p->flags &= ~PF_FREEZE;
1645}
1646
1647/*
1648 * Wake up a frozen process
1649 */
1650static inline int thaw_process(struct task_struct *p)
1651{
1652 if (frozen(p)) {
1653 p->flags &= ~PF_FROZEN;
1654 wake_up_process(p);
1655 return 1;
1656 }
1657 return 0;
1658}
1659
1660/*
1661 * freezing is complete, mark process as frozen
1662 */
1663static inline void frozen_process(struct task_struct *p)
1664{
1665 p->flags = (p->flags & ~PF_FREEZE) | PF_FROZEN;
1666}
1667
1668extern void refrigerator(void);
1669extern int freeze_processes(void);
1670extern void thaw_processes(void);
1671
1672static inline int try_to_freeze(void)
1673{
1674 if (freezing(current)) {
1675 refrigerator();
1676 return 1;
1677 } else
1678 return 0;
1679}
1680#else
1681static inline int frozen(struct task_struct *p) { return 0; }
1682static inline int freezing(struct task_struct *p) { return 0; }
1683static inline void freeze(struct task_struct *p) { BUG(); }
1684static inline int thaw_process(struct task_struct *p) { return 1; }
1685static inline void frozen_process(struct task_struct *p) { BUG(); }
1686
1687static inline void refrigerator(void) {}
1688static inline int freeze_processes(void) { BUG(); return 0; }
1689static inline void thaw_processes(void) {}
1690
1691static inline int try_to_freeze(void) { return 0; }
1692
1693#endif /* CONFIG_PM */
1694#endif /* __KERNEL__ */ 1629#endif /* __KERNEL__ */
1695 1630
1696#endif 1631#endif
diff --git a/include/linux/screen_info.h b/include/linux/screen_info.h
index 2925e66a6732..b02308ee7667 100644
--- a/include/linux/screen_info.h
+++ b/include/linux/screen_info.h
@@ -42,7 +42,8 @@ struct screen_info {
42 u16 pages; /* 0x32 */ 42 u16 pages; /* 0x32 */
43 u16 vesa_attributes; /* 0x34 */ 43 u16 vesa_attributes; /* 0x34 */
44 u32 capabilities; /* 0x36 */ 44 u32 capabilities; /* 0x36 */
45 /* 0x3a -- 0x3f reserved for future expansion */ 45 /* 0x3a -- 0x3b reserved for future expansion */
46 /* 0x3c -- 0x3f micro stack for relocatable kernels */
46}; 47};
47 48
48extern struct screen_info screen_info; 49extern struct screen_info screen_info;
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index b95f6eb7254c..3e3cccbb1cac 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -20,7 +20,7 @@ struct seq_file {
20 loff_t index; 20 loff_t index;
21 loff_t version; 21 loff_t version;
22 struct mutex lock; 22 struct mutex lock;
23 struct seq_operations *op; 23 const struct seq_operations *op;
24 void *private; 24 void *private;
25}; 25};
26 26
@@ -31,7 +31,7 @@ struct seq_operations {
31 int (*show) (struct seq_file *m, void *v); 31 int (*show) (struct seq_file *m, void *v);
32}; 32};
33 33
34int seq_open(struct file *, struct seq_operations *); 34int seq_open(struct file *, const struct seq_operations *);
35ssize_t seq_read(struct file *, char __user *, size_t, loff_t *); 35ssize_t seq_read(struct file *, char __user *, size_t, loff_t *);
36loff_t seq_lseek(struct file *, loff_t, int); 36loff_t seq_lseek(struct file *, loff_t, int);
37int seq_release(struct inode *, struct file *); 37int seq_release(struct inode *, struct file *);
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index 8e9681413726..71310d80c09a 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -41,6 +41,7 @@ enum {
41 PLAT8250_DEV_FOURPORT, 41 PLAT8250_DEV_FOURPORT,
42 PLAT8250_DEV_ACCENT, 42 PLAT8250_DEV_ACCENT,
43 PLAT8250_DEV_BOCA, 43 PLAT8250_DEV_BOCA,
44 PLAT8250_DEV_EXAR_ST16C554,
44 PLAT8250_DEV_HUB6, 45 PLAT8250_DEV_HUB6,
45 PLAT8250_DEV_MCA, 46 PLAT8250_DEV_MCA,
46 PLAT8250_DEV_AU1X00, 47 PLAT8250_DEV_AU1X00,
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 463ab953b092..827672136646 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -132,6 +132,8 @@
132 132
133#define PORT_S3C2412 73 133#define PORT_S3C2412 73
134 134
135/* Xilinx uartlite */
136#define PORT_UARTLITE 74
135 137
136#ifdef __KERNEL__ 138#ifdef __KERNEL__
137 139
diff --git a/include/linux/signal.h b/include/linux/signal.h
index 117135e33d67..14749056dd63 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -241,6 +241,8 @@ extern int sigprocmask(int, sigset_t *, sigset_t *);
241struct pt_regs; 241struct pt_regs;
242extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie); 242extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
243 243
244extern struct kmem_cache *sighand_cachep;
245
244#endif /* __KERNEL__ */ 246#endif /* __KERNEL__ */
245 247
246#endif /* _LINUX_SIGNAL_H */ 248#endif /* _LINUX_SIGNAL_H */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a05a5f7c0b73..4ff3940210d8 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -332,20 +332,20 @@ struct sk_buff {
332extern void kfree_skb(struct sk_buff *skb); 332extern void kfree_skb(struct sk_buff *skb);
333extern void __kfree_skb(struct sk_buff *skb); 333extern void __kfree_skb(struct sk_buff *skb);
334extern struct sk_buff *__alloc_skb(unsigned int size, 334extern struct sk_buff *__alloc_skb(unsigned int size,
335 gfp_t priority, int fclone); 335 gfp_t priority, int fclone, int node);
336static inline struct sk_buff *alloc_skb(unsigned int size, 336static inline struct sk_buff *alloc_skb(unsigned int size,
337 gfp_t priority) 337 gfp_t priority)
338{ 338{
339 return __alloc_skb(size, priority, 0); 339 return __alloc_skb(size, priority, 0, -1);
340} 340}
341 341
342static inline struct sk_buff *alloc_skb_fclone(unsigned int size, 342static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
343 gfp_t priority) 343 gfp_t priority)
344{ 344{
345 return __alloc_skb(size, priority, 1); 345 return __alloc_skb(size, priority, 1, -1);
346} 346}
347 347
348extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, 348extern struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
349 unsigned int size, 349 unsigned int size,
350 gfp_t priority); 350 gfp_t priority);
351extern void kfree_skbmem(struct sk_buff *skb); 351extern void kfree_skbmem(struct sk_buff *skb);
diff --git a/include/linux/slab.h b/include/linux/slab.h
index c4947b8a2c03..2271886744f8 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -7,27 +7,17 @@
7#ifndef _LINUX_SLAB_H 7#ifndef _LINUX_SLAB_H
8#define _LINUX_SLAB_H 8#define _LINUX_SLAB_H
9 9
10#if defined(__KERNEL__) 10#ifdef __KERNEL__
11 11
12typedef struct kmem_cache kmem_cache_t; 12#include <linux/gfp.h>
13#include <linux/init.h>
14#include <linux/types.h>
15#include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */
16#include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */
17#include <linux/compiler.h>
13 18
14#include <linux/gfp.h> 19/* kmem_cache_t exists for legacy reasons and is not used by code in mm */
15#include <linux/init.h> 20typedef struct kmem_cache kmem_cache_t __deprecated;
16#include <linux/types.h>
17#include <asm/page.h> /* kmalloc_sizes.h needs PAGE_SIZE */
18#include <asm/cache.h> /* kmalloc_sizes.h needs L1_CACHE_BYTES */
19
20/* flags for kmem_cache_alloc() */
21#define SLAB_NOFS GFP_NOFS
22#define SLAB_NOIO GFP_NOIO
23#define SLAB_ATOMIC GFP_ATOMIC
24#define SLAB_USER GFP_USER
25#define SLAB_KERNEL GFP_KERNEL
26#define SLAB_DMA GFP_DMA
27
28#define SLAB_LEVEL_MASK GFP_LEVEL_MASK
29
30#define SLAB_NO_GROW __GFP_NO_GROW /* don't grow a cache */
31 21
32/* flags to pass to kmem_cache_create(). 22/* flags to pass to kmem_cache_create().
33 * The first 3 are only valid when the allocator as been build 23 * The first 3 are only valid when the allocator as been build
@@ -57,22 +47,23 @@ typedef struct kmem_cache kmem_cache_t;
57/* prototypes */ 47/* prototypes */
58extern void __init kmem_cache_init(void); 48extern void __init kmem_cache_init(void);
59 49
60extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long, 50extern struct kmem_cache *kmem_cache_create(const char *, size_t, size_t,
61 void (*)(void *, kmem_cache_t *, unsigned long), 51 unsigned long,
62 void (*)(void *, kmem_cache_t *, unsigned long)); 52 void (*)(void *, struct kmem_cache *, unsigned long),
63extern void kmem_cache_destroy(kmem_cache_t *); 53 void (*)(void *, struct kmem_cache *, unsigned long));
64extern int kmem_cache_shrink(kmem_cache_t *); 54extern void kmem_cache_destroy(struct kmem_cache *);
65extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t); 55extern int kmem_cache_shrink(struct kmem_cache *);
56extern void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
66extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); 57extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
67extern void kmem_cache_free(kmem_cache_t *, void *); 58extern void kmem_cache_free(struct kmem_cache *, void *);
68extern unsigned int kmem_cache_size(kmem_cache_t *); 59extern unsigned int kmem_cache_size(struct kmem_cache *);
69extern const char *kmem_cache_name(kmem_cache_t *); 60extern const char *kmem_cache_name(struct kmem_cache *);
70 61
71/* Size description struct for general caches. */ 62/* Size description struct for general caches. */
72struct cache_sizes { 63struct cache_sizes {
73 size_t cs_size; 64 size_t cs_size;
74 kmem_cache_t *cs_cachep; 65 struct kmem_cache *cs_cachep;
75 kmem_cache_t *cs_dmacachep; 66 struct kmem_cache *cs_dmacachep;
76}; 67};
77extern struct cache_sizes malloc_sizes[]; 68extern struct cache_sizes malloc_sizes[];
78 69
@@ -211,7 +202,7 @@ extern unsigned int ksize(const void *);
211extern int slab_is_available(void); 202extern int slab_is_available(void);
212 203
213#ifdef CONFIG_NUMA 204#ifdef CONFIG_NUMA
214extern void *kmem_cache_alloc_node(kmem_cache_t *, gfp_t flags, int node); 205extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
215extern void *__kmalloc_node(size_t size, gfp_t flags, int node); 206extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
216 207
217static inline void *kmalloc_node(size_t size, gfp_t flags, int node) 208static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
@@ -236,8 +227,27 @@ found:
236 } 227 }
237 return __kmalloc_node(size, flags, node); 228 return __kmalloc_node(size, flags, node);
238} 229}
230
231/*
232 * kmalloc_node_track_caller is a special version of kmalloc_node that
233 * records the calling function of the routine calling it for slab leak
234 * tracking instead of just the calling function (confusing, eh?).
235 * It's useful when the call to kmalloc_node comes from a widely-used
236 * standard allocator where we care about the real place the memory
237 * allocation request comes from.
238 */
239#ifndef CONFIG_DEBUG_SLAB
240#define kmalloc_node_track_caller(size, flags, node) \
241 __kmalloc_node(size, flags, node)
239#else 242#else
240static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, gfp_t flags, int node) 243extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, void *);
244#define kmalloc_node_track_caller(size, flags, node) \
245 __kmalloc_node_track_caller(size, flags, node, \
246 __builtin_return_address(0))
247#endif
248#else /* CONFIG_NUMA */
249static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
250 gfp_t flags, int node)
241{ 251{
242 return kmem_cache_alloc(cachep, flags); 252 return kmem_cache_alloc(cachep, flags);
243} 253}
@@ -245,10 +255,13 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node)
245{ 255{
246 return kmalloc(size, flags); 256 return kmalloc(size, flags);
247} 257}
258
259#define kmalloc_node_track_caller(size, flags, node) \
260 kmalloc_track_caller(size, flags)
248#endif 261#endif
249 262
250extern int FASTCALL(kmem_cache_reap(int)); 263extern int FASTCALL(kmem_cache_reap(int));
251extern int FASTCALL(kmem_ptr_validate(kmem_cache_t *cachep, void *ptr)); 264extern int FASTCALL(kmem_ptr_validate(struct kmem_cache *cachep, void *ptr));
252 265
253#else /* CONFIG_SLOB */ 266#else /* CONFIG_SLOB */
254 267
@@ -283,16 +296,9 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
283#define kzalloc(s, f) __kzalloc(s, f) 296#define kzalloc(s, f) __kzalloc(s, f)
284#define kmalloc_track_caller kmalloc 297#define kmalloc_track_caller kmalloc
285 298
286#endif /* CONFIG_SLOB */ 299#define kmalloc_node_track_caller kmalloc_node
287 300
288/* System wide caches */ 301#endif /* CONFIG_SLOB */
289extern kmem_cache_t *vm_area_cachep;
290extern kmem_cache_t *names_cachep;
291extern kmem_cache_t *files_cachep;
292extern kmem_cache_t *filp_cachep;
293extern kmem_cache_t *fs_cachep;
294extern kmem_cache_t *sighand_cachep;
295extern kmem_cache_t *bio_cachep;
296 302
297#endif /* __KERNEL__ */ 303#endif /* __KERNEL__ */
298 304
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 51649987f691..7ba23ec8211b 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -99,6 +99,13 @@ static inline int up_smp_call_function(void)
99static inline void smp_send_reschedule(int cpu) { } 99static inline void smp_send_reschedule(int cpu) { }
100#define num_booting_cpus() 1 100#define num_booting_cpus() 1
101#define smp_prepare_boot_cpu() do {} while (0) 101#define smp_prepare_boot_cpu() do {} while (0)
102static inline int smp_call_function_single(int cpuid, void (*func) (void *info),
103 void *info, int retry, int wait)
104{
105 /* Disable interrupts here? */
106 func(info);
107 return 0;
108}
102 109
103#endif /* !SMP */ 110#endif /* !SMP */
104 111
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 8451052ca66f..94b767d64275 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -52,6 +52,7 @@
52#include <linux/thread_info.h> 52#include <linux/thread_info.h>
53#include <linux/kernel.h> 53#include <linux/kernel.h>
54#include <linux/stringify.h> 54#include <linux/stringify.h>
55#include <linux/bottom_half.h>
55 56
56#include <asm/system.h> 57#include <asm/system.h>
57 58
diff --git a/include/linux/start_kernel.h b/include/linux/start_kernel.h
new file mode 100644
index 000000000000..d3e5f2756545
--- /dev/null
+++ b/include/linux/start_kernel.h
@@ -0,0 +1,12 @@
1#ifndef _LINUX_START_KERNEL_H
2#define _LINUX_START_KERNEL_H
3
4#include <linux/linkage.h>
5#include <linux/init.h>
6
7/* Define the prototype for start_kernel here, rather than cluttering
8 up something else. */
9
10extern asmlinkage void __init start_kernel(void);
11
12#endif /* _LINUX_START_KERNEL_H */
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index b6b6ad6253b4..97c761652581 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -217,7 +217,7 @@ struct rpc_wait_queue {
217 217
218#ifndef RPC_DEBUG 218#ifndef RPC_DEBUG
219# define RPC_WAITQ_INIT(var,qname) { \ 219# define RPC_WAITQ_INIT(var,qname) { \
220 .lock = SPIN_LOCK_UNLOCKED, \ 220 .lock = __SPIN_LOCK_UNLOCKED(var.lock), \
221 .tasks = { \ 221 .tasks = { \
222 [0] = LIST_HEAD_INIT(var.tasks[0]), \ 222 [0] = LIST_HEAD_INIT(var.tasks[0]), \
223 [1] = LIST_HEAD_INIT(var.tasks[1]), \ 223 [1] = LIST_HEAD_INIT(var.tasks[1]), \
@@ -226,7 +226,7 @@ struct rpc_wait_queue {
226 } 226 }
227#else 227#else
228# define RPC_WAITQ_INIT(var,qname) { \ 228# define RPC_WAITQ_INIT(var,qname) { \
229 .lock = SPIN_LOCK_UNLOCKED, \ 229 .lock = __SPIN_LOCK_UNLOCKED(var.lock), \
230 .tasks = { \ 230 .tasks = { \
231 [0] = LIST_HEAD_INIT(var.tasks[0]), \ 231 [0] = LIST_HEAD_INIT(var.tasks[0]), \
232 [1] = LIST_HEAD_INIT(var.tasks[1]), \ 232 [1] = LIST_HEAD_INIT(var.tasks[1]), \
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index b1237f16ecde..bf99bd49f8ef 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -9,10 +9,13 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/pm.h> 10#include <linux/pm.h>
11 11
12/* page backup entry */ 12/* struct pbe is used for creating lists of pages that should be restored
13 * atomically during the resume from disk, because the page frames they have
14 * occupied before the suspend are in use.
15 */
13struct pbe { 16struct pbe {
14 unsigned long address; /* address of the copy */ 17 void *address; /* address of the copy */
15 unsigned long orig_address; /* original address of page */ 18 void *orig_address; /* original address of a page */
16 struct pbe *next; 19 struct pbe *next;
17}; 20};
18 21
diff --git a/include/linux/swap.h b/include/linux/swap.h
index e7c36ba2a2db..add51cebc8d9 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -218,8 +218,6 @@ extern void swap_unplug_io_fn(struct backing_dev_info *, struct page *);
218/* linux/mm/page_io.c */ 218/* linux/mm/page_io.c */
219extern int swap_readpage(struct file *, struct page *); 219extern int swap_readpage(struct file *, struct page *);
220extern int swap_writepage(struct page *page, struct writeback_control *wbc); 220extern int swap_writepage(struct page *page, struct writeback_control *wbc);
221extern int rw_swap_page_sync(int rw, swp_entry_t entry, struct page *page,
222 struct bio **bio_chain);
223extern int end_swap_bio_read(struct bio *bio, unsigned int bytes_done, int err); 221extern int end_swap_bio_read(struct bio *bio, unsigned int bytes_done, int err);
224 222
225/* linux/mm/swap_state.c */ 223/* linux/mm/swap_state.c */
@@ -247,9 +245,10 @@ extern int swap_duplicate(swp_entry_t);
247extern int valid_swaphandles(swp_entry_t, unsigned long *); 245extern int valid_swaphandles(swp_entry_t, unsigned long *);
248extern void swap_free(swp_entry_t); 246extern void swap_free(swp_entry_t);
249extern void free_swap_and_cache(swp_entry_t); 247extern void free_swap_and_cache(swp_entry_t);
250extern int swap_type_of(dev_t); 248extern int swap_type_of(dev_t, sector_t);
251extern unsigned int count_swap_pages(int, int); 249extern unsigned int count_swap_pages(int, int);
252extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t); 250extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
251extern sector_t swapdev_block(int, pgoff_t);
253extern struct swap_info_struct *get_swap_info_struct(unsigned); 252extern struct swap_info_struct *get_swap_info_struct(unsigned);
254extern int can_share_swap_page(struct page *); 253extern int can_share_swap_page(struct page *);
255extern int remove_exclusive_swap_page(struct page *); 254extern int remove_exclusive_swap_page(struct page *);
@@ -259,7 +258,6 @@ extern spinlock_t swap_lock;
259 258
260/* linux/mm/thrash.c */ 259/* linux/mm/thrash.c */
261extern struct mm_struct * swap_token_mm; 260extern struct mm_struct * swap_token_mm;
262extern unsigned long swap_token_default_timeout;
263extern void grab_swap_token(void); 261extern void grab_swap_token(void);
264extern void __put_swap_token(struct mm_struct *); 262extern void __put_swap_token(struct mm_struct *);
265 263
diff --git a/include/linux/taskstats_kern.h b/include/linux/taskstats_kern.h
index 6562a2050a25..7e9680f4afdd 100644
--- a/include/linux/taskstats_kern.h
+++ b/include/linux/taskstats_kern.h
@@ -12,64 +12,27 @@
12#include <net/genetlink.h> 12#include <net/genetlink.h>
13 13
14#ifdef CONFIG_TASKSTATS 14#ifdef CONFIG_TASKSTATS
15extern kmem_cache_t *taskstats_cache; 15extern struct kmem_cache *taskstats_cache;
16extern struct mutex taskstats_exit_mutex; 16extern struct mutex taskstats_exit_mutex;
17 17
18static inline void taskstats_exit_free(struct taskstats *tidstats)
19{
20 if (tidstats)
21 kmem_cache_free(taskstats_cache, tidstats);
22}
23
24static inline void taskstats_tgid_init(struct signal_struct *sig) 18static inline void taskstats_tgid_init(struct signal_struct *sig)
25{ 19{
26 sig->stats = NULL; 20 sig->stats = NULL;
27} 21}
28 22
29static inline void taskstats_tgid_alloc(struct task_struct *tsk)
30{
31 struct signal_struct *sig = tsk->signal;
32 struct taskstats *stats;
33
34 if (sig->stats != NULL)
35 return;
36
37 /* No problem if kmem_cache_zalloc() fails */
38 stats = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL);
39
40 spin_lock_irq(&tsk->sighand->siglock);
41 if (!sig->stats) {
42 sig->stats = stats;
43 stats = NULL;
44 }
45 spin_unlock_irq(&tsk->sighand->siglock);
46
47 if (stats)
48 kmem_cache_free(taskstats_cache, stats);
49}
50
51static inline void taskstats_tgid_free(struct signal_struct *sig) 23static inline void taskstats_tgid_free(struct signal_struct *sig)
52{ 24{
53 if (sig->stats) 25 if (sig->stats)
54 kmem_cache_free(taskstats_cache, sig->stats); 26 kmem_cache_free(taskstats_cache, sig->stats);
55} 27}
56 28
57extern void taskstats_exit_alloc(struct taskstats **, unsigned int *); 29extern void taskstats_exit(struct task_struct *, int group_dead);
58extern void taskstats_exit_send(struct task_struct *, struct taskstats *, int, unsigned int);
59extern void taskstats_init_early(void); 30extern void taskstats_init_early(void);
60#else 31#else
61static inline void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu) 32static inline void taskstats_exit(struct task_struct *tsk, int group_dead)
62{}
63static inline void taskstats_exit_free(struct taskstats *ptidstats)
64{}
65static inline void taskstats_exit_send(struct task_struct *tsk,
66 struct taskstats *tidstats,
67 int group_dead, unsigned int cpu)
68{} 33{}
69static inline void taskstats_tgid_init(struct signal_struct *sig) 34static inline void taskstats_tgid_init(struct signal_struct *sig)
70{} 35{}
71static inline void taskstats_tgid_alloc(struct task_struct *tsk)
72{}
73static inline void taskstats_tgid_free(struct signal_struct *sig) 36static inline void taskstats_tgid_free(struct signal_struct *sig)
74{} 37{}
75static inline void taskstats_init_early(void) 38static inline void taskstats_init_early(void)
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index a48d7f11c7be..975c963e5789 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -1,8 +1,43 @@
1#ifndef __LINUX_UACCESS_H__ 1#ifndef __LINUX_UACCESS_H__
2#define __LINUX_UACCESS_H__ 2#define __LINUX_UACCESS_H__
3 3
4#include <linux/preempt.h>
4#include <asm/uaccess.h> 5#include <asm/uaccess.h>
5 6
7/*
8 * These routines enable/disable the pagefault handler in that
9 * it will not take any locks and go straight to the fixup table.
10 *
11 * They have great resemblance to the preempt_disable/enable calls
12 * and in fact they are identical; this is because currently there is
13 * no other way to make the pagefault handlers do this. So we do
14 * disable preemption but we don't necessarily care about that.
15 */
16static inline void pagefault_disable(void)
17{
18 inc_preempt_count();
19 /*
20 * make sure to have issued the store before a pagefault
21 * can hit.
22 */
23 barrier();
24}
25
26static inline void pagefault_enable(void)
27{
28 /*
29 * make sure to issue those last loads/stores before enabling
30 * the pagefault handler again.
31 */
32 barrier();
33 dec_preempt_count();
34 /*
35 * make sure we do..
36 */
37 barrier();
38 preempt_check_resched();
39}
40
6#ifndef ARCH_HAS_NOCACHE_UACCESS 41#ifndef ARCH_HAS_NOCACHE_UACCESS
7 42
8static inline unsigned long __copy_from_user_inatomic_nocache(void *to, 43static inline unsigned long __copy_from_user_inatomic_nocache(void *to,
@@ -30,14 +65,22 @@ static inline unsigned long __copy_from_user_nocache(void *to,
30 * do_page_fault() doesn't attempt to take mmap_sem. This makes 65 * do_page_fault() doesn't attempt to take mmap_sem. This makes
31 * probe_kernel_address() suitable for use within regions where the caller 66 * probe_kernel_address() suitable for use within regions where the caller
32 * already holds mmap_sem, or other locks which nest inside mmap_sem. 67 * already holds mmap_sem, or other locks which nest inside mmap_sem.
68 * This must be a macro because __get_user() needs to know the types of the
69 * args.
70 *
71 * We don't include enough header files to be able to do the set_fs(). We
72 * require that the probe_kernel_address() caller will do that.
33 */ 73 */
34#define probe_kernel_address(addr, retval) \ 74#define probe_kernel_address(addr, retval) \
35 ({ \ 75 ({ \
36 long ret; \ 76 long ret; \
77 mm_segment_t old_fs = get_fs(); \
37 \ 78 \
38 inc_preempt_count(); \ 79 set_fs(KERNEL_DS); \
39 ret = __get_user(retval, addr); \ 80 pagefault_disable(); \
40 dec_preempt_count(); \ 81 ret = __get_user(retval, (__force typeof(retval) __user *)(addr)); \
82 pagefault_enable(); \
83 set_fs(old_fs); \
41 ret; \ 84 ret; \
42 }) 85 })
43 86
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 4a3ea83c6d16..edef8d50b26b 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -147,9 +147,11 @@ struct execute_work {
147 147
148 148
149extern struct workqueue_struct *__create_workqueue(const char *name, 149extern struct workqueue_struct *__create_workqueue(const char *name,
150 int singlethread); 150 int singlethread,
151#define create_workqueue(name) __create_workqueue((name), 0) 151 int freezeable);
152#define create_singlethread_workqueue(name) __create_workqueue((name), 1) 152#define create_workqueue(name) __create_workqueue((name), 0, 0)
153#define create_freezeable_workqueue(name) __create_workqueue((name), 0, 1)
154#define create_singlethread_workqueue(name) __create_workqueue((name), 1, 0)
153 155
154extern void destroy_workqueue(struct workqueue_struct *wq); 156extern void destroy_workqueue(struct workqueue_struct *wq);
155 157
@@ -160,6 +162,7 @@ extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
160extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq)); 162extern void FASTCALL(flush_workqueue(struct workqueue_struct *wq));
161 163
162extern int FASTCALL(schedule_work(struct work_struct *work)); 164extern int FASTCALL(schedule_work(struct work_struct *work));
165extern int FASTCALL(run_scheduled_work(struct work_struct *work));
163extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, unsigned long delay)); 166extern int FASTCALL(schedule_delayed_work(struct delayed_work *work, unsigned long delay));
164 167
165extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, unsigned long delay); 168extern int schedule_delayed_work_on(int cpu, struct delayed_work *work, unsigned long delay);
diff --git a/include/net/dst.h b/include/net/dst.h
index e156e38e4ac3..62b7e7598e9a 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -98,7 +98,7 @@ struct dst_ops
98 int entry_size; 98 int entry_size;
99 99
100 atomic_t entries; 100 atomic_t entries;
101 kmem_cache_t *kmem_cachep; 101 struct kmem_cache *kmem_cachep;
102}; 102};
103 103
104#ifdef __KERNEL__ 104#ifdef __KERNEL__
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index a9eb2eaf094e..34cc76e3ddb4 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -125,7 +125,7 @@ struct inet_hashinfo {
125 rwlock_t lhash_lock ____cacheline_aligned; 125 rwlock_t lhash_lock ____cacheline_aligned;
126 atomic_t lhash_users; 126 atomic_t lhash_users;
127 wait_queue_head_t lhash_wait; 127 wait_queue_head_t lhash_wait;
128 kmem_cache_t *bind_bucket_cachep; 128 struct kmem_cache *bind_bucket_cachep;
129}; 129};
130 130
131static inline struct inet_ehash_bucket *inet_ehash_bucket( 131static inline struct inet_ehash_bucket *inet_ehash_bucket(
@@ -136,10 +136,10 @@ static inline struct inet_ehash_bucket *inet_ehash_bucket(
136} 136}
137 137
138extern struct inet_bind_bucket * 138extern struct inet_bind_bucket *
139 inet_bind_bucket_create(kmem_cache_t *cachep, 139 inet_bind_bucket_create(struct kmem_cache *cachep,
140 struct inet_bind_hashbucket *head, 140 struct inet_bind_hashbucket *head,
141 const unsigned short snum); 141 const unsigned short snum);
142extern void inet_bind_bucket_destroy(kmem_cache_t *cachep, 142extern void inet_bind_bucket_destroy(struct kmem_cache *cachep,
143 struct inet_bind_bucket *tb); 143 struct inet_bind_bucket *tb);
144 144
145static inline int inet_bhashfn(const __u16 lport, const int bhash_size) 145static inline int inet_bhashfn(const __u16 lport, const int bhash_size)
diff --git a/include/net/irda/irlan_filter.h b/include/net/irda/irlan_filter.h
index 492dedaa8ac1..1720539ac2c1 100644
--- a/include/net/irda/irlan_filter.h
+++ b/include/net/irda/irlan_filter.h
@@ -28,6 +28,8 @@
28void irlan_check_command_param(struct irlan_cb *self, char *param, 28void irlan_check_command_param(struct irlan_cb *self, char *param,
29 char *value); 29 char *value);
30void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb); 30void irlan_filter_request(struct irlan_cb *self, struct sk_buff *skb);
31#ifdef CONFIG_PROC_FS
31void irlan_print_filter(struct seq_file *seq, int filter_type); 32void irlan_print_filter(struct seq_file *seq, int filter_type);
33#endif
32 34
33#endif /* IRLAN_FILTER_H */ 35#endif /* IRLAN_FILTER_H */
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index c8aacbd2e333..23967031ddb7 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -160,7 +160,7 @@ struct neigh_table
160 atomic_t entries; 160 atomic_t entries;
161 rwlock_t lock; 161 rwlock_t lock;
162 unsigned long last_rand; 162 unsigned long last_rand;
163 kmem_cache_t *kmem_cachep; 163 struct kmem_cache *kmem_cachep;
164 struct neigh_statistics *stats; 164 struct neigh_statistics *stats;
165 struct neighbour **hash_buckets; 165 struct neighbour **hash_buckets;
166 unsigned int hash_mask; 166 unsigned int hash_mask;
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index cef3136e22a3..41bcc9eb4206 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -7,7 +7,7 @@
7#include <net/netfilter/nf_conntrack.h> 7#include <net/netfilter/nf_conntrack.h>
8 8
9extern struct list_head nf_conntrack_expect_list; 9extern struct list_head nf_conntrack_expect_list;
10extern kmem_cache_t *nf_conntrack_expect_cachep; 10extern struct kmem_cache *nf_conntrack_expect_cachep;
11extern struct file_operations exp_file_ops; 11extern struct file_operations exp_file_ops;
12 12
13struct nf_conntrack_expect 13struct nf_conntrack_expect
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index e37baaf2080b..7aed02ce2b65 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -29,7 +29,7 @@ struct proto;
29struct request_sock_ops { 29struct request_sock_ops {
30 int family; 30 int family;
31 int obj_size; 31 int obj_size;
32 kmem_cache_t *slab; 32 struct kmem_cache *slab;
33 int (*rtx_syn_ack)(struct sock *sk, 33 int (*rtx_syn_ack)(struct sock *sk,
34 struct request_sock *req, 34 struct request_sock *req,
35 struct dst_entry *dst); 35 struct dst_entry *dst);
@@ -60,7 +60,7 @@ struct request_sock {
60 60
61static inline struct request_sock *reqsk_alloc(const struct request_sock_ops *ops) 61static inline struct request_sock *reqsk_alloc(const struct request_sock_ops *ops)
62{ 62{
63 struct request_sock *req = kmem_cache_alloc(ops->slab, SLAB_ATOMIC); 63 struct request_sock *req = kmem_cache_alloc(ops->slab, GFP_ATOMIC);
64 64
65 if (req != NULL) 65 if (req != NULL)
66 req->rsk_ops = ops; 66 req->rsk_ops = ops;
diff --git a/include/net/sock.h b/include/net/sock.h
index fe3a33fad03f..03684e702d13 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -571,7 +571,7 @@ struct proto {
571 int *sysctl_rmem; 571 int *sysctl_rmem;
572 int max_header; 572 int max_header;
573 573
574 kmem_cache_t *slab; 574 struct kmem_cache *slab;
575 unsigned int obj_size; 575 unsigned int obj_size;
576 576
577 atomic_t *orphan_count; 577 atomic_t *orphan_count;
@@ -746,6 +746,25 @@ static inline int sk_stream_wmem_schedule(struct sock *sk, int size)
746 */ 746 */
747#define sock_owned_by_user(sk) ((sk)->sk_lock.owner) 747#define sock_owned_by_user(sk) ((sk)->sk_lock.owner)
748 748
749/*
750 * Macro so as to not evaluate some arguments when
751 * lockdep is not enabled.
752 *
753 * Mark both the sk_lock and the sk_lock.slock as a
754 * per-address-family lock class.
755 */
756#define sock_lock_init_class_and_name(sk, sname, skey, name, key) \
757do { \
758 sk->sk_lock.owner = NULL; \
759 init_waitqueue_head(&sk->sk_lock.wq); \
760 spin_lock_init(&(sk)->sk_lock.slock); \
761 debug_check_no_locks_freed((void *)&(sk)->sk_lock, \
762 sizeof((sk)->sk_lock)); \
763 lockdep_set_class_and_name(&(sk)->sk_lock.slock, \
764 (skey), (sname)); \
765 lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0); \
766} while (0)
767
749extern void FASTCALL(lock_sock_nested(struct sock *sk, int subclass)); 768extern void FASTCALL(lock_sock_nested(struct sock *sk, int subclass));
750 769
751static inline void lock_sock(struct sock *sk) 770static inline void lock_sock(struct sock *sk)
diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h
index d7a306ea560d..1e1ee3253fd8 100644
--- a/include/net/timewait_sock.h
+++ b/include/net/timewait_sock.h
@@ -15,7 +15,7 @@
15#include <net/sock.h> 15#include <net/sock.h>
16 16
17struct timewait_sock_ops { 17struct timewait_sock_ops {
18 kmem_cache_t *twsk_slab; 18 struct kmem_cache *twsk_slab;
19 unsigned int twsk_obj_size; 19 unsigned int twsk_obj_size;
20 int (*twsk_unique)(struct sock *sk, 20 int (*twsk_unique)(struct sock *sk,
21 struct sock *sktw, void *twp); 21 struct sock *sktw, void *twp);
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 15ec19dcf9c8..e4765413cf80 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -392,6 +392,20 @@ extern int xfrm_unregister_km(struct xfrm_mgr *km);
392 392
393extern unsigned int xfrm_policy_count[XFRM_POLICY_MAX*2]; 393extern unsigned int xfrm_policy_count[XFRM_POLICY_MAX*2];
394 394
395/* Audit Information */
396struct xfrm_audit
397{
398 uid_t loginuid;
399 u32 secid;
400};
401
402#ifdef CONFIG_AUDITSYSCALL
403extern void xfrm_audit_log(uid_t auid, u32 secid, int type, int result,
404 struct xfrm_policy *xp, struct xfrm_state *x);
405#else
406#define xfrm_audit_log(a,s,t,r,p,x) do { ; } while (0)
407#endif /* CONFIG_AUDITSYSCALL */
408
395static inline void xfrm_pol_hold(struct xfrm_policy *policy) 409static inline void xfrm_pol_hold(struct xfrm_policy *policy)
396{ 410{
397 if (likely(policy != NULL)) 411 if (likely(policy != NULL))
@@ -906,7 +920,7 @@ static inline int xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **s
906#endif 920#endif
907extern struct xfrm_state *xfrm_find_acq_byseq(u32 seq); 921extern struct xfrm_state *xfrm_find_acq_byseq(u32 seq);
908extern int xfrm_state_delete(struct xfrm_state *x); 922extern int xfrm_state_delete(struct xfrm_state *x);
909extern void xfrm_state_flush(u8 proto); 923extern void xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info);
910extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq); 924extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq);
911extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); 925extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq);
912extern void xfrm_replay_notify(struct xfrm_state *x, int event); 926extern void xfrm_replay_notify(struct xfrm_state *x, int event);
@@ -959,13 +973,13 @@ struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir,
959 struct xfrm_selector *sel, 973 struct xfrm_selector *sel,
960 struct xfrm_sec_ctx *ctx, int delete); 974 struct xfrm_sec_ctx *ctx, int delete);
961struct xfrm_policy *xfrm_policy_byid(u8, int dir, u32 id, int delete); 975struct xfrm_policy *xfrm_policy_byid(u8, int dir, u32 id, int delete);
962void xfrm_policy_flush(u8 type); 976void xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info);
963u32 xfrm_get_acqseq(void); 977u32 xfrm_get_acqseq(void);
964void xfrm_alloc_spi(struct xfrm_state *x, __be32 minspi, __be32 maxspi); 978void xfrm_alloc_spi(struct xfrm_state *x, __be32 minspi, __be32 maxspi);
965struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, 979struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto,
966 xfrm_address_t *daddr, xfrm_address_t *saddr, 980 xfrm_address_t *daddr, xfrm_address_t *saddr,
967 int create, unsigned short family); 981 int create, unsigned short family);
968extern void xfrm_policy_flush(u8 type); 982extern void xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info);
969extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); 983extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
970extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst, 984extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst,
971 struct flowi *fl, int family, int strict); 985 struct flowi *fl, int family, int strict);
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 9233ed5de664..0c775fceb675 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -557,7 +557,7 @@ struct sas_task {
557 557
558static inline struct sas_task *sas_alloc_task(gfp_t flags) 558static inline struct sas_task *sas_alloc_task(gfp_t flags)
559{ 559{
560 extern kmem_cache_t *sas_task_cache; 560 extern struct kmem_cache *sas_task_cache;
561 struct sas_task *task = kmem_cache_alloc(sas_task_cache, flags); 561 struct sas_task *task = kmem_cache_alloc(sas_task_cache, flags);
562 562
563 if (task) { 563 if (task) {
@@ -575,7 +575,7 @@ static inline struct sas_task *sas_alloc_task(gfp_t flags)
575static inline void sas_free_task(struct sas_task *task) 575static inline void sas_free_task(struct sas_task *task)
576{ 576{
577 if (task) { 577 if (task) {
578 extern kmem_cache_t *sas_task_cache; 578 extern struct kmem_cache *sas_task_cache;
579 BUG_ON(!list_empty(&task->list)); 579 BUG_ON(!list_empty(&task->list));
580 kmem_cache_free(sas_task_cache, task); 580 kmem_cache_free(sas_task_cache, task);
581 } 581 }
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index 919a80cb322e..2cfd7cb36e79 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -6,6 +6,7 @@
6#include <linux/romfs_fs.h> 6#include <linux/romfs_fs.h>
7#include <linux/initrd.h> 7#include <linux/initrd.h>
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/freezer.h>
9 10
10#include "do_mounts.h" 11#include "do_mounts.h"
11 12
diff --git a/init/initramfs.c b/init/initramfs.c
index d28c1094d7e5..85f04037ade1 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -182,6 +182,10 @@ static int __init do_collect(void)
182 182
183static int __init do_header(void) 183static int __init do_header(void)
184{ 184{
185 if (memcmp(collected, "070707", 6)==0) {
186 error("incorrect cpio method used: use -H newc option");
187 return 1;
188 }
185 if (memcmp(collected, "070701", 6)) { 189 if (memcmp(collected, "070701", 6)) {
186 error("no cpio magic"); 190 error("no cpio magic");
187 return 1; 191 return 1;
diff --git a/init/main.c b/init/main.c
index 36f608a7cfba..1174ae3aec8c 100644
--- a/init/main.c
+++ b/init/main.c
@@ -29,6 +29,7 @@
29#include <linux/percpu.h> 29#include <linux/percpu.h>
30#include <linux/kmod.h> 30#include <linux/kmod.h>
31#include <linux/kernel_stat.h> 31#include <linux/kernel_stat.h>
32#include <linux/start_kernel.h>
32#include <linux/security.h> 33#include <linux/security.h>
33#include <linux/workqueue.h> 34#include <linux/workqueue.h>
34#include <linux/profile.h> 35#include <linux/profile.h>
@@ -73,6 +74,10 @@
73#error Sorry, your GCC is too old. It builds incorrect kernels. 74#error Sorry, your GCC is too old. It builds incorrect kernels.
74#endif 75#endif
75 76
77#if __GNUC__ == 4 && __GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ == 0
78#warning gcc-4.1.0 is known to miscompile the kernel. A different compiler version is recommended.
79#endif
80
76static int init(void *); 81static int init(void *);
77 82
78extern void init_IRQ(void); 83extern void init_IRQ(void);
diff --git a/ipc/compat.c b/ipc/compat.c
index 4d20cfd38f0a..fa18141539fb 100644
--- a/ipc/compat.c
+++ b/ipc/compat.c
@@ -115,7 +115,6 @@ struct compat_shm_info {
115 115
116extern int sem_ctls[]; 116extern int sem_ctls[];
117#define sc_semopm (sem_ctls[2]) 117#define sc_semopm (sem_ctls[2])
118#define MAXBUF (64*1024)
119 118
120static inline int compat_ipc_parse_version(int *cmd) 119static inline int compat_ipc_parse_version(int *cmd)
121{ 120{
@@ -307,35 +306,30 @@ long compat_sys_semctl(int first, int second, int third, void __user *uptr)
307 306
308long compat_sys_msgsnd(int first, int second, int third, void __user *uptr) 307long compat_sys_msgsnd(int first, int second, int third, void __user *uptr)
309{ 308{
310 struct msgbuf __user *p;
311 struct compat_msgbuf __user *up = uptr; 309 struct compat_msgbuf __user *up = uptr;
312 long type; 310 long type;
313 311
314 if (first < 0) 312 if (first < 0)
315 return -EINVAL; 313 return -EINVAL;
316 if (second < 0 || (second >= MAXBUF - sizeof(struct msgbuf))) 314 if (second < 0)
317 return -EINVAL; 315 return -EINVAL;
318 316
319 p = compat_alloc_user_space(second + sizeof(struct msgbuf)); 317 if (get_user(type, &up->mtype))
320 if (get_user(type, &up->mtype) ||
321 put_user(type, &p->mtype) ||
322 copy_in_user(p->mtext, up->mtext, second))
323 return -EFAULT; 318 return -EFAULT;
324 319
325 return sys_msgsnd(first, p, second, third); 320 return do_msgsnd(first, type, up->mtext, second, third);
326} 321}
327 322
328long compat_sys_msgrcv(int first, int second, int msgtyp, int third, 323long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
329 int version, void __user *uptr) 324 int version, void __user *uptr)
330{ 325{
331 struct msgbuf __user *p;
332 struct compat_msgbuf __user *up; 326 struct compat_msgbuf __user *up;
333 long type; 327 long type;
334 int err; 328 int err;
335 329
336 if (first < 0) 330 if (first < 0)
337 return -EINVAL; 331 return -EINVAL;
338 if (second < 0 || (second >= MAXBUF - sizeof(struct msgbuf))) 332 if (second < 0)
339 return -EINVAL; 333 return -EINVAL;
340 334
341 if (!version) { 335 if (!version) {
@@ -349,14 +343,11 @@ long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
349 uptr = compat_ptr(ipck.msgp); 343 uptr = compat_ptr(ipck.msgp);
350 msgtyp = ipck.msgtyp; 344 msgtyp = ipck.msgtyp;
351 } 345 }
352 p = compat_alloc_user_space(second + sizeof(struct msgbuf)); 346 up = uptr;
353 err = sys_msgrcv(first, p, second, msgtyp, third); 347 err = do_msgrcv(first, &type, up->mtext, second, msgtyp, third);
354 if (err < 0) 348 if (err < 0)
355 goto out; 349 goto out;
356 up = uptr; 350 if (put_user(type, &up->mtype))
357 if (get_user(type, &p->mtype) ||
358 put_user(type, &up->mtype) ||
359 copy_in_user(up->mtext, p->mtext, err))
360 err = -EFAULT; 351 err = -EFAULT;
361out: 352out:
362 return err; 353 return err;
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 7c274002c9f5..3acc1661e517 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -90,7 +90,7 @@ static struct super_operations mqueue_super_ops;
90static void remove_notification(struct mqueue_inode_info *info); 90static void remove_notification(struct mqueue_inode_info *info);
91 91
92static spinlock_t mq_lock; 92static spinlock_t mq_lock;
93static kmem_cache_t *mqueue_inode_cachep; 93static struct kmem_cache *mqueue_inode_cachep;
94static struct vfsmount *mqueue_mnt; 94static struct vfsmount *mqueue_mnt;
95 95
96static unsigned int queues_count; 96static unsigned int queues_count;
@@ -211,7 +211,7 @@ static int mqueue_get_sb(struct file_system_type *fs_type,
211 return get_sb_single(fs_type, flags, data, mqueue_fill_super, mnt); 211 return get_sb_single(fs_type, flags, data, mqueue_fill_super, mnt);
212} 212}
213 213
214static void init_once(void *foo, kmem_cache_t * cachep, unsigned long flags) 214static void init_once(void *foo, struct kmem_cache * cachep, unsigned long flags)
215{ 215{
216 struct mqueue_inode_info *p = (struct mqueue_inode_info *) foo; 216 struct mqueue_inode_info *p = (struct mqueue_inode_info *) foo;
217 217
@@ -224,7 +224,7 @@ static struct inode *mqueue_alloc_inode(struct super_block *sb)
224{ 224{
225 struct mqueue_inode_info *ei; 225 struct mqueue_inode_info *ei;
226 226
227 ei = kmem_cache_alloc(mqueue_inode_cachep, SLAB_KERNEL); 227 ei = kmem_cache_alloc(mqueue_inode_cachep, GFP_KERNEL);
228 if (!ei) 228 if (!ei)
229 return NULL; 229 return NULL;
230 return &ei->vfs_inode; 230 return &ei->vfs_inode;
diff --git a/ipc/msg.c b/ipc/msg.c
index 1266b1d0c8e3..a388824740e7 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -626,12 +626,11 @@ static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg)
626 return 0; 626 return 0;
627} 627}
628 628
629asmlinkage long 629long do_msgsnd(int msqid, long mtype, void __user *mtext,
630sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg) 630 size_t msgsz, int msgflg)
631{ 631{
632 struct msg_queue *msq; 632 struct msg_queue *msq;
633 struct msg_msg *msg; 633 struct msg_msg *msg;
634 long mtype;
635 int err; 634 int err;
636 struct ipc_namespace *ns; 635 struct ipc_namespace *ns;
637 636
@@ -639,12 +638,10 @@ sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
639 638
640 if (msgsz > ns->msg_ctlmax || (long) msgsz < 0 || msqid < 0) 639 if (msgsz > ns->msg_ctlmax || (long) msgsz < 0 || msqid < 0)
641 return -EINVAL; 640 return -EINVAL;
642 if (get_user(mtype, &msgp->mtype))
643 return -EFAULT;
644 if (mtype < 1) 641 if (mtype < 1)
645 return -EINVAL; 642 return -EINVAL;
646 643
647 msg = load_msg(msgp->mtext, msgsz); 644 msg = load_msg(mtext, msgsz);
648 if (IS_ERR(msg)) 645 if (IS_ERR(msg))
649 return PTR_ERR(msg); 646 return PTR_ERR(msg);
650 647
@@ -723,6 +720,16 @@ out_free:
723 return err; 720 return err;
724} 721}
725 722
723asmlinkage long
724sys_msgsnd(int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg)
725{
726 long mtype;
727
728 if (get_user(mtype, &msgp->mtype))
729 return -EFAULT;
730 return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg);
731}
732
726static inline int convert_mode(long *msgtyp, int msgflg) 733static inline int convert_mode(long *msgtyp, int msgflg)
727{ 734{
728 /* 735 /*
@@ -742,8 +749,8 @@ static inline int convert_mode(long *msgtyp, int msgflg)
742 return SEARCH_EQUAL; 749 return SEARCH_EQUAL;
743} 750}
744 751
745asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz, 752long do_msgrcv(int msqid, long *pmtype, void __user *mtext,
746 long msgtyp, int msgflg) 753 size_t msgsz, long msgtyp, int msgflg)
747{ 754{
748 struct msg_queue *msq; 755 struct msg_queue *msq;
749 struct msg_msg *msg; 756 struct msg_msg *msg;
@@ -889,15 +896,30 @@ out_unlock:
889 return PTR_ERR(msg); 896 return PTR_ERR(msg);
890 897
891 msgsz = (msgsz > msg->m_ts) ? msg->m_ts : msgsz; 898 msgsz = (msgsz > msg->m_ts) ? msg->m_ts : msgsz;
892 if (put_user (msg->m_type, &msgp->mtype) || 899 *pmtype = msg->m_type;
893 store_msg(msgp->mtext, msg, msgsz)) { 900 if (store_msg(mtext, msg, msgsz))
894 msgsz = -EFAULT; 901 msgsz = -EFAULT;
895 } 902
896 free_msg(msg); 903 free_msg(msg);
897 904
898 return msgsz; 905 return msgsz;
899} 906}
900 907
908asmlinkage long sys_msgrcv(int msqid, struct msgbuf __user *msgp, size_t msgsz,
909 long msgtyp, int msgflg)
910{
911 long err, mtype;
912
913 err = do_msgrcv(msqid, &mtype, msgp->mtext, msgsz, msgtyp, msgflg);
914 if (err < 0)
915 goto out;
916
917 if (put_user(mtype, &msgp->mtype))
918 err = -EFAULT;
919out:
920 return err;
921}
922
901#ifdef CONFIG_PROC_FS 923#ifdef CONFIG_PROC_FS
902static int sysvipc_msg_proc_show(struct seq_file *s, void *it) 924static int sysvipc_msg_proc_show(struct seq_file *s, void *it)
903{ 925{
diff --git a/ipc/sem.c b/ipc/sem.c
index 21b3289d640c..d3e12efd55cb 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1070,14 +1070,13 @@ static struct sem_undo *find_undo(struct ipc_namespace *ns, int semid)
1070 ipc_rcu_getref(sma); 1070 ipc_rcu_getref(sma);
1071 sem_unlock(sma); 1071 sem_unlock(sma);
1072 1072
1073 new = (struct sem_undo *) kmalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL); 1073 new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL);
1074 if (!new) { 1074 if (!new) {
1075 ipc_lock_by_ptr(&sma->sem_perm); 1075 ipc_lock_by_ptr(&sma->sem_perm);
1076 ipc_rcu_putref(sma); 1076 ipc_rcu_putref(sma);
1077 sem_unlock(sma); 1077 sem_unlock(sma);
1078 return ERR_PTR(-ENOMEM); 1078 return ERR_PTR(-ENOMEM);
1079 } 1079 }
1080 memset(new, 0, sizeof(struct sem_undo) + sizeof(short)*nsems);
1081 new->semadj = (short *) &new[1]; 1080 new->semadj = (short *) &new[1];
1082 new->semid = semid; 1081 new->semid = semid;
1083 1082
diff --git a/kernel/Kconfig.hz b/kernel/Kconfig.hz
index 248e1c396f8b..4af15802ccd4 100644
--- a/kernel/Kconfig.hz
+++ b/kernel/Kconfig.hz
@@ -7,7 +7,7 @@ choice
7 default HZ_250 7 default HZ_250
8 help 8 help
9 Allows the configuration of the timer frequency. It is customary 9 Allows the configuration of the timer frequency. It is customary
10 to have the timer interrupt run at 1000 HZ but 100 HZ may be more 10 to have the timer interrupt run at 1000 Hz but 100 Hz may be more
11 beneficial for servers and NUMA systems that do not need to have 11 beneficial for servers and NUMA systems that do not need to have
12 a fast response for user interaction and that may experience bus 12 a fast response for user interaction and that may experience bus
13 contention and cacheline bounces as a result of timer interrupts. 13 contention and cacheline bounces as a result of timer interrupts.
@@ -19,21 +19,30 @@ choice
19 config HZ_100 19 config HZ_100
20 bool "100 HZ" 20 bool "100 HZ"
21 help 21 help
22 100 HZ is a typical choice for servers, SMP and NUMA systems 22 100 Hz is a typical choice for servers, SMP and NUMA systems
23 with lots of processors that may show reduced performance if 23 with lots of processors that may show reduced performance if
24 too many timer interrupts are occurring. 24 too many timer interrupts are occurring.
25 25
26 config HZ_250 26 config HZ_250
27 bool "250 HZ" 27 bool "250 HZ"
28 help 28 help
29 250 HZ is a good compromise choice allowing server performance 29 250 Hz is a good compromise choice allowing server performance
30 while also showing good interactive responsiveness even 30 while also showing good interactive responsiveness even
31 on SMP and NUMA systems. 31 on SMP and NUMA systems. If you are going to be using NTSC video
32 or multimedia, selected 300Hz instead.
33
34 config HZ_300
35 bool "300 HZ"
36 help
37 300 Hz is a good compromise choice allowing server performance
38 while also showing good interactive responsiveness even
39 on SMP and NUMA systems and exactly dividing by both PAL and
40 NTSC frame rates for video and multimedia work.
32 41
33 config HZ_1000 42 config HZ_1000
34 bool "1000 HZ" 43 bool "1000 HZ"
35 help 44 help
36 1000 HZ is the preferred choice for desktop systems and other 45 1000 Hz is the preferred choice for desktop systems and other
37 systems requiring fast interactive responses to events. 46 systems requiring fast interactive responses to events.
38 47
39endchoice 48endchoice
@@ -42,5 +51,6 @@ config HZ
42 int 51 int
43 default 100 if HZ_100 52 default 100 if HZ_100
44 default 250 if HZ_250 53 default 250 if HZ_250
54 default 300 if HZ_300
45 default 1000 if HZ_1000 55 default 1000 if HZ_1000
46 56
diff --git a/kernel/acct.c b/kernel/acct.c
index 0aad5ca36a81..dc12db8600e7 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -89,7 +89,8 @@ struct acct_glbs {
89 struct timer_list timer; 89 struct timer_list timer;
90}; 90};
91 91
92static struct acct_glbs acct_globals __cacheline_aligned = {SPIN_LOCK_UNLOCKED}; 92static struct acct_glbs acct_globals __cacheline_aligned =
93 {__SPIN_LOCK_UNLOCKED(acct_globals.lock)};
93 94
94/* 95/*
95 * Called whenever the timer says to check the free space. 96 * Called whenever the timer says to check the free space.
diff --git a/kernel/audit.c b/kernel/audit.c
index 98106f6078b0..d9b690ac684b 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -57,6 +57,7 @@
57#include <linux/netlink.h> 57#include <linux/netlink.h>
58#include <linux/selinux.h> 58#include <linux/selinux.h>
59#include <linux/inotify.h> 59#include <linux/inotify.h>
60#include <linux/freezer.h>
60 61
61#include "audit.h" 62#include "audit.h"
62 63
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 4f40d923af8e..2e896f8ae29e 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -636,10 +636,9 @@ static struct audit_rule *audit_krule_to_rule(struct audit_krule *krule)
636 struct audit_rule *rule; 636 struct audit_rule *rule;
637 int i; 637 int i;
638 638
639 rule = kmalloc(sizeof(*rule), GFP_KERNEL); 639 rule = kzalloc(sizeof(*rule), GFP_KERNEL);
640 if (unlikely(!rule)) 640 if (unlikely(!rule))
641 return NULL; 641 return NULL;
642 memset(rule, 0, sizeof(*rule));
643 642
644 rule->flags = krule->flags | krule->listnr; 643 rule->flags = krule->flags | krule->listnr;
645 rule->action = krule->action; 644 rule->action = krule->action;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index ab97e5101232..40722e26de98 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -731,7 +731,7 @@ static inline void audit_free_context(struct audit_context *context)
731 printk(KERN_ERR "audit: freed %d contexts\n", count); 731 printk(KERN_ERR "audit: freed %d contexts\n", count);
732} 732}
733 733
734static void audit_log_task_context(struct audit_buffer *ab) 734void audit_log_task_context(struct audit_buffer *ab)
735{ 735{
736 char *ctx = NULL; 736 char *ctx = NULL;
737 ssize_t len = 0; 737 ssize_t len = 0;
@@ -760,6 +760,8 @@ error_path:
760 return; 760 return;
761} 761}
762 762
763EXPORT_SYMBOL(audit_log_task_context);
764
763static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk) 765static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk)
764{ 766{
765 char name[sizeof(tsk->comm)]; 767 char name[sizeof(tsk->comm)];
@@ -1488,6 +1490,8 @@ uid_t audit_get_loginuid(struct audit_context *ctx)
1488 return ctx ? ctx->loginuid : -1; 1490 return ctx ? ctx->loginuid : -1;
1489} 1491}
1490 1492
1493EXPORT_SYMBOL(audit_get_loginuid);
1494
1491/** 1495/**
1492 * __audit_mq_open - record audit data for a POSIX MQ open 1496 * __audit_mq_open - record audit data for a POSIX MQ open
1493 * @oflag: open flag 1497 * @oflag: open flag
diff --git a/kernel/configs.c b/kernel/configs.c
index f9e31974f4ad..8fa1fb28f8a7 100644
--- a/kernel/configs.c
+++ b/kernel/configs.c
@@ -75,7 +75,7 @@ ikconfig_read_current(struct file *file, char __user *buf,
75 return count; 75 return count;
76} 76}
77 77
78static struct file_operations ikconfig_file_ops = { 78static const struct file_operations ikconfig_file_ops = {
79 .owner = THIS_MODULE, 79 .owner = THIS_MODULE,
80 .read = ikconfig_read_current, 80 .read = ikconfig_read_current,
81}; 81};
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 272254f20d97..9124669f4586 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -270,11 +270,7 @@ int disable_nonboot_cpus(void)
270 goto out; 270 goto out;
271 } 271 }
272 } 272 }
273 error = set_cpus_allowed(current, cpumask_of_cpu(first_cpu)); 273
274 if (error) {
275 printk(KERN_ERR "Could not run on CPU%d\n", first_cpu);
276 goto out;
277 }
278 /* We take down all of the non-boot CPUs in one shot to avoid races 274 /* We take down all of the non-boot CPUs in one shot to avoid races
279 * with the userspace trying to use the CPU hotplug at the same time 275 * with the userspace trying to use the CPU hotplug at the same time
280 */ 276 */
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 6313c38c930e..0a6b4d89f9a0 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -729,9 +729,11 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
729 } 729 }
730 730
731 /* Remaining checks don't apply to root cpuset */ 731 /* Remaining checks don't apply to root cpuset */
732 if ((par = cur->parent) == NULL) 732 if (cur == &top_cpuset)
733 return 0; 733 return 0;
734 734
735 par = cur->parent;
736
735 /* We must be a subset of our parent cpuset */ 737 /* We must be a subset of our parent cpuset */
736 if (!is_cpuset_subset(trial, par)) 738 if (!is_cpuset_subset(trial, par))
737 return -EACCES; 739 return -EACCES;
@@ -1060,10 +1062,7 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf)
1060 cpu_exclusive_changed = 1062 cpu_exclusive_changed =
1061 (is_cpu_exclusive(cs) != is_cpu_exclusive(&trialcs)); 1063 (is_cpu_exclusive(cs) != is_cpu_exclusive(&trialcs));
1062 mutex_lock(&callback_mutex); 1064 mutex_lock(&callback_mutex);
1063 if (turning_on) 1065 cs->flags = trialcs.flags;
1064 set_bit(bit, &cs->flags);
1065 else
1066 clear_bit(bit, &cs->flags);
1067 mutex_unlock(&callback_mutex); 1066 mutex_unlock(&callback_mutex);
1068 1067
1069 if (cpu_exclusive_changed) 1068 if (cpu_exclusive_changed)
@@ -1281,7 +1280,8 @@ typedef enum {
1281 FILE_TASKLIST, 1280 FILE_TASKLIST,
1282} cpuset_filetype_t; 1281} cpuset_filetype_t;
1283 1282
1284static ssize_t cpuset_common_file_write(struct file *file, const char __user *userbuf, 1283static ssize_t cpuset_common_file_write(struct file *file,
1284 const char __user *userbuf,
1285 size_t nbytes, loff_t *unused_ppos) 1285 size_t nbytes, loff_t *unused_ppos)
1286{ 1286{
1287 struct cpuset *cs = __d_cs(file->f_dentry->d_parent); 1287 struct cpuset *cs = __d_cs(file->f_dentry->d_parent);
@@ -1292,7 +1292,7 @@ static ssize_t cpuset_common_file_write(struct file *file, const char __user *us
1292 int retval = 0; 1292 int retval = 0;
1293 1293
1294 /* Crude upper limit on largest legitimate cpulist user might write. */ 1294 /* Crude upper limit on largest legitimate cpulist user might write. */
1295 if (nbytes > 100 + 6 * NR_CPUS) 1295 if (nbytes > 100 + 6 * max(NR_CPUS, MAX_NUMNODES))
1296 return -E2BIG; 1296 return -E2BIG;
1297 1297
1298 /* +1 for nul-terminator */ 1298 /* +1 for nul-terminator */
@@ -1532,7 +1532,7 @@ static int cpuset_rename(struct inode *old_dir, struct dentry *old_dentry,
1532 return simple_rename(old_dir, old_dentry, new_dir, new_dentry); 1532 return simple_rename(old_dir, old_dentry, new_dir, new_dentry);
1533} 1533}
1534 1534
1535static struct file_operations cpuset_file_operations = { 1535static const struct file_operations cpuset_file_operations = {
1536 .read = cpuset_file_read, 1536 .read = cpuset_file_read,
1537 .write = cpuset_file_write, 1537 .write = cpuset_file_write,
1538 .llseek = generic_file_llseek, 1538 .llseek = generic_file_llseek,
@@ -2045,7 +2045,6 @@ out:
2045 return err; 2045 return err;
2046} 2046}
2047 2047
2048#if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_MEMORY_HOTPLUG)
2049/* 2048/*
2050 * If common_cpu_mem_hotplug_unplug(), below, unplugs any CPUs 2049 * If common_cpu_mem_hotplug_unplug(), below, unplugs any CPUs
2051 * or memory nodes, we need to walk over the cpuset hierarchy, 2050 * or memory nodes, we need to walk over the cpuset hierarchy,
@@ -2109,9 +2108,7 @@ static void common_cpu_mem_hotplug_unplug(void)
2109 mutex_unlock(&callback_mutex); 2108 mutex_unlock(&callback_mutex);
2110 mutex_unlock(&manage_mutex); 2109 mutex_unlock(&manage_mutex);
2111} 2110}
2112#endif
2113 2111
2114#ifdef CONFIG_HOTPLUG_CPU
2115/* 2112/*
2116 * The top_cpuset tracks what CPUs and Memory Nodes are online, 2113 * The top_cpuset tracks what CPUs and Memory Nodes are online,
2117 * period. This is necessary in order to make cpusets transparent 2114 * period. This is necessary in order to make cpusets transparent
@@ -2128,7 +2125,6 @@ static int cpuset_handle_cpuhp(struct notifier_block *nb,
2128 common_cpu_mem_hotplug_unplug(); 2125 common_cpu_mem_hotplug_unplug();
2129 return 0; 2126 return 0;
2130} 2127}
2131#endif
2132 2128
2133#ifdef CONFIG_MEMORY_HOTPLUG 2129#ifdef CONFIG_MEMORY_HOTPLUG
2134/* 2130/*
@@ -2610,7 +2606,7 @@ static int cpuset_open(struct inode *inode, struct file *file)
2610 return single_open(file, proc_cpuset_show, pid); 2606 return single_open(file, proc_cpuset_show, pid);
2611} 2607}
2612 2608
2613struct file_operations proc_cpuset_operations = { 2609const struct file_operations proc_cpuset_operations = {
2614 .open = cpuset_open, 2610 .open = cpuset_open,
2615 .read = seq_read, 2611 .read = seq_read,
2616 .llseek = seq_lseek, 2612 .llseek = seq_lseek,
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 66a0ea48751d..766d5912b26a 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -20,7 +20,7 @@
20#include <linux/delayacct.h> 20#include <linux/delayacct.h>
21 21
22int delayacct_on __read_mostly = 1; /* Delay accounting turned on/off */ 22int delayacct_on __read_mostly = 1; /* Delay accounting turned on/off */
23kmem_cache_t *delayacct_cache; 23struct kmem_cache *delayacct_cache;
24 24
25static int __init delayacct_setup_disable(char *str) 25static int __init delayacct_setup_disable(char *str)
26{ 26{
@@ -41,7 +41,7 @@ void delayacct_init(void)
41 41
42void __delayacct_tsk_init(struct task_struct *tsk) 42void __delayacct_tsk_init(struct task_struct *tsk)
43{ 43{
44 tsk->delays = kmem_cache_zalloc(delayacct_cache, SLAB_KERNEL); 44 tsk->delays = kmem_cache_zalloc(delayacct_cache, GFP_KERNEL);
45 if (tsk->delays) 45 if (tsk->delays)
46 spin_lock_init(&tsk->delays->lock); 46 spin_lock_init(&tsk->delays->lock);
47} 47}
diff --git a/kernel/dma.c b/kernel/dma.c
index 2020644c938a..937b13ca33ba 100644
--- a/kernel/dma.c
+++ b/kernel/dma.c
@@ -140,7 +140,7 @@ static int proc_dma_open(struct inode *inode, struct file *file)
140 return single_open(file, proc_dma_show, NULL); 140 return single_open(file, proc_dma_show, NULL);
141} 141}
142 142
143static struct file_operations proc_dma_operations = { 143static const struct file_operations proc_dma_operations = {
144 .open = proc_dma_open, 144 .open = proc_dma_open,
145 .read = seq_read, 145 .read = seq_read,
146 .llseek = seq_lseek, 146 .llseek = seq_lseek,
diff --git a/kernel/exit.c b/kernel/exit.c
index 06de6c4e8ca3..4e3f919edc48 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -850,9 +850,7 @@ static void exit_notify(struct task_struct *tsk)
850fastcall NORET_TYPE void do_exit(long code) 850fastcall NORET_TYPE void do_exit(long code)
851{ 851{
852 struct task_struct *tsk = current; 852 struct task_struct *tsk = current;
853 struct taskstats *tidstats;
854 int group_dead; 853 int group_dead;
855 unsigned int mycpu;
856 854
857 profile_task_exit(tsk); 855 profile_task_exit(tsk);
858 856
@@ -890,8 +888,6 @@ fastcall NORET_TYPE void do_exit(long code)
890 current->comm, current->pid, 888 current->comm, current->pid,
891 preempt_count()); 889 preempt_count());
892 890
893 taskstats_exit_alloc(&tidstats, &mycpu);
894
895 acct_update_integrals(tsk); 891 acct_update_integrals(tsk);
896 if (tsk->mm) { 892 if (tsk->mm) {
897 update_hiwater_rss(tsk->mm); 893 update_hiwater_rss(tsk->mm);
@@ -911,8 +907,8 @@ fastcall NORET_TYPE void do_exit(long code)
911#endif 907#endif
912 if (unlikely(tsk->audit_context)) 908 if (unlikely(tsk->audit_context))
913 audit_free(tsk); 909 audit_free(tsk);
914 taskstats_exit_send(tsk, tidstats, group_dead, mycpu); 910
915 taskstats_exit_free(tidstats); 911 taskstats_exit(tsk, group_dead);
916 912
917 exit_mm(tsk); 913 exit_mm(tsk);
918 914
diff --git a/kernel/fork.c b/kernel/fork.c
index 8cdd3e72ba55..7f2e31ba33af 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -82,26 +82,26 @@ int nr_processes(void)
82#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR 82#ifndef __HAVE_ARCH_TASK_STRUCT_ALLOCATOR
83# define alloc_task_struct() kmem_cache_alloc(task_struct_cachep, GFP_KERNEL) 83# define alloc_task_struct() kmem_cache_alloc(task_struct_cachep, GFP_KERNEL)
84# define free_task_struct(tsk) kmem_cache_free(task_struct_cachep, (tsk)) 84# define free_task_struct(tsk) kmem_cache_free(task_struct_cachep, (tsk))
85static kmem_cache_t *task_struct_cachep; 85static struct kmem_cache *task_struct_cachep;
86#endif 86#endif
87 87
88/* SLAB cache for signal_struct structures (tsk->signal) */ 88/* SLAB cache for signal_struct structures (tsk->signal) */
89static kmem_cache_t *signal_cachep; 89static struct kmem_cache *signal_cachep;
90 90
91/* SLAB cache for sighand_struct structures (tsk->sighand) */ 91/* SLAB cache for sighand_struct structures (tsk->sighand) */
92kmem_cache_t *sighand_cachep; 92struct kmem_cache *sighand_cachep;
93 93
94/* SLAB cache for files_struct structures (tsk->files) */ 94/* SLAB cache for files_struct structures (tsk->files) */
95kmem_cache_t *files_cachep; 95struct kmem_cache *files_cachep;
96 96
97/* SLAB cache for fs_struct structures (tsk->fs) */ 97/* SLAB cache for fs_struct structures (tsk->fs) */
98kmem_cache_t *fs_cachep; 98struct kmem_cache *fs_cachep;
99 99
100/* SLAB cache for vm_area_struct structures */ 100/* SLAB cache for vm_area_struct structures */
101kmem_cache_t *vm_area_cachep; 101struct kmem_cache *vm_area_cachep;
102 102
103/* SLAB cache for mm_struct structures (tsk->mm) */ 103/* SLAB cache for mm_struct structures (tsk->mm) */
104static kmem_cache_t *mm_cachep; 104static struct kmem_cache *mm_cachep;
105 105
106void free_task(struct task_struct *tsk) 106void free_task(struct task_struct *tsk)
107{ 107{
@@ -237,7 +237,7 @@ static inline int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
237 goto fail_nomem; 237 goto fail_nomem;
238 charge = len; 238 charge = len;
239 } 239 }
240 tmp = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 240 tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
241 if (!tmp) 241 if (!tmp)
242 goto fail_nomem; 242 goto fail_nomem;
243 *tmp = *mpnt; 243 *tmp = *mpnt;
@@ -319,7 +319,7 @@ static inline void mm_free_pgd(struct mm_struct * mm)
319 319
320 __cacheline_aligned_in_smp DEFINE_SPINLOCK(mmlist_lock); 320 __cacheline_aligned_in_smp DEFINE_SPINLOCK(mmlist_lock);
321 321
322#define allocate_mm() (kmem_cache_alloc(mm_cachep, SLAB_KERNEL)) 322#define allocate_mm() (kmem_cache_alloc(mm_cachep, GFP_KERNEL))
323#define free_mm(mm) (kmem_cache_free(mm_cachep, (mm))) 323#define free_mm(mm) (kmem_cache_free(mm_cachep, (mm)))
324 324
325#include <linux/init_task.h> 325#include <linux/init_task.h>
@@ -448,7 +448,16 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
448 tsk->vfork_done = NULL; 448 tsk->vfork_done = NULL;
449 complete(vfork_done); 449 complete(vfork_done);
450 } 450 }
451 if (tsk->clear_child_tid && atomic_read(&mm->mm_users) > 1) { 451
452 /*
453 * If we're exiting normally, clear a user-space tid field if
454 * requested. We leave this alone when dying by signal, to leave
455 * the value intact in a core dump, and to save the unnecessary
456 * trouble otherwise. Userland only wants this done for a sys_exit.
457 */
458 if (tsk->clear_child_tid
459 && !(tsk->flags & PF_SIGNALED)
460 && atomic_read(&mm->mm_users) > 1) {
452 u32 __user * tidptr = tsk->clear_child_tid; 461 u32 __user * tidptr = tsk->clear_child_tid;
453 tsk->clear_child_tid = NULL; 462 tsk->clear_child_tid = NULL;
454 463
@@ -479,6 +488,10 @@ static struct mm_struct *dup_mm(struct task_struct *tsk)
479 488
480 memcpy(mm, oldmm, sizeof(*mm)); 489 memcpy(mm, oldmm, sizeof(*mm));
481 490
491 /* Initializing for Swap token stuff */
492 mm->token_priority = 0;
493 mm->last_interval = 0;
494
482 if (!mm_init(mm)) 495 if (!mm_init(mm))
483 goto fail_nomem; 496 goto fail_nomem;
484 497
@@ -542,6 +555,10 @@ static int copy_mm(unsigned long clone_flags, struct task_struct * tsk)
542 goto fail_nomem; 555 goto fail_nomem;
543 556
544good_mm: 557good_mm:
558 /* Initializing for Swap token stuff */
559 mm->token_priority = 0;
560 mm->last_interval = 0;
561
545 tsk->mm = mm; 562 tsk->mm = mm;
546 tsk->active_mm = mm; 563 tsk->active_mm = mm;
547 return 0; 564 return 0;
@@ -613,7 +630,7 @@ static struct files_struct *alloc_files(void)
613 struct files_struct *newf; 630 struct files_struct *newf;
614 struct fdtable *fdt; 631 struct fdtable *fdt;
615 632
616 newf = kmem_cache_alloc(files_cachep, SLAB_KERNEL); 633 newf = kmem_cache_alloc(files_cachep, GFP_KERNEL);
617 if (!newf) 634 if (!newf)
618 goto out; 635 goto out;
619 636
@@ -830,7 +847,6 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
830 if (clone_flags & CLONE_THREAD) { 847 if (clone_flags & CLONE_THREAD) {
831 atomic_inc(&current->signal->count); 848 atomic_inc(&current->signal->count);
832 atomic_inc(&current->signal->live); 849 atomic_inc(&current->signal->live);
833 taskstats_tgid_alloc(current);
834 return 0; 850 return 0;
835 } 851 }
836 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); 852 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
@@ -1303,7 +1319,7 @@ fork_out:
1303 return ERR_PTR(retval); 1319 return ERR_PTR(retval);
1304} 1320}
1305 1321
1306struct pt_regs * __devinit __attribute__((weak)) idle_regs(struct pt_regs *regs) 1322noinline struct pt_regs * __devinit __attribute__((weak)) idle_regs(struct pt_regs *regs)
1307{ 1323{
1308 memset(regs, 0, sizeof(struct pt_regs)); 1324 memset(regs, 0, sizeof(struct pt_regs));
1309 return regs; 1325 return regs;
@@ -1413,7 +1429,7 @@ long do_fork(unsigned long clone_flags,
1413#define ARCH_MIN_MMSTRUCT_ALIGN 0 1429#define ARCH_MIN_MMSTRUCT_ALIGN 0
1414#endif 1430#endif
1415 1431
1416static void sighand_ctor(void *data, kmem_cache_t *cachep, unsigned long flags) 1432static void sighand_ctor(void *data, struct kmem_cache *cachep, unsigned long flags)
1417{ 1433{
1418 struct sighand_struct *sighand = data; 1434 struct sighand_struct *sighand = data;
1419 1435
diff --git a/kernel/futex.c b/kernel/futex.c
index 93ef30ba209f..95989a3b4168 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -282,9 +282,9 @@ static inline int get_futex_value_locked(u32 *dest, u32 __user *from)
282{ 282{
283 int ret; 283 int ret;
284 284
285 inc_preempt_count(); 285 pagefault_disable();
286 ret = __copy_from_user_inatomic(dest, from, sizeof(u32)); 286 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
287 dec_preempt_count(); 287 pagefault_enable();
288 288
289 return ret ? -EFAULT : 0; 289 return ret ? -EFAULT : 0;
290} 290}
@@ -324,12 +324,11 @@ static int refill_pi_state_cache(void)
324 if (likely(current->pi_state_cache)) 324 if (likely(current->pi_state_cache))
325 return 0; 325 return 0;
326 326
327 pi_state = kmalloc(sizeof(*pi_state), GFP_KERNEL); 327 pi_state = kzalloc(sizeof(*pi_state), GFP_KERNEL);
328 328
329 if (!pi_state) 329 if (!pi_state)
330 return -ENOMEM; 330 return -ENOMEM;
331 331
332 memset(pi_state, 0, sizeof(*pi_state));
333 INIT_LIST_HEAD(&pi_state->list); 332 INIT_LIST_HEAD(&pi_state->list);
334 /* pi_mutex gets initialized later */ 333 /* pi_mutex gets initialized later */
335 pi_state->owner = NULL; 334 pi_state->owner = NULL;
@@ -553,7 +552,7 @@ static void wake_futex(struct futex_q *q)
553 * at the end of wake_up_all() does not prevent this store from 552 * at the end of wake_up_all() does not prevent this store from
554 * moving. 553 * moving.
555 */ 554 */
556 wmb(); 555 smp_wmb();
557 q->lock_ptr = NULL; 556 q->lock_ptr = NULL;
558} 557}
559 558
@@ -585,9 +584,9 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
585 if (!(uval & FUTEX_OWNER_DIED)) { 584 if (!(uval & FUTEX_OWNER_DIED)) {
586 newval = FUTEX_WAITERS | new_owner->pid; 585 newval = FUTEX_WAITERS | new_owner->pid;
587 586
588 inc_preempt_count(); 587 pagefault_disable();
589 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval); 588 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval);
590 dec_preempt_count(); 589 pagefault_enable();
591 if (curval == -EFAULT) 590 if (curval == -EFAULT)
592 return -EFAULT; 591 return -EFAULT;
593 if (curval != uval) 592 if (curval != uval)
@@ -618,9 +617,9 @@ static int unlock_futex_pi(u32 __user *uaddr, u32 uval)
618 * There is no waiter, so we unlock the futex. The owner died 617 * There is no waiter, so we unlock the futex. The owner died
619 * bit has not to be preserved here. We are the owner: 618 * bit has not to be preserved here. We are the owner:
620 */ 619 */
621 inc_preempt_count(); 620 pagefault_disable();
622 oldval = futex_atomic_cmpxchg_inatomic(uaddr, uval, 0); 621 oldval = futex_atomic_cmpxchg_inatomic(uaddr, uval, 0);
623 dec_preempt_count(); 622 pagefault_enable();
624 623
625 if (oldval == -EFAULT) 624 if (oldval == -EFAULT)
626 return oldval; 625 return oldval;
@@ -1158,9 +1157,9 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
1158 */ 1157 */
1159 newval = current->pid; 1158 newval = current->pid;
1160 1159
1161 inc_preempt_count(); 1160 pagefault_disable();
1162 curval = futex_atomic_cmpxchg_inatomic(uaddr, 0, newval); 1161 curval = futex_atomic_cmpxchg_inatomic(uaddr, 0, newval);
1163 dec_preempt_count(); 1162 pagefault_enable();
1164 1163
1165 if (unlikely(curval == -EFAULT)) 1164 if (unlikely(curval == -EFAULT))
1166 goto uaddr_faulted; 1165 goto uaddr_faulted;
@@ -1183,9 +1182,9 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
1183 uval = curval; 1182 uval = curval;
1184 newval = uval | FUTEX_WAITERS; 1183 newval = uval | FUTEX_WAITERS;
1185 1184
1186 inc_preempt_count(); 1185 pagefault_disable();
1187 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval); 1186 curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval);
1188 dec_preempt_count(); 1187 pagefault_enable();
1189 1188
1190 if (unlikely(curval == -EFAULT)) 1189 if (unlikely(curval == -EFAULT))
1191 goto uaddr_faulted; 1190 goto uaddr_faulted;
@@ -1215,10 +1214,10 @@ static int futex_lock_pi(u32 __user *uaddr, int detect, unsigned long sec,
1215 newval = current->pid | 1214 newval = current->pid |
1216 FUTEX_OWNER_DIED | FUTEX_WAITERS; 1215 FUTEX_OWNER_DIED | FUTEX_WAITERS;
1217 1216
1218 inc_preempt_count(); 1217 pagefault_disable();
1219 curval = futex_atomic_cmpxchg_inatomic(uaddr, 1218 curval = futex_atomic_cmpxchg_inatomic(uaddr,
1220 uval, newval); 1219 uval, newval);
1221 dec_preempt_count(); 1220 pagefault_enable();
1222 1221
1223 if (unlikely(curval == -EFAULT)) 1222 if (unlikely(curval == -EFAULT))
1224 goto uaddr_faulted; 1223 goto uaddr_faulted;
@@ -1390,9 +1389,9 @@ retry_locked:
1390 * anyone else up: 1389 * anyone else up:
1391 */ 1390 */
1392 if (!(uval & FUTEX_OWNER_DIED)) { 1391 if (!(uval & FUTEX_OWNER_DIED)) {
1393 inc_preempt_count(); 1392 pagefault_disable();
1394 uval = futex_atomic_cmpxchg_inatomic(uaddr, current->pid, 0); 1393 uval = futex_atomic_cmpxchg_inatomic(uaddr, current->pid, 0);
1395 dec_preempt_count(); 1394 pagefault_enable();
1396 } 1395 }
1397 1396
1398 if (unlikely(uval == -EFAULT)) 1397 if (unlikely(uval == -EFAULT))
@@ -1493,7 +1492,7 @@ static unsigned int futex_poll(struct file *filp,
1493 return ret; 1492 return ret;
1494} 1493}
1495 1494
1496static struct file_operations futex_fops = { 1495static const struct file_operations futex_fops = {
1497 .release = futex_close, 1496 .release = futex_close,
1498 .poll = futex_poll, 1497 .poll = futex_poll,
1499}; 1498};
@@ -1858,10 +1857,16 @@ static struct file_system_type futex_fs_type = {
1858 1857
1859static int __init init(void) 1858static int __init init(void)
1860{ 1859{
1861 unsigned int i; 1860 int i = register_filesystem(&futex_fs_type);
1861
1862 if (i)
1863 return i;
1862 1864
1863 register_filesystem(&futex_fs_type);
1864 futex_mnt = kern_mount(&futex_fs_type); 1865 futex_mnt = kern_mount(&futex_fs_type);
1866 if (IS_ERR(futex_mnt)) {
1867 unregister_filesystem(&futex_fs_type);
1868 return PTR_ERR(futex_mnt);
1869 }
1865 1870
1866 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) { 1871 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
1867 INIT_LIST_HEAD(&futex_queues[i].chain); 1872 INIT_LIST_HEAD(&futex_queues[i].chain);
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c
index a681912bc89a..aff1f0fabb0d 100644
--- a/kernel/irq/handle.c
+++ b/kernel/irq/handle.c
@@ -54,7 +54,7 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned = {
54 .chip = &no_irq_chip, 54 .chip = &no_irq_chip,
55 .handle_irq = handle_bad_irq, 55 .handle_irq = handle_bad_irq,
56 .depth = 1, 56 .depth = 1,
57 .lock = SPIN_LOCK_UNLOCKED, 57 .lock = __SPIN_LOCK_UNLOCKED(irq_desc->lock),
58#ifdef CONFIG_SMP 58#ifdef CONFIG_SMP
59 .affinity = CPU_MASK_ALL 59 .affinity = CPU_MASK_ALL
60#endif 60#endif
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index eeac3e313b2b..ab63cfc42992 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -20,6 +20,7 @@
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <linux/sched.h> /* for cond_resched */ 21#include <linux/sched.h> /* for cond_resched */
22#include <linux/mm.h> 22#include <linux/mm.h>
23#include <linux/ctype.h>
23 24
24#include <asm/sections.h> 25#include <asm/sections.h>
25 26
@@ -301,13 +302,6 @@ struct kallsym_iter
301 char name[KSYM_NAME_LEN+1]; 302 char name[KSYM_NAME_LEN+1];
302}; 303};
303 304
304/* Only label it "global" if it is exported. */
305static void upcase_if_global(struct kallsym_iter *iter)
306{
307 if (is_exported(iter->name, iter->owner))
308 iter->type += 'A' - 'a';
309}
310
311static int get_ksymbol_mod(struct kallsym_iter *iter) 305static int get_ksymbol_mod(struct kallsym_iter *iter)
312{ 306{
313 iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms, 307 iter->owner = module_get_kallsym(iter->pos - kallsyms_num_syms,
@@ -316,7 +310,10 @@ static int get_ksymbol_mod(struct kallsym_iter *iter)
316 if (iter->owner == NULL) 310 if (iter->owner == NULL)
317 return 0; 311 return 0;
318 312
319 upcase_if_global(iter); 313 /* Label it "global" if it is exported, "local" if not exported. */
314 iter->type = is_exported(iter->name, iter->owner)
315 ? toupper(iter->type) : tolower(iter->type);
316
320 return 1; 317 return 1;
321} 318}
322 319
@@ -401,7 +398,7 @@ static int s_show(struct seq_file *m, void *p)
401 return 0; 398 return 0;
402} 399}
403 400
404static struct seq_operations kallsyms_op = { 401static const struct seq_operations kallsyms_op = {
405 .start = s_start, 402 .start = s_start,
406 .next = s_next, 403 .next = s_next,
407 .stop = s_stop, 404 .stop = s_stop,
@@ -436,7 +433,7 @@ static int kallsyms_release(struct inode *inode, struct file *file)
436 return seq_release(inode, file); 433 return seq_release(inode, file);
437} 434}
438 435
439static struct file_operations kallsyms_operations = { 436static const struct file_operations kallsyms_operations = {
440 .open = kallsyms_open, 437 .open = kallsyms_open,
441 .read = seq_read, 438 .read = seq_read,
442 .llseek = seq_lseek, 439 .llseek = seq_lseek,
diff --git a/kernel/kexec.c b/kernel/kexec.c
index fcdd5d2bc3f4..afbbbe981be2 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -20,6 +20,8 @@
20#include <linux/syscalls.h> 20#include <linux/syscalls.h>
21#include <linux/ioport.h> 21#include <linux/ioport.h>
22#include <linux/hardirq.h> 22#include <linux/hardirq.h>
23#include <linux/elf.h>
24#include <linux/elfcore.h>
23 25
24#include <asm/page.h> 26#include <asm/page.h>
25#include <asm/uaccess.h> 27#include <asm/uaccess.h>
@@ -108,11 +110,10 @@ static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
108 110
109 /* Allocate a controlling structure */ 111 /* Allocate a controlling structure */
110 result = -ENOMEM; 112 result = -ENOMEM;
111 image = kmalloc(sizeof(*image), GFP_KERNEL); 113 image = kzalloc(sizeof(*image), GFP_KERNEL);
112 if (!image) 114 if (!image)
113 goto out; 115 goto out;
114 116
115 memset(image, 0, sizeof(*image));
116 image->head = 0; 117 image->head = 0;
117 image->entry = &image->head; 118 image->entry = &image->head;
118 image->last_entry = &image->head; 119 image->last_entry = &image->head;
@@ -1067,6 +1068,60 @@ void crash_kexec(struct pt_regs *regs)
1067 } 1068 }
1068} 1069}
1069 1070
1071static u32 *append_elf_note(u32 *buf, char *name, unsigned type, void *data,
1072 size_t data_len)
1073{
1074 struct elf_note note;
1075
1076 note.n_namesz = strlen(name) + 1;
1077 note.n_descsz = data_len;
1078 note.n_type = type;
1079 memcpy(buf, &note, sizeof(note));
1080 buf += (sizeof(note) + 3)/4;
1081 memcpy(buf, name, note.n_namesz);
1082 buf += (note.n_namesz + 3)/4;
1083 memcpy(buf, data, note.n_descsz);
1084 buf += (note.n_descsz + 3)/4;
1085
1086 return buf;
1087}
1088
1089static void final_note(u32 *buf)
1090{
1091 struct elf_note note;
1092
1093 note.n_namesz = 0;
1094 note.n_descsz = 0;
1095 note.n_type = 0;
1096 memcpy(buf, &note, sizeof(note));
1097}
1098
1099void crash_save_cpu(struct pt_regs *regs, int cpu)
1100{
1101 struct elf_prstatus prstatus;
1102 u32 *buf;
1103
1104 if ((cpu < 0) || (cpu >= NR_CPUS))
1105 return;
1106
1107 /* Using ELF notes here is opportunistic.
1108 * I need a well defined structure format
1109 * for the data I pass, and I need tags
1110 * on the data to indicate what information I have
1111 * squirrelled away. ELF notes happen to provide
1112 * all of that, so there is no need to invent something new.
1113 */
1114 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
1115 if (!buf)
1116 return;
1117 memset(&prstatus, 0, sizeof(prstatus));
1118 prstatus.pr_pid = current->pid;
1119 elf_core_copy_regs(&prstatus.pr_reg, regs);
1120 buf = append_elf_note(buf, "CORE", NT_PRSTATUS, &prstatus,
1121 sizeof(prstatus));
1122 final_note(buf);
1123}
1124
1070static int __init crash_notes_memory_init(void) 1125static int __init crash_notes_memory_init(void)
1071{ 1126{
1072 /* Allocate memory for saving cpu registers. */ 1127 /* Allocate memory for saving cpu registers. */
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 610c837ad9e0..17ec4afb0994 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -38,6 +38,7 @@
38#include <linux/module.h> 38#include <linux/module.h>
39#include <linux/moduleloader.h> 39#include <linux/moduleloader.h>
40#include <linux/kallsyms.h> 40#include <linux/kallsyms.h>
41#include <linux/freezer.h>
41#include <asm-generic/sections.h> 42#include <asm-generic/sections.h>
42#include <asm/cacheflush.h> 43#include <asm/cacheflush.h>
43#include <asm/errno.h> 44#include <asm/errno.h>
@@ -83,9 +84,36 @@ struct kprobe_insn_page {
83 kprobe_opcode_t *insns; /* Page of instruction slots */ 84 kprobe_opcode_t *insns; /* Page of instruction slots */
84 char slot_used[INSNS_PER_PAGE]; 85 char slot_used[INSNS_PER_PAGE];
85 int nused; 86 int nused;
87 int ngarbage;
86}; 88};
87 89
88static struct hlist_head kprobe_insn_pages; 90static struct hlist_head kprobe_insn_pages;
91static int kprobe_garbage_slots;
92static int collect_garbage_slots(void);
93
94static int __kprobes check_safety(void)
95{
96 int ret = 0;
97#if defined(CONFIG_PREEMPT) && defined(CONFIG_PM)
98 ret = freeze_processes();
99 if (ret == 0) {
100 struct task_struct *p, *q;
101 do_each_thread(p, q) {
102 if (p != current && p->state == TASK_RUNNING &&
103 p->pid != 0) {
104 printk("Check failed: %s is running\n",p->comm);
105 ret = -1;
106 goto loop_end;
107 }
108 } while_each_thread(p, q);
109 }
110loop_end:
111 thaw_processes();
112#else
113 synchronize_sched();
114#endif
115 return ret;
116}
89 117
90/** 118/**
91 * get_insn_slot() - Find a slot on an executable page for an instruction. 119 * get_insn_slot() - Find a slot on an executable page for an instruction.
@@ -96,6 +124,7 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
96 struct kprobe_insn_page *kip; 124 struct kprobe_insn_page *kip;
97 struct hlist_node *pos; 125 struct hlist_node *pos;
98 126
127 retry:
99 hlist_for_each(pos, &kprobe_insn_pages) { 128 hlist_for_each(pos, &kprobe_insn_pages) {
100 kip = hlist_entry(pos, struct kprobe_insn_page, hlist); 129 kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
101 if (kip->nused < INSNS_PER_PAGE) { 130 if (kip->nused < INSNS_PER_PAGE) {
@@ -112,7 +141,11 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
112 } 141 }
113 } 142 }
114 143
115 /* All out of space. Need to allocate a new page. Use slot 0.*/ 144 /* If there are any garbage slots, collect it and try again. */
145 if (kprobe_garbage_slots && collect_garbage_slots() == 0) {
146 goto retry;
147 }
148 /* All out of space. Need to allocate a new page. Use slot 0. */
116 kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_KERNEL); 149 kip = kmalloc(sizeof(struct kprobe_insn_page), GFP_KERNEL);
117 if (!kip) { 150 if (!kip) {
118 return NULL; 151 return NULL;
@@ -133,10 +166,62 @@ kprobe_opcode_t __kprobes *get_insn_slot(void)
133 memset(kip->slot_used, 0, INSNS_PER_PAGE); 166 memset(kip->slot_used, 0, INSNS_PER_PAGE);
134 kip->slot_used[0] = 1; 167 kip->slot_used[0] = 1;
135 kip->nused = 1; 168 kip->nused = 1;
169 kip->ngarbage = 0;
136 return kip->insns; 170 return kip->insns;
137} 171}
138 172
139void __kprobes free_insn_slot(kprobe_opcode_t *slot) 173/* Return 1 if all garbages are collected, otherwise 0. */
174static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
175{
176 kip->slot_used[idx] = 0;
177 kip->nused--;
178 if (kip->nused == 0) {
179 /*
180 * Page is no longer in use. Free it unless
181 * it's the last one. We keep the last one
182 * so as not to have to set it up again the
183 * next time somebody inserts a probe.
184 */
185 hlist_del(&kip->hlist);
186 if (hlist_empty(&kprobe_insn_pages)) {
187 INIT_HLIST_NODE(&kip->hlist);
188 hlist_add_head(&kip->hlist,
189 &kprobe_insn_pages);
190 } else {
191 module_free(NULL, kip->insns);
192 kfree(kip);
193 }
194 return 1;
195 }
196 return 0;
197}
198
199static int __kprobes collect_garbage_slots(void)
200{
201 struct kprobe_insn_page *kip;
202 struct hlist_node *pos, *next;
203
204 /* Ensure no-one is preepmted on the garbages */
205 if (check_safety() != 0)
206 return -EAGAIN;
207
208 hlist_for_each_safe(pos, next, &kprobe_insn_pages) {
209 int i;
210 kip = hlist_entry(pos, struct kprobe_insn_page, hlist);
211 if (kip->ngarbage == 0)
212 continue;
213 kip->ngarbage = 0; /* we will collect all garbages */
214 for (i = 0; i < INSNS_PER_PAGE; i++) {
215 if (kip->slot_used[i] == -1 &&
216 collect_one_slot(kip, i))
217 break;
218 }
219 }
220 kprobe_garbage_slots = 0;
221 return 0;
222}
223
224void __kprobes free_insn_slot(kprobe_opcode_t * slot, int dirty)
140{ 225{
141 struct kprobe_insn_page *kip; 226 struct kprobe_insn_page *kip;
142 struct hlist_node *pos; 227 struct hlist_node *pos;
@@ -146,28 +231,18 @@ void __kprobes free_insn_slot(kprobe_opcode_t *slot)
146 if (kip->insns <= slot && 231 if (kip->insns <= slot &&
147 slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) { 232 slot < kip->insns + (INSNS_PER_PAGE * MAX_INSN_SIZE)) {
148 int i = (slot - kip->insns) / MAX_INSN_SIZE; 233 int i = (slot - kip->insns) / MAX_INSN_SIZE;
149 kip->slot_used[i] = 0; 234 if (dirty) {
150 kip->nused--; 235 kip->slot_used[i] = -1;
151 if (kip->nused == 0) { 236 kip->ngarbage++;
152 /* 237 } else {
153 * Page is no longer in use. Free it unless 238 collect_one_slot(kip, i);
154 * it's the last one. We keep the last one
155 * so as not to have to set it up again the
156 * next time somebody inserts a probe.
157 */
158 hlist_del(&kip->hlist);
159 if (hlist_empty(&kprobe_insn_pages)) {
160 INIT_HLIST_NODE(&kip->hlist);
161 hlist_add_head(&kip->hlist,
162 &kprobe_insn_pages);
163 } else {
164 module_free(NULL, kip->insns);
165 kfree(kip);
166 }
167 } 239 }
168 return; 240 break;
169 } 241 }
170 } 242 }
243 if (dirty && (++kprobe_garbage_slots > INSNS_PER_PAGE)) {
244 collect_garbage_slots();
245 }
171} 246}
172#endif 247#endif
173 248
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index c9fefdb1a7db..b02032476dc2 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -140,13 +140,6 @@ void lockdep_on(void)
140 140
141EXPORT_SYMBOL(lockdep_on); 141EXPORT_SYMBOL(lockdep_on);
142 142
143int lockdep_internal(void)
144{
145 return current->lockdep_recursion != 0;
146}
147
148EXPORT_SYMBOL(lockdep_internal);
149
150/* 143/*
151 * Debugging switches: 144 * Debugging switches:
152 */ 145 */
@@ -228,17 +221,15 @@ static int save_trace(struct stack_trace *trace)
228 trace->skip = 3; 221 trace->skip = 3;
229 trace->all_contexts = 0; 222 trace->all_contexts = 0;
230 223
231 /* Make sure to not recurse in case the the unwinder needs to tak
232e locks. */
233 lockdep_off();
234 save_stack_trace(trace, NULL); 224 save_stack_trace(trace, NULL);
235 lockdep_on();
236 225
237 trace->max_entries = trace->nr_entries; 226 trace->max_entries = trace->nr_entries;
238 227
239 nr_stack_trace_entries += trace->nr_entries; 228 nr_stack_trace_entries += trace->nr_entries;
240 if (DEBUG_LOCKS_WARN_ON(nr_stack_trace_entries > MAX_STACK_TRACE_ENTRIES)) 229 if (DEBUG_LOCKS_WARN_ON(nr_stack_trace_entries > MAX_STACK_TRACE_ENTRIES)) {
230 __raw_spin_unlock(&hash_lock);
241 return 0; 231 return 0;
232 }
242 233
243 if (nr_stack_trace_entries == MAX_STACK_TRACE_ENTRIES) { 234 if (nr_stack_trace_entries == MAX_STACK_TRACE_ENTRIES) {
244 __raw_spin_unlock(&hash_lock); 235 __raw_spin_unlock(&hash_lock);
@@ -357,7 +348,7 @@ get_usage_chars(struct lock_class *class, char *c1, char *c2, char *c3, char *c4
357 348
358static void print_lock_name(struct lock_class *class) 349static void print_lock_name(struct lock_class *class)
359{ 350{
360 char str[128], c1, c2, c3, c4; 351 char str[KSYM_NAME_LEN + 1], c1, c2, c3, c4;
361 const char *name; 352 const char *name;
362 353
363 get_usage_chars(class, &c1, &c2, &c3, &c4); 354 get_usage_chars(class, &c1, &c2, &c3, &c4);
@@ -379,7 +370,7 @@ static void print_lock_name(struct lock_class *class)
379static void print_lockdep_cache(struct lockdep_map *lock) 370static void print_lockdep_cache(struct lockdep_map *lock)
380{ 371{
381 const char *name; 372 const char *name;
382 char str[128]; 373 char str[KSYM_NAME_LEN + 1];
383 374
384 name = lock->name; 375 name = lock->name;
385 if (!name) 376 if (!name)
@@ -449,7 +440,9 @@ static void print_lock_dependencies(struct lock_class *class, int depth)
449 print_lock_class_header(class, depth); 440 print_lock_class_header(class, depth);
450 441
451 list_for_each_entry(entry, &class->locks_after, entry) { 442 list_for_each_entry(entry, &class->locks_after, entry) {
452 DEBUG_LOCKS_WARN_ON(!entry->class); 443 if (DEBUG_LOCKS_WARN_ON(!entry->class))
444 return;
445
453 print_lock_dependencies(entry->class, depth + 1); 446 print_lock_dependencies(entry->class, depth + 1);
454 447
455 printk("%*s ... acquired at:\n",depth,""); 448 printk("%*s ... acquired at:\n",depth,"");
@@ -474,7 +467,8 @@ static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
474 return 0; 467 return 0;
475 468
476 entry->class = this; 469 entry->class = this;
477 save_trace(&entry->trace); 470 if (!save_trace(&entry->trace))
471 return 0;
478 472
479 /* 473 /*
480 * Since we never remove from the dependency list, the list can 474 * Since we never remove from the dependency list, the list can
@@ -562,8 +556,12 @@ static noinline int print_circular_bug_tail(void)
562 if (debug_locks_silent) 556 if (debug_locks_silent)
563 return 0; 557 return 0;
564 558
559 /* hash_lock unlocked by the header */
560 __raw_spin_lock(&hash_lock);
565 this.class = check_source->class; 561 this.class = check_source->class;
566 save_trace(&this.trace); 562 if (!save_trace(&this.trace))
563 return 0;
564 __raw_spin_unlock(&hash_lock);
567 print_circular_bug_entry(&this, 0); 565 print_circular_bug_entry(&this, 0);
568 566
569 printk("\nother info that might help us debug this:\n\n"); 567 printk("\nother info that might help us debug this:\n\n");
@@ -966,14 +964,11 @@ check_prev_add(struct task_struct *curr, struct held_lock *prev,
966 &prev->class->locks_after, next->acquire_ip); 964 &prev->class->locks_after, next->acquire_ip);
967 if (!ret) 965 if (!ret)
968 return 0; 966 return 0;
969 /* 967
970 * Return value of 2 signals 'dependency already added',
971 * in that case we dont have to add the backlink either.
972 */
973 if (ret == 2)
974 return 2;
975 ret = add_lock_to_list(next->class, prev->class, 968 ret = add_lock_to_list(next->class, prev->class,
976 &next->class->locks_before, next->acquire_ip); 969 &next->class->locks_before, next->acquire_ip);
970 if (!ret)
971 return 0;
977 972
978 /* 973 /*
979 * Debugging printouts: 974 * Debugging printouts:
@@ -1025,7 +1020,8 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next)
1025 * added: 1020 * added:
1026 */ 1021 */
1027 if (hlock->read != 2) { 1022 if (hlock->read != 2) {
1028 check_prev_add(curr, hlock, next); 1023 if (!check_prev_add(curr, hlock, next))
1024 return 0;
1029 /* 1025 /*
1030 * Stop after the first non-trylock entry, 1026 * Stop after the first non-trylock entry,
1031 * as non-trylock entries have added their 1027 * as non-trylock entries have added their
@@ -1182,6 +1178,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1182 struct lockdep_subclass_key *key; 1178 struct lockdep_subclass_key *key;
1183 struct list_head *hash_head; 1179 struct list_head *hash_head;
1184 struct lock_class *class; 1180 struct lock_class *class;
1181 unsigned long flags;
1185 1182
1186 class = look_up_lock_class(lock, subclass); 1183 class = look_up_lock_class(lock, subclass);
1187 if (likely(class)) 1184 if (likely(class))
@@ -1203,6 +1200,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1203 key = lock->key->subkeys + subclass; 1200 key = lock->key->subkeys + subclass;
1204 hash_head = classhashentry(key); 1201 hash_head = classhashentry(key);
1205 1202
1203 raw_local_irq_save(flags);
1206 __raw_spin_lock(&hash_lock); 1204 __raw_spin_lock(&hash_lock);
1207 /* 1205 /*
1208 * We have to do the hash-walk again, to avoid races 1206 * We have to do the hash-walk again, to avoid races
@@ -1217,6 +1215,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1217 */ 1215 */
1218 if (nr_lock_classes >= MAX_LOCKDEP_KEYS) { 1216 if (nr_lock_classes >= MAX_LOCKDEP_KEYS) {
1219 __raw_spin_unlock(&hash_lock); 1217 __raw_spin_unlock(&hash_lock);
1218 raw_local_irq_restore(flags);
1220 debug_locks_off(); 1219 debug_locks_off();
1221 printk("BUG: MAX_LOCKDEP_KEYS too low!\n"); 1220 printk("BUG: MAX_LOCKDEP_KEYS too low!\n");
1222 printk("turning off the locking correctness validator.\n"); 1221 printk("turning off the locking correctness validator.\n");
@@ -1239,15 +1238,18 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
1239 1238
1240 if (verbose(class)) { 1239 if (verbose(class)) {
1241 __raw_spin_unlock(&hash_lock); 1240 __raw_spin_unlock(&hash_lock);
1241 raw_local_irq_restore(flags);
1242 printk("\nnew class %p: %s", class->key, class->name); 1242 printk("\nnew class %p: %s", class->key, class->name);
1243 if (class->name_version > 1) 1243 if (class->name_version > 1)
1244 printk("#%d", class->name_version); 1244 printk("#%d", class->name_version);
1245 printk("\n"); 1245 printk("\n");
1246 dump_stack(); 1246 dump_stack();
1247 raw_local_irq_save(flags);
1247 __raw_spin_lock(&hash_lock); 1248 __raw_spin_lock(&hash_lock);
1248 } 1249 }
1249out_unlock_set: 1250out_unlock_set:
1250 __raw_spin_unlock(&hash_lock); 1251 __raw_spin_unlock(&hash_lock);
1252 raw_local_irq_restore(flags);
1251 1253
1252 if (!subclass || force) 1254 if (!subclass || force)
1253 lock->class_cache = class; 1255 lock->class_cache = class;
@@ -1728,6 +1730,7 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
1728 debug_atomic_dec(&nr_unused_locks); 1730 debug_atomic_dec(&nr_unused_locks);
1729 break; 1731 break;
1730 default: 1732 default:
1733 __raw_spin_unlock(&hash_lock);
1731 debug_locks_off(); 1734 debug_locks_off();
1732 WARN_ON(1); 1735 WARN_ON(1);
1733 return 0; 1736 return 0;
@@ -2645,6 +2648,7 @@ void debug_check_no_locks_freed(const void *mem_from, unsigned long mem_len)
2645 } 2648 }
2646 local_irq_restore(flags); 2649 local_irq_restore(flags);
2647} 2650}
2651EXPORT_SYMBOL_GPL(debug_check_no_locks_freed);
2648 2652
2649static void print_held_locks_bug(struct task_struct *curr) 2653static void print_held_locks_bug(struct task_struct *curr)
2650{ 2654{
diff --git a/kernel/lockdep_internals.h b/kernel/lockdep_internals.h
index eab043c83bb2..8ce09bc4613d 100644
--- a/kernel/lockdep_internals.h
+++ b/kernel/lockdep_internals.h
@@ -20,7 +20,7 @@
20#define MAX_LOCKDEP_KEYS_BITS 11 20#define MAX_LOCKDEP_KEYS_BITS 11
21#define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS) 21#define MAX_LOCKDEP_KEYS (1UL << MAX_LOCKDEP_KEYS_BITS)
22 22
23#define MAX_LOCKDEP_CHAINS_BITS 13 23#define MAX_LOCKDEP_CHAINS_BITS 14
24#define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS) 24#define MAX_LOCKDEP_CHAINS (1UL << MAX_LOCKDEP_CHAINS_BITS)
25 25
26/* 26/*
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index f6e72eaab3fa..b554b40a4aa6 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -113,7 +113,7 @@ static int l_show(struct seq_file *m, void *v)
113 return 0; 113 return 0;
114} 114}
115 115
116static struct seq_operations lockdep_ops = { 116static const struct seq_operations lockdep_ops = {
117 .start = l_start, 117 .start = l_start,
118 .next = l_next, 118 .next = l_next,
119 .stop = l_stop, 119 .stop = l_stop,
@@ -135,7 +135,7 @@ static int lockdep_open(struct inode *inode, struct file *file)
135 return res; 135 return res;
136} 136}
137 137
138static struct file_operations proc_lockdep_operations = { 138static const struct file_operations proc_lockdep_operations = {
139 .open = lockdep_open, 139 .open = lockdep_open,
140 .read = seq_read, 140 .read = seq_read,
141 .llseek = seq_lseek, 141 .llseek = seq_lseek,
@@ -319,7 +319,7 @@ static int lockdep_stats_open(struct inode *inode, struct file *file)
319 return single_open(file, lockdep_stats_show, NULL); 319 return single_open(file, lockdep_stats_show, NULL);
320} 320}
321 321
322static struct file_operations proc_lockdep_stats_operations = { 322static const struct file_operations proc_lockdep_stats_operations = {
323 .open = lockdep_stats_open, 323 .open = lockdep_stats_open,
324 .read = seq_read, 324 .read = seq_read,
325 .llseek = seq_lseek, 325 .llseek = seq_lseek,
diff --git a/kernel/module.c b/kernel/module.c
index e2d09d604ca0..d9eae45d0145 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2209,7 +2209,7 @@ static int m_show(struct seq_file *m, void *p)
2209 Where refcount is a number or -, and deps is a comma-separated list 2209 Where refcount is a number or -, and deps is a comma-separated list
2210 of depends or -. 2210 of depends or -.
2211*/ 2211*/
2212struct seq_operations modules_op = { 2212const struct seq_operations modules_op = {
2213 .start = m_start, 2213 .start = m_start,
2214 .next = m_next, 2214 .next = m_next,
2215 .stop = m_stop, 2215 .stop = m_stop,
diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
index 18651641a7b5..841539d72c55 100644
--- a/kernel/mutex-debug.c
+++ b/kernel/mutex-debug.c
@@ -77,6 +77,9 @@ void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77 77
78void debug_mutex_unlock(struct mutex *lock) 78void debug_mutex_unlock(struct mutex *lock)
79{ 79{
80 if (unlikely(!debug_locks))
81 return;
82
80 DEBUG_LOCKS_WARN_ON(lock->owner != current_thread_info()); 83 DEBUG_LOCKS_WARN_ON(lock->owner != current_thread_info());
81 DEBUG_LOCKS_WARN_ON(lock->magic != lock); 84 DEBUG_LOCKS_WARN_ON(lock->magic != lock);
82 DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next); 85 DEBUG_LOCKS_WARN_ON(!lock->wait_list.prev && !lock->wait_list.next);
diff --git a/kernel/pid.c b/kernel/pid.c
index b914392085f9..a48879b0b921 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -31,7 +31,7 @@
31#define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift) 31#define pid_hashfn(nr) hash_long((unsigned long)nr, pidhash_shift)
32static struct hlist_head *pid_hash; 32static struct hlist_head *pid_hash;
33static int pidhash_shift; 33static int pidhash_shift;
34static kmem_cache_t *pid_cachep; 34static struct kmem_cache *pid_cachep;
35 35
36int pid_max = PID_MAX_DEFAULT; 36int pid_max = PID_MAX_DEFAULT;
37 37
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 9cbb5d1be06f..5fe87de10ff0 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -70,7 +70,7 @@
70/* 70/*
71 * Lets keep our timers in a slab cache :-) 71 * Lets keep our timers in a slab cache :-)
72 */ 72 */
73static kmem_cache_t *posix_timers_cache; 73static struct kmem_cache *posix_timers_cache;
74static struct idr posix_timers_id; 74static struct idr posix_timers_id;
75static DEFINE_SPINLOCK(idr_lock); 75static DEFINE_SPINLOCK(idr_lock);
76 76
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 825068ca3479..710ed084e7c5 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -78,7 +78,7 @@ config PM_SYSFS_DEPRECATED
78 78
79config SOFTWARE_SUSPEND 79config SOFTWARE_SUSPEND
80 bool "Software Suspend" 80 bool "Software Suspend"
81 depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP) && !X86_PAE) || ((FRV || PPC32) && !SMP)) 81 depends on PM && SWAP && ((X86 && (!SMP || SUSPEND_SMP)) || ((FRV || PPC32) && !SMP))
82 ---help--- 82 ---help---
83 Enable the possibility of suspending the machine. 83 Enable the possibility of suspending the machine.
84 It doesn't need ACPI or APM. 84 It doesn't need ACPI or APM.
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index b1fb7866b0b3..0b00f56c2ad0 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -20,6 +20,7 @@
20#include <linux/pm.h> 20#include <linux/pm.h>
21#include <linux/console.h> 21#include <linux/console.h>
22#include <linux/cpu.h> 22#include <linux/cpu.h>
23#include <linux/freezer.h>
23 24
24#include "power.h" 25#include "power.h"
25 26
@@ -27,6 +28,23 @@
27static int noresume = 0; 28static int noresume = 0;
28char resume_file[256] = CONFIG_PM_STD_PARTITION; 29char resume_file[256] = CONFIG_PM_STD_PARTITION;
29dev_t swsusp_resume_device; 30dev_t swsusp_resume_device;
31sector_t swsusp_resume_block;
32
33/**
34 * platform_prepare - prepare the machine for hibernation using the
35 * platform driver if so configured and return an error code if it fails
36 */
37
38static inline int platform_prepare(void)
39{
40 int error = 0;
41
42 if (pm_disk_mode == PM_DISK_PLATFORM) {
43 if (pm_ops && pm_ops->prepare)
44 error = pm_ops->prepare(PM_SUSPEND_DISK);
45 }
46 return error;
47}
30 48
31/** 49/**
32 * power_down - Shut machine down for hibernate. 50 * power_down - Shut machine down for hibernate.
@@ -40,12 +58,10 @@ dev_t swsusp_resume_device;
40 58
41static void power_down(suspend_disk_method_t mode) 59static void power_down(suspend_disk_method_t mode)
42{ 60{
43 int error = 0;
44
45 switch(mode) { 61 switch(mode) {
46 case PM_DISK_PLATFORM: 62 case PM_DISK_PLATFORM:
47 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK); 63 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
48 error = pm_ops->enter(PM_SUSPEND_DISK); 64 pm_ops->enter(PM_SUSPEND_DISK);
49 break; 65 break;
50 case PM_DISK_SHUTDOWN: 66 case PM_DISK_SHUTDOWN:
51 kernel_power_off(); 67 kernel_power_off();
@@ -90,12 +106,18 @@ static int prepare_processes(void)
90 goto thaw; 106 goto thaw;
91 } 107 }
92 108
109 error = platform_prepare();
110 if (error)
111 goto thaw;
112
93 /* Free memory before shutting down devices. */ 113 /* Free memory before shutting down devices. */
94 if (!(error = swsusp_shrink_memory())) 114 if (!(error = swsusp_shrink_memory()))
95 return 0; 115 return 0;
96thaw: 116
117 platform_finish();
118 thaw:
97 thaw_processes(); 119 thaw_processes();
98enable_cpus: 120 enable_cpus:
99 enable_nonboot_cpus(); 121 enable_nonboot_cpus();
100 pm_restore_console(); 122 pm_restore_console();
101 return error; 123 return error;
@@ -127,7 +149,7 @@ int pm_suspend_disk(void)
127 return error; 149 return error;
128 150
129 if (pm_disk_mode == PM_DISK_TESTPROC) 151 if (pm_disk_mode == PM_DISK_TESTPROC)
130 goto Thaw; 152 return 0;
131 153
132 suspend_console(); 154 suspend_console();
133 error = device_suspend(PMSG_FREEZE); 155 error = device_suspend(PMSG_FREEZE);
@@ -189,10 +211,10 @@ static int software_resume(void)
189{ 211{
190 int error; 212 int error;
191 213
192 down(&pm_sem); 214 mutex_lock(&pm_mutex);
193 if (!swsusp_resume_device) { 215 if (!swsusp_resume_device) {
194 if (!strlen(resume_file)) { 216 if (!strlen(resume_file)) {
195 up(&pm_sem); 217 mutex_unlock(&pm_mutex);
196 return -ENOENT; 218 return -ENOENT;
197 } 219 }
198 swsusp_resume_device = name_to_dev_t(resume_file); 220 swsusp_resume_device = name_to_dev_t(resume_file);
@@ -207,7 +229,7 @@ static int software_resume(void)
207 * FIXME: If noresume is specified, we need to find the partition 229 * FIXME: If noresume is specified, we need to find the partition
208 * and reset it back to normal swap space. 230 * and reset it back to normal swap space.
209 */ 231 */
210 up(&pm_sem); 232 mutex_unlock(&pm_mutex);
211 return 0; 233 return 0;
212 } 234 }
213 235
@@ -251,7 +273,7 @@ static int software_resume(void)
251 unprepare_processes(); 273 unprepare_processes();
252 Done: 274 Done:
253 /* For success case, the suspend path will release the lock */ 275 /* For success case, the suspend path will release the lock */
254 up(&pm_sem); 276 mutex_unlock(&pm_mutex);
255 pr_debug("PM: Resume from disk failed.\n"); 277 pr_debug("PM: Resume from disk failed.\n");
256 return 0; 278 return 0;
257} 279}
@@ -312,7 +334,7 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
312 p = memchr(buf, '\n', n); 334 p = memchr(buf, '\n', n);
313 len = p ? p - buf : n; 335 len = p ? p - buf : n;
314 336
315 down(&pm_sem); 337 mutex_lock(&pm_mutex);
316 for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) { 338 for (i = PM_DISK_FIRMWARE; i < PM_DISK_MAX; i++) {
317 if (!strncmp(buf, pm_disk_modes[i], len)) { 339 if (!strncmp(buf, pm_disk_modes[i], len)) {
318 mode = i; 340 mode = i;
@@ -336,7 +358,7 @@ static ssize_t disk_store(struct subsystem * s, const char * buf, size_t n)
336 358
337 pr_debug("PM: suspend-to-disk mode set to '%s'\n", 359 pr_debug("PM: suspend-to-disk mode set to '%s'\n",
338 pm_disk_modes[mode]); 360 pm_disk_modes[mode]);
339 up(&pm_sem); 361 mutex_unlock(&pm_mutex);
340 return error ? error : n; 362 return error ? error : n;
341} 363}
342 364
@@ -361,14 +383,14 @@ static ssize_t resume_store(struct subsystem *subsys, const char *buf, size_t n)
361 if (maj != MAJOR(res) || min != MINOR(res)) 383 if (maj != MAJOR(res) || min != MINOR(res))
362 goto out; 384 goto out;
363 385
364 down(&pm_sem); 386 mutex_lock(&pm_mutex);
365 swsusp_resume_device = res; 387 swsusp_resume_device = res;
366 up(&pm_sem); 388 mutex_unlock(&pm_mutex);
367 printk("Attempting manual resume\n"); 389 printk("Attempting manual resume\n");
368 noresume = 0; 390 noresume = 0;
369 software_resume(); 391 software_resume();
370 ret = n; 392 ret = n;
371out: 393 out:
372 return ret; 394 return ret;
373} 395}
374 396
@@ -423,6 +445,19 @@ static int __init resume_setup(char *str)
423 return 1; 445 return 1;
424} 446}
425 447
448static int __init resume_offset_setup(char *str)
449{
450 unsigned long long offset;
451
452 if (noresume)
453 return 1;
454
455 if (sscanf(str, "%llu", &offset) == 1)
456 swsusp_resume_block = offset;
457
458 return 1;
459}
460
426static int __init noresume_setup(char *str) 461static int __init noresume_setup(char *str)
427{ 462{
428 noresume = 1; 463 noresume = 1;
@@ -430,4 +465,5 @@ static int __init noresume_setup(char *str)
430} 465}
431 466
432__setup("noresume", noresume_setup); 467__setup("noresume", noresume_setup);
468__setup("resume_offset=", resume_offset_setup);
433__setup("resume=", resume_setup); 469__setup("resume=", resume_setup);
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 873228c71dab..500eb87f643d 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -8,6 +8,7 @@
8 * 8 *
9 */ 9 */
10 10
11#include <linux/module.h>
11#include <linux/suspend.h> 12#include <linux/suspend.h>
12#include <linux/kobject.h> 13#include <linux/kobject.h>
13#include <linux/string.h> 14#include <linux/string.h>
@@ -18,13 +19,14 @@
18#include <linux/console.h> 19#include <linux/console.h>
19#include <linux/cpu.h> 20#include <linux/cpu.h>
20#include <linux/resume-trace.h> 21#include <linux/resume-trace.h>
22#include <linux/freezer.h>
21 23
22#include "power.h" 24#include "power.h"
23 25
24/*This is just an arbitrary number */ 26/*This is just an arbitrary number */
25#define FREE_PAGE_NUMBER (100) 27#define FREE_PAGE_NUMBER (100)
26 28
27DECLARE_MUTEX(pm_sem); 29DEFINE_MUTEX(pm_mutex);
28 30
29struct pm_ops *pm_ops; 31struct pm_ops *pm_ops;
30suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN; 32suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
@@ -36,9 +38,9 @@ suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;
36 38
37void pm_set_ops(struct pm_ops * ops) 39void pm_set_ops(struct pm_ops * ops)
38{ 40{
39 down(&pm_sem); 41 mutex_lock(&pm_mutex);
40 pm_ops = ops; 42 pm_ops = ops;
41 up(&pm_sem); 43 mutex_unlock(&pm_mutex);
42} 44}
43 45
44 46
@@ -182,7 +184,7 @@ static int enter_state(suspend_state_t state)
182 184
183 if (!valid_state(state)) 185 if (!valid_state(state))
184 return -ENODEV; 186 return -ENODEV;
185 if (down_trylock(&pm_sem)) 187 if (!mutex_trylock(&pm_mutex))
186 return -EBUSY; 188 return -EBUSY;
187 189
188 if (state == PM_SUSPEND_DISK) { 190 if (state == PM_SUSPEND_DISK) {
@@ -200,7 +202,7 @@ static int enter_state(suspend_state_t state)
200 pr_debug("PM: Finishing wakeup.\n"); 202 pr_debug("PM: Finishing wakeup.\n");
201 suspend_finish(state); 203 suspend_finish(state);
202 Unlock: 204 Unlock:
203 up(&pm_sem); 205 mutex_unlock(&pm_mutex);
204 return error; 206 return error;
205} 207}
206 208
@@ -229,7 +231,7 @@ int pm_suspend(suspend_state_t state)
229 return -EINVAL; 231 return -EINVAL;
230} 232}
231 233
232 234EXPORT_SYMBOL(pm_suspend);
233 235
234decl_subsys(power,NULL,NULL); 236decl_subsys(power,NULL,NULL);
235 237
diff --git a/kernel/power/power.h b/kernel/power/power.h
index bfe999f7b272..eb461b816bf4 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -22,7 +22,9 @@ static inline int pm_suspend_disk(void)
22 return -EPERM; 22 return -EPERM;
23} 23}
24#endif 24#endif
25extern struct semaphore pm_sem; 25
26extern struct mutex pm_mutex;
27
26#define power_attr(_name) \ 28#define power_attr(_name) \
27static struct subsys_attribute _name##_attr = { \ 29static struct subsys_attribute _name##_attr = { \
28 .attr = { \ 30 .attr = { \
@@ -42,6 +44,7 @@ extern const void __nosave_begin, __nosave_end;
42extern unsigned long image_size; 44extern unsigned long image_size;
43extern int in_suspend; 45extern int in_suspend;
44extern dev_t swsusp_resume_device; 46extern dev_t swsusp_resume_device;
47extern sector_t swsusp_resume_block;
45 48
46extern asmlinkage int swsusp_arch_suspend(void); 49extern asmlinkage int swsusp_arch_suspend(void);
47extern asmlinkage int swsusp_arch_resume(void); 50extern asmlinkage int swsusp_arch_resume(void);
@@ -102,8 +105,18 @@ struct snapshot_handle {
102extern unsigned int snapshot_additional_pages(struct zone *zone); 105extern unsigned int snapshot_additional_pages(struct zone *zone);
103extern int snapshot_read_next(struct snapshot_handle *handle, size_t count); 106extern int snapshot_read_next(struct snapshot_handle *handle, size_t count);
104extern int snapshot_write_next(struct snapshot_handle *handle, size_t count); 107extern int snapshot_write_next(struct snapshot_handle *handle, size_t count);
108extern void snapshot_write_finalize(struct snapshot_handle *handle);
105extern int snapshot_image_loaded(struct snapshot_handle *handle); 109extern int snapshot_image_loaded(struct snapshot_handle *handle);
106extern void snapshot_free_unused_memory(struct snapshot_handle *handle); 110
111/*
112 * This structure is used to pass the values needed for the identification
113 * of the resume swap area from a user space to the kernel via the
114 * SNAPSHOT_SET_SWAP_AREA ioctl
115 */
116struct resume_swap_area {
117 loff_t offset;
118 u_int32_t dev;
119} __attribute__((packed));
107 120
108#define SNAPSHOT_IOC_MAGIC '3' 121#define SNAPSHOT_IOC_MAGIC '3'
109#define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1) 122#define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1)
@@ -117,7 +130,14 @@ extern void snapshot_free_unused_memory(struct snapshot_handle *handle);
117#define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9) 130#define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9)
118#define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int) 131#define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int)
119#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11) 132#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11)
120#define SNAPSHOT_IOC_MAXNR 11 133#define SNAPSHOT_PMOPS _IOW(SNAPSHOT_IOC_MAGIC, 12, unsigned int)
134#define SNAPSHOT_SET_SWAP_AREA _IOW(SNAPSHOT_IOC_MAGIC, 13, \
135 struct resume_swap_area)
136#define SNAPSHOT_IOC_MAXNR 13
137
138#define PMOPS_PREPARE 1
139#define PMOPS_ENTER 2
140#define PMOPS_FINISH 3
121 141
122/** 142/**
123 * The bitmap is used for tracing allocated swap pages 143 * The bitmap is used for tracing allocated swap pages
@@ -141,7 +161,7 @@ struct bitmap_page {
141 161
142extern void free_bitmap(struct bitmap_page *bitmap); 162extern void free_bitmap(struct bitmap_page *bitmap);
143extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits); 163extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits);
144extern unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap); 164extern sector_t alloc_swapdev_block(int swap, struct bitmap_page *bitmap);
145extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap); 165extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap);
146 166
147extern int swsusp_check(void); 167extern int swsusp_check(void);
@@ -153,3 +173,7 @@ extern int swsusp_read(void);
153extern int swsusp_write(void); 173extern int swsusp_write(void);
154extern void swsusp_close(void); 174extern void swsusp_close(void);
155extern int suspend_enter(suspend_state_t state); 175extern int suspend_enter(suspend_state_t state);
176
177struct timeval;
178extern void swsusp_show_speed(struct timeval *, struct timeval *,
179 unsigned int, char *);
diff --git a/kernel/power/process.c b/kernel/power/process.c
index 72e72d2c61e6..99eeb119b06d 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -13,12 +13,15 @@
13#include <linux/suspend.h> 13#include <linux/suspend.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/syscalls.h> 15#include <linux/syscalls.h>
16#include <linux/freezer.h>
16 17
17/* 18/*
18 * Timeout for stopping processes 19 * Timeout for stopping processes
19 */ 20 */
20#define TIMEOUT (20 * HZ) 21#define TIMEOUT (20 * HZ)
21 22
23#define FREEZER_KERNEL_THREADS 0
24#define FREEZER_USER_SPACE 1
22 25
23static inline int freezeable(struct task_struct * p) 26static inline int freezeable(struct task_struct * p)
24{ 27{
@@ -39,7 +42,6 @@ void refrigerator(void)
39 long save; 42 long save;
40 save = current->state; 43 save = current->state;
41 pr_debug("%s entered refrigerator\n", current->comm); 44 pr_debug("%s entered refrigerator\n", current->comm);
42 printk("=");
43 45
44 frozen_process(current); 46 frozen_process(current);
45 spin_lock_irq(&current->sighand->siglock); 47 spin_lock_irq(&current->sighand->siglock);
@@ -79,96 +81,136 @@ static void cancel_freezing(struct task_struct *p)
79 } 81 }
80} 82}
81 83
82/* 0 = success, else # of processes that we failed to stop */ 84static inline int is_user_space(struct task_struct *p)
83int freeze_processes(void) 85{
86 return p->mm && !(p->flags & PF_BORROWED_MM);
87}
88
89static unsigned int try_to_freeze_tasks(int freeze_user_space)
84{ 90{
85 int todo, nr_user, user_frozen;
86 unsigned long start_time;
87 struct task_struct *g, *p; 91 struct task_struct *g, *p;
92 unsigned long end_time;
93 unsigned int todo;
88 94
89 printk( "Stopping tasks: " ); 95 end_time = jiffies + TIMEOUT;
90 start_time = jiffies;
91 user_frozen = 0;
92 do { 96 do {
93 nr_user = todo = 0; 97 todo = 0;
94 read_lock(&tasklist_lock); 98 read_lock(&tasklist_lock);
95 do_each_thread(g, p) { 99 do_each_thread(g, p) {
96 if (!freezeable(p)) 100 if (!freezeable(p))
97 continue; 101 continue;
102
98 if (frozen(p)) 103 if (frozen(p))
99 continue; 104 continue;
100 if (p->state == TASK_TRACED && frozen(p->parent)) { 105
106 if (p->state == TASK_TRACED &&
107 (frozen(p->parent) ||
108 p->parent->state == TASK_STOPPED)) {
101 cancel_freezing(p); 109 cancel_freezing(p);
102 continue; 110 continue;
103 } 111 }
104 if (p->mm && !(p->flags & PF_BORROWED_MM)) { 112 if (is_user_space(p)) {
105 /* The task is a user-space one. 113 if (!freeze_user_space)
106 * Freeze it unless there's a vfork completion 114 continue;
107 * pending 115
116 /* Freeze the task unless there is a vfork
117 * completion pending
108 */ 118 */
109 if (!p->vfork_done) 119 if (!p->vfork_done)
110 freeze_process(p); 120 freeze_process(p);
111 nr_user++;
112 } else { 121 } else {
113 /* Freeze only if the user space is frozen */ 122 if (freeze_user_space)
114 if (user_frozen) 123 continue;
115 freeze_process(p); 124
116 todo++; 125 freeze_process(p);
117 } 126 }
127 todo++;
118 } while_each_thread(g, p); 128 } while_each_thread(g, p);
119 read_unlock(&tasklist_lock); 129 read_unlock(&tasklist_lock);
120 todo += nr_user;
121 if (!user_frozen && !nr_user) {
122 sys_sync();
123 start_time = jiffies;
124 }
125 user_frozen = !nr_user;
126 yield(); /* Yield is okay here */ 130 yield(); /* Yield is okay here */
127 if (todo && time_after(jiffies, start_time + TIMEOUT)) 131 if (todo && time_after(jiffies, end_time))
128 break; 132 break;
129 } while(todo); 133 } while (todo);
130 134
131 /* This does not unfreeze processes that are already frozen
132 * (we have slightly ugly calling convention in that respect,
133 * and caller must call thaw_processes() if something fails),
134 * but it cleans up leftover PF_FREEZE requests.
135 */
136 if (todo) { 135 if (todo) {
137 printk( "\n" ); 136 /* This does not unfreeze processes that are already frozen
138 printk(KERN_ERR " stopping tasks timed out " 137 * (we have slightly ugly calling convention in that respect,
139 "after %d seconds (%d tasks remaining):\n", 138 * and caller must call thaw_processes() if something fails),
140 TIMEOUT / HZ, todo); 139 * but it cleans up leftover PF_FREEZE requests.
140 */
141 printk("\n");
142 printk(KERN_ERR "Stopping %s timed out after %d seconds "
143 "(%d tasks refusing to freeze):\n",
144 freeze_user_space ? "user space processes" :
145 "kernel threads",
146 TIMEOUT / HZ, todo);
141 read_lock(&tasklist_lock); 147 read_lock(&tasklist_lock);
142 do_each_thread(g, p) { 148 do_each_thread(g, p) {
149 if (is_user_space(p) == !freeze_user_space)
150 continue;
151
143 if (freezeable(p) && !frozen(p)) 152 if (freezeable(p) && !frozen(p))
144 printk(KERN_ERR " %s\n", p->comm); 153 printk(KERN_ERR " %s\n", p->comm);
154
145 cancel_freezing(p); 155 cancel_freezing(p);
146 } while_each_thread(g, p); 156 } while_each_thread(g, p);
147 read_unlock(&tasklist_lock); 157 read_unlock(&tasklist_lock);
148 return todo;
149 } 158 }
150 159
151 printk( "|\n" ); 160 return todo;
161}
162
163/**
164 * freeze_processes - tell processes to enter the refrigerator
165 *
166 * Returns 0 on success, or the number of processes that didn't freeze,
167 * although they were told to.
168 */
169int freeze_processes(void)
170{
171 unsigned int nr_unfrozen;
172
173 printk("Stopping tasks ... ");
174 nr_unfrozen = try_to_freeze_tasks(FREEZER_USER_SPACE);
175 if (nr_unfrozen)
176 return nr_unfrozen;
177
178 sys_sync();
179 nr_unfrozen = try_to_freeze_tasks(FREEZER_KERNEL_THREADS);
180 if (nr_unfrozen)
181 return nr_unfrozen;
182
183 printk("done.\n");
152 BUG_ON(in_atomic()); 184 BUG_ON(in_atomic());
153 return 0; 185 return 0;
154} 186}
155 187
156void thaw_processes(void) 188static void thaw_tasks(int thaw_user_space)
157{ 189{
158 struct task_struct *g, *p; 190 struct task_struct *g, *p;
159 191
160 printk( "Restarting tasks..." );
161 read_lock(&tasklist_lock); 192 read_lock(&tasklist_lock);
162 do_each_thread(g, p) { 193 do_each_thread(g, p) {
163 if (!freezeable(p)) 194 if (!freezeable(p))
164 continue; 195 continue;
196
197 if (is_user_space(p) == !thaw_user_space)
198 continue;
199
165 if (!thaw_process(p)) 200 if (!thaw_process(p))
166 printk(KERN_INFO " Strange, %s not stopped\n", p->comm ); 201 printk(KERN_WARNING " Strange, %s not stopped\n",
202 p->comm );
167 } while_each_thread(g, p); 203 } while_each_thread(g, p);
168
169 read_unlock(&tasklist_lock); 204 read_unlock(&tasklist_lock);
205}
206
207void thaw_processes(void)
208{
209 printk("Restarting tasks ... ");
210 thaw_tasks(FREEZER_KERNEL_THREADS);
211 thaw_tasks(FREEZER_USER_SPACE);
170 schedule(); 212 schedule();
171 printk( " done\n" ); 213 printk("done.\n");
172} 214}
173 215
174EXPORT_SYMBOL(refrigerator); 216EXPORT_SYMBOL(refrigerator);
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 99f9b7d177d6..c024606221c4 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -1,15 +1,15 @@
1/* 1/*
2 * linux/kernel/power/snapshot.c 2 * linux/kernel/power/snapshot.c
3 * 3 *
4 * This file provide system snapshot/restore functionality. 4 * This file provides system snapshot/restore functionality for swsusp.
5 * 5 *
6 * Copyright (C) 1998-2005 Pavel Machek <pavel@suse.cz> 6 * Copyright (C) 1998-2005 Pavel Machek <pavel@suse.cz>
7 * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
7 * 8 *
8 * This file is released under the GPLv2, and is based on swsusp.c. 9 * This file is released under the GPLv2.
9 * 10 *
10 */ 11 */
11 12
12
13#include <linux/version.h> 13#include <linux/version.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
@@ -34,137 +34,24 @@
34 34
35#include "power.h" 35#include "power.h"
36 36
37/* List of PBEs used for creating and restoring the suspend image */ 37/* List of PBEs needed for restoring the pages that were allocated before
38 * the suspend and included in the suspend image, but have also been
39 * allocated by the "resume" kernel, so their contents cannot be written
40 * directly to their "original" page frames.
41 */
38struct pbe *restore_pblist; 42struct pbe *restore_pblist;
39 43
40static unsigned int nr_copy_pages; 44/* Pointer to an auxiliary buffer (1 page) */
41static unsigned int nr_meta_pages;
42static void *buffer; 45static void *buffer;
43 46
44#ifdef CONFIG_HIGHMEM
45unsigned int count_highmem_pages(void)
46{
47 struct zone *zone;
48 unsigned long zone_pfn;
49 unsigned int n = 0;
50
51 for_each_zone (zone)
52 if (is_highmem(zone)) {
53 mark_free_pages(zone);
54 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; zone_pfn++) {
55 struct page *page;
56 unsigned long pfn = zone_pfn + zone->zone_start_pfn;
57 if (!pfn_valid(pfn))
58 continue;
59 page = pfn_to_page(pfn);
60 if (PageReserved(page))
61 continue;
62 if (PageNosaveFree(page))
63 continue;
64 n++;
65 }
66 }
67 return n;
68}
69
70struct highmem_page {
71 char *data;
72 struct page *page;
73 struct highmem_page *next;
74};
75
76static struct highmem_page *highmem_copy;
77
78static int save_highmem_zone(struct zone *zone)
79{
80 unsigned long zone_pfn;
81 mark_free_pages(zone);
82 for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn) {
83 struct page *page;
84 struct highmem_page *save;
85 void *kaddr;
86 unsigned long pfn = zone_pfn + zone->zone_start_pfn;
87
88 if (!(pfn%10000))
89 printk(".");
90 if (!pfn_valid(pfn))
91 continue;
92 page = pfn_to_page(pfn);
93 /*
94 * This condition results from rvmalloc() sans vmalloc_32()
95 * and architectural memory reservations. This should be
96 * corrected eventually when the cases giving rise to this
97 * are better understood.
98 */
99 if (PageReserved(page))
100 continue;
101 BUG_ON(PageNosave(page));
102 if (PageNosaveFree(page))
103 continue;
104 save = kmalloc(sizeof(struct highmem_page), GFP_ATOMIC);
105 if (!save)
106 return -ENOMEM;
107 save->next = highmem_copy;
108 save->page = page;
109 save->data = (void *) get_zeroed_page(GFP_ATOMIC);
110 if (!save->data) {
111 kfree(save);
112 return -ENOMEM;
113 }
114 kaddr = kmap_atomic(page, KM_USER0);
115 memcpy(save->data, kaddr, PAGE_SIZE);
116 kunmap_atomic(kaddr, KM_USER0);
117 highmem_copy = save;
118 }
119 return 0;
120}
121
122int save_highmem(void)
123{
124 struct zone *zone;
125 int res = 0;
126
127 pr_debug("swsusp: Saving Highmem");
128 drain_local_pages();
129 for_each_zone (zone) {
130 if (is_highmem(zone))
131 res = save_highmem_zone(zone);
132 if (res)
133 return res;
134 }
135 printk("\n");
136 return 0;
137}
138
139int restore_highmem(void)
140{
141 printk("swsusp: Restoring Highmem\n");
142 while (highmem_copy) {
143 struct highmem_page *save = highmem_copy;
144 void *kaddr;
145 highmem_copy = save->next;
146
147 kaddr = kmap_atomic(save->page, KM_USER0);
148 memcpy(kaddr, save->data, PAGE_SIZE);
149 kunmap_atomic(kaddr, KM_USER0);
150 free_page((long) save->data);
151 kfree(save);
152 }
153 return 0;
154}
155#else
156static inline unsigned int count_highmem_pages(void) {return 0;}
157static inline int save_highmem(void) {return 0;}
158static inline int restore_highmem(void) {return 0;}
159#endif
160
161/** 47/**
162 * @safe_needed - on resume, for storing the PBE list and the image, 48 * @safe_needed - on resume, for storing the PBE list and the image,
163 * we can only use memory pages that do not conflict with the pages 49 * we can only use memory pages that do not conflict with the pages
164 * used before suspend. 50 * used before suspend. The unsafe pages have PageNosaveFree set
51 * and we count them using unsafe_pages.
165 * 52 *
166 * The unsafe pages are marked with the PG_nosave_free flag 53 * Each allocated image page is marked as PageNosave and PageNosaveFree
167 * and we count them using unsafe_pages 54 * so that swsusp_free() can release it.
168 */ 55 */
169 56
170#define PG_ANY 0 57#define PG_ANY 0
@@ -174,7 +61,7 @@ static inline int restore_highmem(void) {return 0;}
174 61
175static unsigned int allocated_unsafe_pages; 62static unsigned int allocated_unsafe_pages;
176 63
177static void *alloc_image_page(gfp_t gfp_mask, int safe_needed) 64static void *get_image_page(gfp_t gfp_mask, int safe_needed)
178{ 65{
179 void *res; 66 void *res;
180 67
@@ -195,20 +82,39 @@ static void *alloc_image_page(gfp_t gfp_mask, int safe_needed)
195 82
196unsigned long get_safe_page(gfp_t gfp_mask) 83unsigned long get_safe_page(gfp_t gfp_mask)
197{ 84{
198 return (unsigned long)alloc_image_page(gfp_mask, PG_SAFE); 85 return (unsigned long)get_image_page(gfp_mask, PG_SAFE);
86}
87
88static struct page *alloc_image_page(gfp_t gfp_mask)
89{
90 struct page *page;
91
92 page = alloc_page(gfp_mask);
93 if (page) {
94 SetPageNosave(page);
95 SetPageNosaveFree(page);
96 }
97 return page;
199} 98}
200 99
201/** 100/**
202 * free_image_page - free page represented by @addr, allocated with 101 * free_image_page - free page represented by @addr, allocated with
203 * alloc_image_page (page flags set by it must be cleared) 102 * get_image_page (page flags set by it must be cleared)
204 */ 103 */
205 104
206static inline void free_image_page(void *addr, int clear_nosave_free) 105static inline void free_image_page(void *addr, int clear_nosave_free)
207{ 106{
208 ClearPageNosave(virt_to_page(addr)); 107 struct page *page;
108
109 BUG_ON(!virt_addr_valid(addr));
110
111 page = virt_to_page(addr);
112
113 ClearPageNosave(page);
209 if (clear_nosave_free) 114 if (clear_nosave_free)
210 ClearPageNosaveFree(virt_to_page(addr)); 115 ClearPageNosaveFree(page);
211 free_page((unsigned long)addr); 116
117 __free_page(page);
212} 118}
213 119
214/* struct linked_page is used to build chains of pages */ 120/* struct linked_page is used to build chains of pages */
@@ -269,7 +175,7 @@ static void *chain_alloc(struct chain_allocator *ca, unsigned int size)
269 if (LINKED_PAGE_DATA_SIZE - ca->used_space < size) { 175 if (LINKED_PAGE_DATA_SIZE - ca->used_space < size) {
270 struct linked_page *lp; 176 struct linked_page *lp;
271 177
272 lp = alloc_image_page(ca->gfp_mask, ca->safe_needed); 178 lp = get_image_page(ca->gfp_mask, ca->safe_needed);
273 if (!lp) 179 if (!lp)
274 return NULL; 180 return NULL;
275 181
@@ -446,8 +352,8 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
446 352
447 /* Compute the number of zones */ 353 /* Compute the number of zones */
448 nr = 0; 354 nr = 0;
449 for_each_zone (zone) 355 for_each_zone(zone)
450 if (populated_zone(zone) && !is_highmem(zone)) 356 if (populated_zone(zone))
451 nr++; 357 nr++;
452 358
453 /* Allocate the list of zones bitmap objects */ 359 /* Allocate the list of zones bitmap objects */
@@ -459,10 +365,10 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
459 } 365 }
460 366
461 /* Initialize the zone bitmap objects */ 367 /* Initialize the zone bitmap objects */
462 for_each_zone (zone) { 368 for_each_zone(zone) {
463 unsigned long pfn; 369 unsigned long pfn;
464 370
465 if (!populated_zone(zone) || is_highmem(zone)) 371 if (!populated_zone(zone))
466 continue; 372 continue;
467 373
468 zone_bm->start_pfn = zone->zone_start_pfn; 374 zone_bm->start_pfn = zone->zone_start_pfn;
@@ -481,7 +387,7 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
481 while (bb) { 387 while (bb) {
482 unsigned long *ptr; 388 unsigned long *ptr;
483 389
484 ptr = alloc_image_page(gfp_mask, safe_needed); 390 ptr = get_image_page(gfp_mask, safe_needed);
485 bb->data = ptr; 391 bb->data = ptr;
486 if (!ptr) 392 if (!ptr)
487 goto Free; 393 goto Free;
@@ -505,7 +411,7 @@ memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask, int safe_needed)
505 memory_bm_position_reset(bm); 411 memory_bm_position_reset(bm);
506 return 0; 412 return 0;
507 413
508Free: 414 Free:
509 bm->p_list = ca.chain; 415 bm->p_list = ca.chain;
510 memory_bm_free(bm, PG_UNSAFE_CLEAR); 416 memory_bm_free(bm, PG_UNSAFE_CLEAR);
511 return -ENOMEM; 417 return -ENOMEM;
@@ -651,7 +557,7 @@ static unsigned long memory_bm_next_pfn(struct memory_bitmap *bm)
651 memory_bm_position_reset(bm); 557 memory_bm_position_reset(bm);
652 return BM_END_OF_MAP; 558 return BM_END_OF_MAP;
653 559
654Return_pfn: 560 Return_pfn:
655 bm->cur.chunk = chunk; 561 bm->cur.chunk = chunk;
656 bm->cur.bit = bit; 562 bm->cur.bit = bit;
657 return bb->start_pfn + chunk * BM_BITS_PER_CHUNK + bit; 563 return bb->start_pfn + chunk * BM_BITS_PER_CHUNK + bit;
@@ -669,10 +575,82 @@ unsigned int snapshot_additional_pages(struct zone *zone)
669 575
670 res = DIV_ROUND_UP(zone->spanned_pages, BM_BITS_PER_BLOCK); 576 res = DIV_ROUND_UP(zone->spanned_pages, BM_BITS_PER_BLOCK);
671 res += DIV_ROUND_UP(res * sizeof(struct bm_block), PAGE_SIZE); 577 res += DIV_ROUND_UP(res * sizeof(struct bm_block), PAGE_SIZE);
672 return res; 578 return 2 * res;
579}
580
581#ifdef CONFIG_HIGHMEM
582/**
583 * count_free_highmem_pages - compute the total number of free highmem
584 * pages, system-wide.
585 */
586
587static unsigned int count_free_highmem_pages(void)
588{
589 struct zone *zone;
590 unsigned int cnt = 0;
591
592 for_each_zone(zone)
593 if (populated_zone(zone) && is_highmem(zone))
594 cnt += zone->free_pages;
595
596 return cnt;
597}
598
599/**
600 * saveable_highmem_page - Determine whether a highmem page should be
601 * included in the suspend image.
602 *
603 * We should save the page if it isn't Nosave or NosaveFree, or Reserved,
604 * and it isn't a part of a free chunk of pages.
605 */
606
607static struct page *saveable_highmem_page(unsigned long pfn)
608{
609 struct page *page;
610
611 if (!pfn_valid(pfn))
612 return NULL;
613
614 page = pfn_to_page(pfn);
615
616 BUG_ON(!PageHighMem(page));
617
618 if (PageNosave(page) || PageReserved(page) || PageNosaveFree(page))
619 return NULL;
620
621 return page;
673} 622}
674 623
675/** 624/**
625 * count_highmem_pages - compute the total number of saveable highmem
626 * pages.
627 */
628
629unsigned int count_highmem_pages(void)
630{
631 struct zone *zone;
632 unsigned int n = 0;
633
634 for_each_zone(zone) {
635 unsigned long pfn, max_zone_pfn;
636
637 if (!is_highmem(zone))
638 continue;
639
640 mark_free_pages(zone);
641 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
642 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
643 if (saveable_highmem_page(pfn))
644 n++;
645 }
646 return n;
647}
648#else
649static inline void *saveable_highmem_page(unsigned long pfn) { return NULL; }
650static inline unsigned int count_highmem_pages(void) { return 0; }
651#endif /* CONFIG_HIGHMEM */
652
653/**
676 * pfn_is_nosave - check if given pfn is in the 'nosave' section 654 * pfn_is_nosave - check if given pfn is in the 'nosave' section
677 */ 655 */
678 656
@@ -684,12 +662,12 @@ static inline int pfn_is_nosave(unsigned long pfn)
684} 662}
685 663
686/** 664/**
687 * saveable - Determine whether a page should be cloned or not. 665 * saveable - Determine whether a non-highmem page should be included in
688 * @pfn: The page 666 * the suspend image.
689 * 667 *
690 * We save a page if it isn't Nosave, and is not in the range of pages 668 * We should save the page if it isn't Nosave, and is not in the range
691 * statically defined as 'unsaveable', and it 669 * of pages statically defined as 'unsaveable', and it isn't a part of
692 * isn't a part of a free chunk of pages. 670 * a free chunk of pages.
693 */ 671 */
694 672
695static struct page *saveable_page(unsigned long pfn) 673static struct page *saveable_page(unsigned long pfn)
@@ -701,76 +679,130 @@ static struct page *saveable_page(unsigned long pfn)
701 679
702 page = pfn_to_page(pfn); 680 page = pfn_to_page(pfn);
703 681
704 if (PageNosave(page)) 682 BUG_ON(PageHighMem(page));
683
684 if (PageNosave(page) || PageNosaveFree(page))
705 return NULL; 685 return NULL;
686
706 if (PageReserved(page) && pfn_is_nosave(pfn)) 687 if (PageReserved(page) && pfn_is_nosave(pfn))
707 return NULL; 688 return NULL;
708 if (PageNosaveFree(page))
709 return NULL;
710 689
711 return page; 690 return page;
712} 691}
713 692
693/**
694 * count_data_pages - compute the total number of saveable non-highmem
695 * pages.
696 */
697
714unsigned int count_data_pages(void) 698unsigned int count_data_pages(void)
715{ 699{
716 struct zone *zone; 700 struct zone *zone;
717 unsigned long pfn, max_zone_pfn; 701 unsigned long pfn, max_zone_pfn;
718 unsigned int n = 0; 702 unsigned int n = 0;
719 703
720 for_each_zone (zone) { 704 for_each_zone(zone) {
721 if (is_highmem(zone)) 705 if (is_highmem(zone))
722 continue; 706 continue;
707
723 mark_free_pages(zone); 708 mark_free_pages(zone);
724 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; 709 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
725 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) 710 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
726 n += !!saveable_page(pfn); 711 if(saveable_page(pfn))
712 n++;
727 } 713 }
728 return n; 714 return n;
729} 715}
730 716
731static inline void copy_data_page(long *dst, long *src) 717/* This is needed, because copy_page and memcpy are not usable for copying
718 * task structs.
719 */
720static inline void do_copy_page(long *dst, long *src)
732{ 721{
733 int n; 722 int n;
734 723
735 /* copy_page and memcpy are not usable for copying task structs. */
736 for (n = PAGE_SIZE / sizeof(long); n; n--) 724 for (n = PAGE_SIZE / sizeof(long); n; n--)
737 *dst++ = *src++; 725 *dst++ = *src++;
738} 726}
739 727
728#ifdef CONFIG_HIGHMEM
729static inline struct page *
730page_is_saveable(struct zone *zone, unsigned long pfn)
731{
732 return is_highmem(zone) ?
733 saveable_highmem_page(pfn) : saveable_page(pfn);
734}
735
736static inline void
737copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
738{
739 struct page *s_page, *d_page;
740 void *src, *dst;
741
742 s_page = pfn_to_page(src_pfn);
743 d_page = pfn_to_page(dst_pfn);
744 if (PageHighMem(s_page)) {
745 src = kmap_atomic(s_page, KM_USER0);
746 dst = kmap_atomic(d_page, KM_USER1);
747 do_copy_page(dst, src);
748 kunmap_atomic(src, KM_USER0);
749 kunmap_atomic(dst, KM_USER1);
750 } else {
751 src = page_address(s_page);
752 if (PageHighMem(d_page)) {
753 /* Page pointed to by src may contain some kernel
754 * data modified by kmap_atomic()
755 */
756 do_copy_page(buffer, src);
757 dst = kmap_atomic(pfn_to_page(dst_pfn), KM_USER0);
758 memcpy(dst, buffer, PAGE_SIZE);
759 kunmap_atomic(dst, KM_USER0);
760 } else {
761 dst = page_address(d_page);
762 do_copy_page(dst, src);
763 }
764 }
765}
766#else
767#define page_is_saveable(zone, pfn) saveable_page(pfn)
768
769static inline void
770copy_data_page(unsigned long dst_pfn, unsigned long src_pfn)
771{
772 do_copy_page(page_address(pfn_to_page(dst_pfn)),
773 page_address(pfn_to_page(src_pfn)));
774}
775#endif /* CONFIG_HIGHMEM */
776
740static void 777static void
741copy_data_pages(struct memory_bitmap *copy_bm, struct memory_bitmap *orig_bm) 778copy_data_pages(struct memory_bitmap *copy_bm, struct memory_bitmap *orig_bm)
742{ 779{
743 struct zone *zone; 780 struct zone *zone;
744 unsigned long pfn; 781 unsigned long pfn;
745 782
746 for_each_zone (zone) { 783 for_each_zone(zone) {
747 unsigned long max_zone_pfn; 784 unsigned long max_zone_pfn;
748 785
749 if (is_highmem(zone))
750 continue;
751
752 mark_free_pages(zone); 786 mark_free_pages(zone);
753 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; 787 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
754 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) 788 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
755 if (saveable_page(pfn)) 789 if (page_is_saveable(zone, pfn))
756 memory_bm_set_bit(orig_bm, pfn); 790 memory_bm_set_bit(orig_bm, pfn);
757 } 791 }
758 memory_bm_position_reset(orig_bm); 792 memory_bm_position_reset(orig_bm);
759 memory_bm_position_reset(copy_bm); 793 memory_bm_position_reset(copy_bm);
760 do { 794 do {
761 pfn = memory_bm_next_pfn(orig_bm); 795 pfn = memory_bm_next_pfn(orig_bm);
762 if (likely(pfn != BM_END_OF_MAP)) { 796 if (likely(pfn != BM_END_OF_MAP))
763 struct page *page; 797 copy_data_page(memory_bm_next_pfn(copy_bm), pfn);
764 void *src;
765
766 page = pfn_to_page(pfn);
767 src = page_address(page);
768 page = pfn_to_page(memory_bm_next_pfn(copy_bm));
769 copy_data_page(page_address(page), src);
770 }
771 } while (pfn != BM_END_OF_MAP); 798 } while (pfn != BM_END_OF_MAP);
772} 799}
773 800
801/* Total number of image pages */
802static unsigned int nr_copy_pages;
803/* Number of pages needed for saving the original pfns of the image pages */
804static unsigned int nr_meta_pages;
805
774/** 806/**
775 * swsusp_free - free pages allocated for the suspend. 807 * swsusp_free - free pages allocated for the suspend.
776 * 808 *
@@ -792,7 +824,7 @@ void swsusp_free(void)
792 if (PageNosave(page) && PageNosaveFree(page)) { 824 if (PageNosave(page) && PageNosaveFree(page)) {
793 ClearPageNosave(page); 825 ClearPageNosave(page);
794 ClearPageNosaveFree(page); 826 ClearPageNosaveFree(page);
795 free_page((long) page_address(page)); 827 __free_page(page);
796 } 828 }
797 } 829 }
798 } 830 }
@@ -802,34 +834,108 @@ void swsusp_free(void)
802 buffer = NULL; 834 buffer = NULL;
803} 835}
804 836
837#ifdef CONFIG_HIGHMEM
838/**
839 * count_pages_for_highmem - compute the number of non-highmem pages
840 * that will be necessary for creating copies of highmem pages.
841 */
842
843static unsigned int count_pages_for_highmem(unsigned int nr_highmem)
844{
845 unsigned int free_highmem = count_free_highmem_pages();
846
847 if (free_highmem >= nr_highmem)
848 nr_highmem = 0;
849 else
850 nr_highmem -= free_highmem;
851
852 return nr_highmem;
853}
854#else
855static unsigned int
856count_pages_for_highmem(unsigned int nr_highmem) { return 0; }
857#endif /* CONFIG_HIGHMEM */
805 858
806/** 859/**
807 * enough_free_mem - Make sure we enough free memory to snapshot. 860 * enough_free_mem - Make sure we have enough free memory for the
808 * 861 * snapshot image.
809 * Returns TRUE or FALSE after checking the number of available
810 * free pages.
811 */ 862 */
812 863
813static int enough_free_mem(unsigned int nr_pages) 864static int enough_free_mem(unsigned int nr_pages, unsigned int nr_highmem)
814{ 865{
815 struct zone *zone; 866 struct zone *zone;
816 unsigned int free = 0, meta = 0; 867 unsigned int free = 0, meta = 0;
817 868
818 for_each_zone (zone) 869 for_each_zone(zone) {
819 if (!is_highmem(zone)) { 870 meta += snapshot_additional_pages(zone);
871 if (!is_highmem(zone))
820 free += zone->free_pages; 872 free += zone->free_pages;
821 meta += snapshot_additional_pages(zone); 873 }
822 }
823 874
824 pr_debug("swsusp: pages needed: %u + %u + %u, available pages: %u\n", 875 nr_pages += count_pages_for_highmem(nr_highmem);
876 pr_debug("swsusp: Normal pages needed: %u + %u + %u, available pages: %u\n",
825 nr_pages, PAGES_FOR_IO, meta, free); 877 nr_pages, PAGES_FOR_IO, meta, free);
826 878
827 return free > nr_pages + PAGES_FOR_IO + meta; 879 return free > nr_pages + PAGES_FOR_IO + meta;
828} 880}
829 881
882#ifdef CONFIG_HIGHMEM
883/**
884 * get_highmem_buffer - if there are some highmem pages in the suspend
885 * image, we may need the buffer to copy them and/or load their data.
886 */
887
888static inline int get_highmem_buffer(int safe_needed)
889{
890 buffer = get_image_page(GFP_ATOMIC | __GFP_COLD, safe_needed);
891 return buffer ? 0 : -ENOMEM;
892}
893
894/**
895 * alloc_highmem_image_pages - allocate some highmem pages for the image.
896 * Try to allocate as many pages as needed, but if the number of free
897 * highmem pages is lesser than that, allocate them all.
898 */
899
900static inline unsigned int
901alloc_highmem_image_pages(struct memory_bitmap *bm, unsigned int nr_highmem)
902{
903 unsigned int to_alloc = count_free_highmem_pages();
904
905 if (to_alloc > nr_highmem)
906 to_alloc = nr_highmem;
907
908 nr_highmem -= to_alloc;
909 while (to_alloc-- > 0) {
910 struct page *page;
911
912 page = alloc_image_page(__GFP_HIGHMEM);
913 memory_bm_set_bit(bm, page_to_pfn(page));
914 }
915 return nr_highmem;
916}
917#else
918static inline int get_highmem_buffer(int safe_needed) { return 0; }
919
920static inline unsigned int
921alloc_highmem_image_pages(struct memory_bitmap *bm, unsigned int n) { return 0; }
922#endif /* CONFIG_HIGHMEM */
923
924/**
925 * swsusp_alloc - allocate memory for the suspend image
926 *
927 * We first try to allocate as many highmem pages as there are
928 * saveable highmem pages in the system. If that fails, we allocate
929 * non-highmem pages for the copies of the remaining highmem ones.
930 *
931 * In this approach it is likely that the copies of highmem pages will
932 * also be located in the high memory, because of the way in which
933 * copy_data_pages() works.
934 */
935
830static int 936static int
831swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm, 937swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
832 unsigned int nr_pages) 938 unsigned int nr_pages, unsigned int nr_highmem)
833{ 939{
834 int error; 940 int error;
835 941
@@ -841,46 +947,61 @@ swsusp_alloc(struct memory_bitmap *orig_bm, struct memory_bitmap *copy_bm,
841 if (error) 947 if (error)
842 goto Free; 948 goto Free;
843 949
950 if (nr_highmem > 0) {
951 error = get_highmem_buffer(PG_ANY);
952 if (error)
953 goto Free;
954
955 nr_pages += alloc_highmem_image_pages(copy_bm, nr_highmem);
956 }
844 while (nr_pages-- > 0) { 957 while (nr_pages-- > 0) {
845 struct page *page = alloc_page(GFP_ATOMIC | __GFP_COLD); 958 struct page *page = alloc_image_page(GFP_ATOMIC | __GFP_COLD);
959
846 if (!page) 960 if (!page)
847 goto Free; 961 goto Free;
848 962
849 SetPageNosave(page);
850 SetPageNosaveFree(page);
851 memory_bm_set_bit(copy_bm, page_to_pfn(page)); 963 memory_bm_set_bit(copy_bm, page_to_pfn(page));
852 } 964 }
853 return 0; 965 return 0;
854 966
855Free: 967 Free:
856 swsusp_free(); 968 swsusp_free();
857 return -ENOMEM; 969 return -ENOMEM;
858} 970}
859 971
860/* Memory bitmap used for marking saveable pages */ 972/* Memory bitmap used for marking saveable pages (during suspend) or the
973 * suspend image pages (during resume)
974 */
861static struct memory_bitmap orig_bm; 975static struct memory_bitmap orig_bm;
862/* Memory bitmap used for marking allocated pages that will contain the copies 976/* Memory bitmap used on suspend for marking allocated pages that will contain
863 * of saveable pages 977 * the copies of saveable pages. During resume it is initially used for
978 * marking the suspend image pages, but then its set bits are duplicated in
979 * @orig_bm and it is released. Next, on systems with high memory, it may be
980 * used for marking "safe" highmem pages, but it has to be reinitialized for
981 * this purpose.
864 */ 982 */
865static struct memory_bitmap copy_bm; 983static struct memory_bitmap copy_bm;
866 984
867asmlinkage int swsusp_save(void) 985asmlinkage int swsusp_save(void)
868{ 986{
869 unsigned int nr_pages; 987 unsigned int nr_pages, nr_highmem;
870 988
871 pr_debug("swsusp: critical section: \n"); 989 printk("swsusp: critical section: \n");
872 990
873 drain_local_pages(); 991 drain_local_pages();
874 nr_pages = count_data_pages(); 992 nr_pages = count_data_pages();
875 printk("swsusp: Need to copy %u pages\n", nr_pages); 993 nr_highmem = count_highmem_pages();
994 printk("swsusp: Need to copy %u pages\n", nr_pages + nr_highmem);
876 995
877 if (!enough_free_mem(nr_pages)) { 996 if (!enough_free_mem(nr_pages, nr_highmem)) {
878 printk(KERN_ERR "swsusp: Not enough free memory\n"); 997 printk(KERN_ERR "swsusp: Not enough free memory\n");
879 return -ENOMEM; 998 return -ENOMEM;
880 } 999 }
881 1000
882 if (swsusp_alloc(&orig_bm, &copy_bm, nr_pages)) 1001 if (swsusp_alloc(&orig_bm, &copy_bm, nr_pages, nr_highmem)) {
1002 printk(KERN_ERR "swsusp: Memory allocation failed\n");
883 return -ENOMEM; 1003 return -ENOMEM;
1004 }
884 1005
885 /* During allocating of suspend pagedir, new cold pages may appear. 1006 /* During allocating of suspend pagedir, new cold pages may appear.
886 * Kill them. 1007 * Kill them.
@@ -894,10 +1015,12 @@ asmlinkage int swsusp_save(void)
894 * touch swap space! Except we must write out our image of course. 1015 * touch swap space! Except we must write out our image of course.
895 */ 1016 */
896 1017
1018 nr_pages += nr_highmem;
897 nr_copy_pages = nr_pages; 1019 nr_copy_pages = nr_pages;
898 nr_meta_pages = (nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT; 1020 nr_meta_pages = DIV_ROUND_UP(nr_pages * sizeof(long), PAGE_SIZE);
899 1021
900 printk("swsusp: critical section/: done (%d pages copied)\n", nr_pages); 1022 printk("swsusp: critical section/: done (%d pages copied)\n", nr_pages);
1023
901 return 0; 1024 return 0;
902} 1025}
903 1026
@@ -960,7 +1083,7 @@ int snapshot_read_next(struct snapshot_handle *handle, size_t count)
960 1083
961 if (!buffer) { 1084 if (!buffer) {
962 /* This makes the buffer be freed by swsusp_free() */ 1085 /* This makes the buffer be freed by swsusp_free() */
963 buffer = alloc_image_page(GFP_ATOMIC, PG_ANY); 1086 buffer = get_image_page(GFP_ATOMIC, PG_ANY);
964 if (!buffer) 1087 if (!buffer)
965 return -ENOMEM; 1088 return -ENOMEM;
966 } 1089 }
@@ -975,9 +1098,23 @@ int snapshot_read_next(struct snapshot_handle *handle, size_t count)
975 memset(buffer, 0, PAGE_SIZE); 1098 memset(buffer, 0, PAGE_SIZE);
976 pack_pfns(buffer, &orig_bm); 1099 pack_pfns(buffer, &orig_bm);
977 } else { 1100 } else {
978 unsigned long pfn = memory_bm_next_pfn(&copy_bm); 1101 struct page *page;
979 1102
980 handle->buffer = page_address(pfn_to_page(pfn)); 1103 page = pfn_to_page(memory_bm_next_pfn(&copy_bm));
1104 if (PageHighMem(page)) {
1105 /* Highmem pages are copied to the buffer,
1106 * because we can't return with a kmapped
1107 * highmem page (we may not be called again).
1108 */
1109 void *kaddr;
1110
1111 kaddr = kmap_atomic(page, KM_USER0);
1112 memcpy(buffer, kaddr, PAGE_SIZE);
1113 kunmap_atomic(kaddr, KM_USER0);
1114 handle->buffer = buffer;
1115 } else {
1116 handle->buffer = page_address(page);
1117 }
981 } 1118 }
982 handle->prev = handle->cur; 1119 handle->prev = handle->cur;
983 } 1120 }
@@ -1005,7 +1142,7 @@ static int mark_unsafe_pages(struct memory_bitmap *bm)
1005 unsigned long pfn, max_zone_pfn; 1142 unsigned long pfn, max_zone_pfn;
1006 1143
1007 /* Clear page flags */ 1144 /* Clear page flags */
1008 for_each_zone (zone) { 1145 for_each_zone(zone) {
1009 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages; 1146 max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
1010 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) 1147 for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++)
1011 if (pfn_valid(pfn)) 1148 if (pfn_valid(pfn))
@@ -1101,6 +1238,218 @@ unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm)
1101 } 1238 }
1102} 1239}
1103 1240
1241/* List of "safe" pages that may be used to store data loaded from the suspend
1242 * image
1243 */
1244static struct linked_page *safe_pages_list;
1245
1246#ifdef CONFIG_HIGHMEM
1247/* struct highmem_pbe is used for creating the list of highmem pages that
1248 * should be restored atomically during the resume from disk, because the page
1249 * frames they have occupied before the suspend are in use.
1250 */
1251struct highmem_pbe {
1252 struct page *copy_page; /* data is here now */
1253 struct page *orig_page; /* data was here before the suspend */
1254 struct highmem_pbe *next;
1255};
1256
1257/* List of highmem PBEs needed for restoring the highmem pages that were
1258 * allocated before the suspend and included in the suspend image, but have
1259 * also been allocated by the "resume" kernel, so their contents cannot be
1260 * written directly to their "original" page frames.
1261 */
1262static struct highmem_pbe *highmem_pblist;
1263
1264/**
1265 * count_highmem_image_pages - compute the number of highmem pages in the
1266 * suspend image. The bits in the memory bitmap @bm that correspond to the
1267 * image pages are assumed to be set.
1268 */
1269
1270static unsigned int count_highmem_image_pages(struct memory_bitmap *bm)
1271{
1272 unsigned long pfn;
1273 unsigned int cnt = 0;
1274
1275 memory_bm_position_reset(bm);
1276 pfn = memory_bm_next_pfn(bm);
1277 while (pfn != BM_END_OF_MAP) {
1278 if (PageHighMem(pfn_to_page(pfn)))
1279 cnt++;
1280
1281 pfn = memory_bm_next_pfn(bm);
1282 }
1283 return cnt;
1284}
1285
1286/**
1287 * prepare_highmem_image - try to allocate as many highmem pages as
1288 * there are highmem image pages (@nr_highmem_p points to the variable
1289 * containing the number of highmem image pages). The pages that are
1290 * "safe" (ie. will not be overwritten when the suspend image is
1291 * restored) have the corresponding bits set in @bm (it must be
1292 * unitialized).
1293 *
1294 * NOTE: This function should not be called if there are no highmem
1295 * image pages.
1296 */
1297
1298static unsigned int safe_highmem_pages;
1299
1300static struct memory_bitmap *safe_highmem_bm;
1301
1302static int
1303prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p)
1304{
1305 unsigned int to_alloc;
1306
1307 if (memory_bm_create(bm, GFP_ATOMIC, PG_SAFE))
1308 return -ENOMEM;
1309
1310 if (get_highmem_buffer(PG_SAFE))
1311 return -ENOMEM;
1312
1313 to_alloc = count_free_highmem_pages();
1314 if (to_alloc > *nr_highmem_p)
1315 to_alloc = *nr_highmem_p;
1316 else
1317 *nr_highmem_p = to_alloc;
1318
1319 safe_highmem_pages = 0;
1320 while (to_alloc-- > 0) {
1321 struct page *page;
1322
1323 page = alloc_page(__GFP_HIGHMEM);
1324 if (!PageNosaveFree(page)) {
1325 /* The page is "safe", set its bit the bitmap */
1326 memory_bm_set_bit(bm, page_to_pfn(page));
1327 safe_highmem_pages++;
1328 }
1329 /* Mark the page as allocated */
1330 SetPageNosave(page);
1331 SetPageNosaveFree(page);
1332 }
1333 memory_bm_position_reset(bm);
1334 safe_highmem_bm = bm;
1335 return 0;
1336}
1337
1338/**
1339 * get_highmem_page_buffer - for given highmem image page find the buffer
1340 * that suspend_write_next() should set for its caller to write to.
1341 *
1342 * If the page is to be saved to its "original" page frame or a copy of
1343 * the page is to be made in the highmem, @buffer is returned. Otherwise,
1344 * the copy of the page is to be made in normal memory, so the address of
1345 * the copy is returned.
1346 *
1347 * If @buffer is returned, the caller of suspend_write_next() will write
1348 * the page's contents to @buffer, so they will have to be copied to the
1349 * right location on the next call to suspend_write_next() and it is done
1350 * with the help of copy_last_highmem_page(). For this purpose, if
1351 * @buffer is returned, @last_highmem page is set to the page to which
1352 * the data will have to be copied from @buffer.
1353 */
1354
1355static struct page *last_highmem_page;
1356
1357static void *
1358get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
1359{
1360 struct highmem_pbe *pbe;
1361 void *kaddr;
1362
1363 if (PageNosave(page) && PageNosaveFree(page)) {
1364 /* We have allocated the "original" page frame and we can
1365 * use it directly to store the loaded page.
1366 */
1367 last_highmem_page = page;
1368 return buffer;
1369 }
1370 /* The "original" page frame has not been allocated and we have to
1371 * use a "safe" page frame to store the loaded page.
1372 */
1373 pbe = chain_alloc(ca, sizeof(struct highmem_pbe));
1374 if (!pbe) {
1375 swsusp_free();
1376 return NULL;
1377 }
1378 pbe->orig_page = page;
1379 if (safe_highmem_pages > 0) {
1380 struct page *tmp;
1381
1382 /* Copy of the page will be stored in high memory */
1383 kaddr = buffer;
1384 tmp = pfn_to_page(memory_bm_next_pfn(safe_highmem_bm));
1385 safe_highmem_pages--;
1386 last_highmem_page = tmp;
1387 pbe->copy_page = tmp;
1388 } else {
1389 /* Copy of the page will be stored in normal memory */
1390 kaddr = safe_pages_list;
1391 safe_pages_list = safe_pages_list->next;
1392 pbe->copy_page = virt_to_page(kaddr);
1393 }
1394 pbe->next = highmem_pblist;
1395 highmem_pblist = pbe;
1396 return kaddr;
1397}
1398
1399/**
1400 * copy_last_highmem_page - copy the contents of a highmem image from
1401 * @buffer, where the caller of snapshot_write_next() has place them,
1402 * to the right location represented by @last_highmem_page .
1403 */
1404
1405static void copy_last_highmem_page(void)
1406{
1407 if (last_highmem_page) {
1408 void *dst;
1409
1410 dst = kmap_atomic(last_highmem_page, KM_USER0);
1411 memcpy(dst, buffer, PAGE_SIZE);
1412 kunmap_atomic(dst, KM_USER0);
1413 last_highmem_page = NULL;
1414 }
1415}
1416
1417static inline int last_highmem_page_copied(void)
1418{
1419 return !last_highmem_page;
1420}
1421
1422static inline void free_highmem_data(void)
1423{
1424 if (safe_highmem_bm)
1425 memory_bm_free(safe_highmem_bm, PG_UNSAFE_CLEAR);
1426
1427 if (buffer)
1428 free_image_page(buffer, PG_UNSAFE_CLEAR);
1429}
1430#else
1431static inline int get_safe_write_buffer(void) { return 0; }
1432
1433static unsigned int
1434count_highmem_image_pages(struct memory_bitmap *bm) { return 0; }
1435
1436static inline int
1437prepare_highmem_image(struct memory_bitmap *bm, unsigned int *nr_highmem_p)
1438{
1439 return 0;
1440}
1441
1442static inline void *
1443get_highmem_page_buffer(struct page *page, struct chain_allocator *ca)
1444{
1445 return NULL;
1446}
1447
1448static inline void copy_last_highmem_page(void) {}
1449static inline int last_highmem_page_copied(void) { return 1; }
1450static inline void free_highmem_data(void) {}
1451#endif /* CONFIG_HIGHMEM */
1452
1104/** 1453/**
1105 * prepare_image - use the memory bitmap @bm to mark the pages that will 1454 * prepare_image - use the memory bitmap @bm to mark the pages that will
1106 * be overwritten in the process of restoring the system memory state 1455 * be overwritten in the process of restoring the system memory state
@@ -1110,20 +1459,25 @@ unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm)
1110 * The idea is to allocate a new memory bitmap first and then allocate 1459 * The idea is to allocate a new memory bitmap first and then allocate
1111 * as many pages as needed for the image data, but not to assign these 1460 * as many pages as needed for the image data, but not to assign these
1112 * pages to specific tasks initially. Instead, we just mark them as 1461 * pages to specific tasks initially. Instead, we just mark them as
1113 * allocated and create a list of "safe" pages that will be used later. 1462 * allocated and create a lists of "safe" pages that will be used
1463 * later. On systems with high memory a list of "safe" highmem pages is
1464 * also created.
1114 */ 1465 */
1115 1466
1116#define PBES_PER_LINKED_PAGE (LINKED_PAGE_DATA_SIZE / sizeof(struct pbe)) 1467#define PBES_PER_LINKED_PAGE (LINKED_PAGE_DATA_SIZE / sizeof(struct pbe))
1117 1468
1118static struct linked_page *safe_pages_list;
1119
1120static int 1469static int
1121prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm) 1470prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1122{ 1471{
1123 unsigned int nr_pages; 1472 unsigned int nr_pages, nr_highmem;
1124 struct linked_page *sp_list, *lp; 1473 struct linked_page *sp_list, *lp;
1125 int error; 1474 int error;
1126 1475
1476 /* If there is no highmem, the buffer will not be necessary */
1477 free_image_page(buffer, PG_UNSAFE_CLEAR);
1478 buffer = NULL;
1479
1480 nr_highmem = count_highmem_image_pages(bm);
1127 error = mark_unsafe_pages(bm); 1481 error = mark_unsafe_pages(bm);
1128 if (error) 1482 if (error)
1129 goto Free; 1483 goto Free;
@@ -1134,6 +1488,11 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1134 1488
1135 duplicate_memory_bitmap(new_bm, bm); 1489 duplicate_memory_bitmap(new_bm, bm);
1136 memory_bm_free(bm, PG_UNSAFE_KEEP); 1490 memory_bm_free(bm, PG_UNSAFE_KEEP);
1491 if (nr_highmem > 0) {
1492 error = prepare_highmem_image(bm, &nr_highmem);
1493 if (error)
1494 goto Free;
1495 }
1137 /* Reserve some safe pages for potential later use. 1496 /* Reserve some safe pages for potential later use.
1138 * 1497 *
1139 * NOTE: This way we make sure there will be enough safe pages for the 1498 * NOTE: This way we make sure there will be enough safe pages for the
@@ -1142,10 +1501,10 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1142 */ 1501 */
1143 sp_list = NULL; 1502 sp_list = NULL;
1144 /* nr_copy_pages cannot be lesser than allocated_unsafe_pages */ 1503 /* nr_copy_pages cannot be lesser than allocated_unsafe_pages */
1145 nr_pages = nr_copy_pages - allocated_unsafe_pages; 1504 nr_pages = nr_copy_pages - nr_highmem - allocated_unsafe_pages;
1146 nr_pages = DIV_ROUND_UP(nr_pages, PBES_PER_LINKED_PAGE); 1505 nr_pages = DIV_ROUND_UP(nr_pages, PBES_PER_LINKED_PAGE);
1147 while (nr_pages > 0) { 1506 while (nr_pages > 0) {
1148 lp = alloc_image_page(GFP_ATOMIC, PG_SAFE); 1507 lp = get_image_page(GFP_ATOMIC, PG_SAFE);
1149 if (!lp) { 1508 if (!lp) {
1150 error = -ENOMEM; 1509 error = -ENOMEM;
1151 goto Free; 1510 goto Free;
@@ -1156,7 +1515,7 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1156 } 1515 }
1157 /* Preallocate memory for the image */ 1516 /* Preallocate memory for the image */
1158 safe_pages_list = NULL; 1517 safe_pages_list = NULL;
1159 nr_pages = nr_copy_pages - allocated_unsafe_pages; 1518 nr_pages = nr_copy_pages - nr_highmem - allocated_unsafe_pages;
1160 while (nr_pages > 0) { 1519 while (nr_pages > 0) {
1161 lp = (struct linked_page *)get_zeroed_page(GFP_ATOMIC); 1520 lp = (struct linked_page *)get_zeroed_page(GFP_ATOMIC);
1162 if (!lp) { 1521 if (!lp) {
@@ -1181,7 +1540,7 @@ prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm)
1181 } 1540 }
1182 return 0; 1541 return 0;
1183 1542
1184Free: 1543 Free:
1185 swsusp_free(); 1544 swsusp_free();
1186 return error; 1545 return error;
1187} 1546}
@@ -1196,6 +1555,9 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
1196 struct pbe *pbe; 1555 struct pbe *pbe;
1197 struct page *page = pfn_to_page(memory_bm_next_pfn(bm)); 1556 struct page *page = pfn_to_page(memory_bm_next_pfn(bm));
1198 1557
1558 if (PageHighMem(page))
1559 return get_highmem_page_buffer(page, ca);
1560
1199 if (PageNosave(page) && PageNosaveFree(page)) 1561 if (PageNosave(page) && PageNosaveFree(page))
1200 /* We have allocated the "original" page frame and we can 1562 /* We have allocated the "original" page frame and we can
1201 * use it directly to store the loaded page. 1563 * use it directly to store the loaded page.
@@ -1210,12 +1572,12 @@ static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
1210 swsusp_free(); 1572 swsusp_free();
1211 return NULL; 1573 return NULL;
1212 } 1574 }
1213 pbe->orig_address = (unsigned long)page_address(page); 1575 pbe->orig_address = page_address(page);
1214 pbe->address = (unsigned long)safe_pages_list; 1576 pbe->address = safe_pages_list;
1215 safe_pages_list = safe_pages_list->next; 1577 safe_pages_list = safe_pages_list->next;
1216 pbe->next = restore_pblist; 1578 pbe->next = restore_pblist;
1217 restore_pblist = pbe; 1579 restore_pblist = pbe;
1218 return (void *)pbe->address; 1580 return pbe->address;
1219} 1581}
1220 1582
1221/** 1583/**
@@ -1249,14 +1611,16 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
1249 if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages) 1611 if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages)
1250 return 0; 1612 return 0;
1251 1613
1252 if (!buffer) { 1614 if (handle->offset == 0) {
1253 /* This makes the buffer be freed by swsusp_free() */ 1615 if (!buffer)
1254 buffer = alloc_image_page(GFP_ATOMIC, PG_ANY); 1616 /* This makes the buffer be freed by swsusp_free() */
1617 buffer = get_image_page(GFP_ATOMIC, PG_ANY);
1618
1255 if (!buffer) 1619 if (!buffer)
1256 return -ENOMEM; 1620 return -ENOMEM;
1257 } 1621
1258 if (!handle->offset)
1259 handle->buffer = buffer; 1622 handle->buffer = buffer;
1623 }
1260 handle->sync_read = 1; 1624 handle->sync_read = 1;
1261 if (handle->prev < handle->cur) { 1625 if (handle->prev < handle->cur) {
1262 if (handle->prev == 0) { 1626 if (handle->prev == 0) {
@@ -1284,8 +1648,10 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
1284 return -ENOMEM; 1648 return -ENOMEM;
1285 } 1649 }
1286 } else { 1650 } else {
1651 copy_last_highmem_page();
1287 handle->buffer = get_buffer(&orig_bm, &ca); 1652 handle->buffer = get_buffer(&orig_bm, &ca);
1288 handle->sync_read = 0; 1653 if (handle->buffer != buffer)
1654 handle->sync_read = 0;
1289 } 1655 }
1290 handle->prev = handle->cur; 1656 handle->prev = handle->cur;
1291 } 1657 }
@@ -1301,15 +1667,73 @@ int snapshot_write_next(struct snapshot_handle *handle, size_t count)
1301 return count; 1667 return count;
1302} 1668}
1303 1669
1670/**
1671 * snapshot_write_finalize - must be called after the last call to
1672 * snapshot_write_next() in case the last page in the image happens
1673 * to be a highmem page and its contents should be stored in the
1674 * highmem. Additionally, it releases the memory that will not be
1675 * used any more.
1676 */
1677
1678void snapshot_write_finalize(struct snapshot_handle *handle)
1679{
1680 copy_last_highmem_page();
1681 /* Free only if we have loaded the image entirely */
1682 if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages) {
1683 memory_bm_free(&orig_bm, PG_UNSAFE_CLEAR);
1684 free_highmem_data();
1685 }
1686}
1687
1304int snapshot_image_loaded(struct snapshot_handle *handle) 1688int snapshot_image_loaded(struct snapshot_handle *handle)
1305{ 1689{
1306 return !(!nr_copy_pages || 1690 return !(!nr_copy_pages || !last_highmem_page_copied() ||
1307 handle->cur <= nr_meta_pages + nr_copy_pages); 1691 handle->cur <= nr_meta_pages + nr_copy_pages);
1308} 1692}
1309 1693
1310void snapshot_free_unused_memory(struct snapshot_handle *handle) 1694#ifdef CONFIG_HIGHMEM
1695/* Assumes that @buf is ready and points to a "safe" page */
1696static inline void
1697swap_two_pages_data(struct page *p1, struct page *p2, void *buf)
1311{ 1698{
1312 /* Free only if we have loaded the image entirely */ 1699 void *kaddr1, *kaddr2;
1313 if (handle->prev && handle->cur > nr_meta_pages + nr_copy_pages) 1700
1314 memory_bm_free(&orig_bm, PG_UNSAFE_CLEAR); 1701 kaddr1 = kmap_atomic(p1, KM_USER0);
1702 kaddr2 = kmap_atomic(p2, KM_USER1);
1703 memcpy(buf, kaddr1, PAGE_SIZE);
1704 memcpy(kaddr1, kaddr2, PAGE_SIZE);
1705 memcpy(kaddr2, buf, PAGE_SIZE);
1706 kunmap_atomic(kaddr1, KM_USER0);
1707 kunmap_atomic(kaddr2, KM_USER1);
1708}
1709
1710/**
1711 * restore_highmem - for each highmem page that was allocated before
1712 * the suspend and included in the suspend image, and also has been
1713 * allocated by the "resume" kernel swap its current (ie. "before
1714 * resume") contents with the previous (ie. "before suspend") one.
1715 *
1716 * If the resume eventually fails, we can call this function once
1717 * again and restore the "before resume" highmem state.
1718 */
1719
1720int restore_highmem(void)
1721{
1722 struct highmem_pbe *pbe = highmem_pblist;
1723 void *buf;
1724
1725 if (!pbe)
1726 return 0;
1727
1728 buf = get_image_page(GFP_ATOMIC, PG_SAFE);
1729 if (!buf)
1730 return -ENOMEM;
1731
1732 while (pbe) {
1733 swap_two_pages_data(pbe->copy_page, pbe->orig_page, buf);
1734 pbe = pbe->next;
1735 }
1736 free_image_page(buf, PG_UNSAFE_CLEAR);
1737 return 0;
1315} 1738}
1739#endif /* CONFIG_HIGHMEM */
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 1a3b0dd2c3fc..f133d4a6d817 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -34,34 +34,123 @@ extern char resume_file[];
34#define SWSUSP_SIG "S1SUSPEND" 34#define SWSUSP_SIG "S1SUSPEND"
35 35
36static struct swsusp_header { 36static struct swsusp_header {
37 char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)]; 37 char reserved[PAGE_SIZE - 20 - sizeof(sector_t)];
38 swp_entry_t image; 38 sector_t image;
39 char orig_sig[10]; 39 char orig_sig[10];
40 char sig[10]; 40 char sig[10];
41} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header; 41} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header;
42 42
43/* 43/*
44 * Saving part... 44 * General things
45 */ 45 */
46 46
47static unsigned short root_swap = 0xffff; 47static unsigned short root_swap = 0xffff;
48static struct block_device *resume_bdev;
49
50/**
51 * submit - submit BIO request.
52 * @rw: READ or WRITE.
53 * @off physical offset of page.
54 * @page: page we're reading or writing.
55 * @bio_chain: list of pending biod (for async reading)
56 *
57 * Straight from the textbook - allocate and initialize the bio.
58 * If we're reading, make sure the page is marked as dirty.
59 * Then submit it and, if @bio_chain == NULL, wait.
60 */
61static int submit(int rw, pgoff_t page_off, struct page *page,
62 struct bio **bio_chain)
63{
64 struct bio *bio;
65
66 bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1);
67 if (!bio)
68 return -ENOMEM;
69 bio->bi_sector = page_off * (PAGE_SIZE >> 9);
70 bio->bi_bdev = resume_bdev;
71 bio->bi_end_io = end_swap_bio_read;
72
73 if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
74 printk("swsusp: ERROR: adding page to bio at %ld\n", page_off);
75 bio_put(bio);
76 return -EFAULT;
77 }
78
79 lock_page(page);
80 bio_get(bio);
81
82 if (bio_chain == NULL) {
83 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
84 wait_on_page_locked(page);
85 if (rw == READ)
86 bio_set_pages_dirty(bio);
87 bio_put(bio);
88 } else {
89 if (rw == READ)
90 get_page(page); /* These pages are freed later */
91 bio->bi_private = *bio_chain;
92 *bio_chain = bio;
93 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
94 }
95 return 0;
96}
97
98static int bio_read_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
99{
100 return submit(READ, page_off, virt_to_page(addr), bio_chain);
101}
102
103static int bio_write_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
104{
105 return submit(WRITE, page_off, virt_to_page(addr), bio_chain);
106}
107
108static int wait_on_bio_chain(struct bio **bio_chain)
109{
110 struct bio *bio;
111 struct bio *next_bio;
112 int ret = 0;
113
114 if (bio_chain == NULL)
115 return 0;
116
117 bio = *bio_chain;
118 if (bio == NULL)
119 return 0;
120 while (bio) {
121 struct page *page;
122
123 next_bio = bio->bi_private;
124 page = bio->bi_io_vec[0].bv_page;
125 wait_on_page_locked(page);
126 if (!PageUptodate(page) || PageError(page))
127 ret = -EIO;
128 put_page(page);
129 bio_put(bio);
130 bio = next_bio;
131 }
132 *bio_chain = NULL;
133 return ret;
134}
135
136/*
137 * Saving part
138 */
48 139
49static int mark_swapfiles(swp_entry_t start) 140static int mark_swapfiles(sector_t start)
50{ 141{
51 int error; 142 int error;
52 143
53 rw_swap_page_sync(READ, swp_entry(root_swap, 0), 144 bio_read_page(swsusp_resume_block, &swsusp_header, NULL);
54 virt_to_page((unsigned long)&swsusp_header), NULL);
55 if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) || 145 if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
56 !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) { 146 !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
57 memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10); 147 memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
58 memcpy(swsusp_header.sig,SWSUSP_SIG, 10); 148 memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
59 swsusp_header.image = start; 149 swsusp_header.image = start;
60 error = rw_swap_page_sync(WRITE, swp_entry(root_swap, 0), 150 error = bio_write_page(swsusp_resume_block,
61 virt_to_page((unsigned long)&swsusp_header), 151 &swsusp_header, NULL);
62 NULL);
63 } else { 152 } else {
64 pr_debug("swsusp: Partition is not swap space.\n"); 153 printk(KERN_ERR "swsusp: Swap header not found!\n");
65 error = -ENODEV; 154 error = -ENODEV;
66 } 155 }
67 return error; 156 return error;
@@ -74,12 +163,21 @@ static int mark_swapfiles(swp_entry_t start)
74 163
75static int swsusp_swap_check(void) /* This is called before saving image */ 164static int swsusp_swap_check(void) /* This is called before saving image */
76{ 165{
77 int res = swap_type_of(swsusp_resume_device); 166 int res;
167
168 res = swap_type_of(swsusp_resume_device, swsusp_resume_block);
169 if (res < 0)
170 return res;
171
172 root_swap = res;
173 resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_WRITE);
174 if (IS_ERR(resume_bdev))
175 return PTR_ERR(resume_bdev);
176
177 res = set_blocksize(resume_bdev, PAGE_SIZE);
178 if (res < 0)
179 blkdev_put(resume_bdev);
78 180
79 if (res >= 0) {
80 root_swap = res;
81 return 0;
82 }
83 return res; 181 return res;
84} 182}
85 183
@@ -90,36 +188,26 @@ static int swsusp_swap_check(void) /* This is called before saving image */
90 * @bio_chain: Link the next write BIO here 188 * @bio_chain: Link the next write BIO here
91 */ 189 */
92 190
93static int write_page(void *buf, unsigned long offset, struct bio **bio_chain) 191static int write_page(void *buf, sector_t offset, struct bio **bio_chain)
94{ 192{
95 swp_entry_t entry; 193 void *src;
96 int error = -ENOSPC; 194
97 195 if (!offset)
98 if (offset) { 196 return -ENOSPC;
99 struct page *page = virt_to_page(buf); 197
100 198 if (bio_chain) {
101 if (bio_chain) { 199 src = (void *)__get_free_page(__GFP_WAIT | __GFP_HIGH);
102 /* 200 if (src) {
103 * Whether or not we successfully allocated a copy page, 201 memcpy(src, buf, PAGE_SIZE);
104 * we take a ref on the page here. It gets undone in 202 } else {
105 * wait_on_bio_chain(). 203 WARN_ON_ONCE(1);
106 */ 204 bio_chain = NULL; /* Go synchronous */
107 struct page *page_copy; 205 src = buf;
108 page_copy = alloc_page(GFP_ATOMIC);
109 if (page_copy == NULL) {
110 WARN_ON_ONCE(1);
111 bio_chain = NULL; /* Go synchronous */
112 get_page(page);
113 } else {
114 memcpy(page_address(page_copy),
115 page_address(page), PAGE_SIZE);
116 page = page_copy;
117 }
118 } 206 }
119 entry = swp_entry(root_swap, offset); 207 } else {
120 error = rw_swap_page_sync(WRITE, entry, page, bio_chain); 208 src = buf;
121 } 209 }
122 return error; 210 return bio_write_page(offset, src, bio_chain);
123} 211}
124 212
125/* 213/*
@@ -137,11 +225,11 @@ static int write_page(void *buf, unsigned long offset, struct bio **bio_chain)
137 * at a time. 225 * at a time.
138 */ 226 */
139 227
140#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(long) - 1) 228#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(sector_t) - 1)
141 229
142struct swap_map_page { 230struct swap_map_page {
143 unsigned long entries[MAP_PAGE_ENTRIES]; 231 sector_t entries[MAP_PAGE_ENTRIES];
144 unsigned long next_swap; 232 sector_t next_swap;
145}; 233};
146 234
147/** 235/**
@@ -151,7 +239,7 @@ struct swap_map_page {
151 239
152struct swap_map_handle { 240struct swap_map_handle {
153 struct swap_map_page *cur; 241 struct swap_map_page *cur;
154 unsigned long cur_swap; 242 sector_t cur_swap;
155 struct bitmap_page *bitmap; 243 struct bitmap_page *bitmap;
156 unsigned int k; 244 unsigned int k;
157}; 245};
@@ -166,26 +254,6 @@ static void release_swap_writer(struct swap_map_handle *handle)
166 handle->bitmap = NULL; 254 handle->bitmap = NULL;
167} 255}
168 256
169static void show_speed(struct timeval *start, struct timeval *stop,
170 unsigned nr_pages, char *msg)
171{
172 s64 elapsed_centisecs64;
173 int centisecs;
174 int k;
175 int kps;
176
177 elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
178 do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
179 centisecs = elapsed_centisecs64;
180 if (centisecs == 0)
181 centisecs = 1; /* avoid div-by-zero */
182 k = nr_pages * (PAGE_SIZE / 1024);
183 kps = (k * 100) / centisecs;
184 printk("%s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n", msg, k,
185 centisecs / 100, centisecs % 100,
186 kps / 1000, (kps % 1000) / 10);
187}
188
189static int get_swap_writer(struct swap_map_handle *handle) 257static int get_swap_writer(struct swap_map_handle *handle)
190{ 258{
191 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL); 259 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL);
@@ -196,7 +264,7 @@ static int get_swap_writer(struct swap_map_handle *handle)
196 release_swap_writer(handle); 264 release_swap_writer(handle);
197 return -ENOMEM; 265 return -ENOMEM;
198 } 266 }
199 handle->cur_swap = alloc_swap_page(root_swap, handle->bitmap); 267 handle->cur_swap = alloc_swapdev_block(root_swap, handle->bitmap);
200 if (!handle->cur_swap) { 268 if (!handle->cur_swap) {
201 release_swap_writer(handle); 269 release_swap_writer(handle);
202 return -ENOSPC; 270 return -ENOSPC;
@@ -205,43 +273,15 @@ static int get_swap_writer(struct swap_map_handle *handle)
205 return 0; 273 return 0;
206} 274}
207 275
208static int wait_on_bio_chain(struct bio **bio_chain)
209{
210 struct bio *bio;
211 struct bio *next_bio;
212 int ret = 0;
213
214 if (bio_chain == NULL)
215 return 0;
216
217 bio = *bio_chain;
218 if (bio == NULL)
219 return 0;
220 while (bio) {
221 struct page *page;
222
223 next_bio = bio->bi_private;
224 page = bio->bi_io_vec[0].bv_page;
225 wait_on_page_locked(page);
226 if (!PageUptodate(page) || PageError(page))
227 ret = -EIO;
228 put_page(page);
229 bio_put(bio);
230 bio = next_bio;
231 }
232 *bio_chain = NULL;
233 return ret;
234}
235
236static int swap_write_page(struct swap_map_handle *handle, void *buf, 276static int swap_write_page(struct swap_map_handle *handle, void *buf,
237 struct bio **bio_chain) 277 struct bio **bio_chain)
238{ 278{
239 int error = 0; 279 int error = 0;
240 unsigned long offset; 280 sector_t offset;
241 281
242 if (!handle->cur) 282 if (!handle->cur)
243 return -EINVAL; 283 return -EINVAL;
244 offset = alloc_swap_page(root_swap, handle->bitmap); 284 offset = alloc_swapdev_block(root_swap, handle->bitmap);
245 error = write_page(buf, offset, bio_chain); 285 error = write_page(buf, offset, bio_chain);
246 if (error) 286 if (error)
247 return error; 287 return error;
@@ -250,7 +290,7 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
250 error = wait_on_bio_chain(bio_chain); 290 error = wait_on_bio_chain(bio_chain);
251 if (error) 291 if (error)
252 goto out; 292 goto out;
253 offset = alloc_swap_page(root_swap, handle->bitmap); 293 offset = alloc_swapdev_block(root_swap, handle->bitmap);
254 if (!offset) 294 if (!offset)
255 return -ENOSPC; 295 return -ENOSPC;
256 handle->cur->next_swap = offset; 296 handle->cur->next_swap = offset;
@@ -261,7 +301,7 @@ static int swap_write_page(struct swap_map_handle *handle, void *buf,
261 handle->cur_swap = offset; 301 handle->cur_swap = offset;
262 handle->k = 0; 302 handle->k = 0;
263 } 303 }
264out: 304 out:
265 return error; 305 return error;
266} 306}
267 307
@@ -315,7 +355,7 @@ static int save_image(struct swap_map_handle *handle,
315 error = err2; 355 error = err2;
316 if (!error) 356 if (!error)
317 printk("\b\b\b\bdone\n"); 357 printk("\b\b\b\bdone\n");
318 show_speed(&start, &stop, nr_to_write, "Wrote"); 358 swsusp_show_speed(&start, &stop, nr_to_write, "Wrote");
319 return error; 359 return error;
320} 360}
321 361
@@ -350,100 +390,50 @@ int swsusp_write(void)
350 struct swsusp_info *header; 390 struct swsusp_info *header;
351 int error; 391 int error;
352 392
353 if ((error = swsusp_swap_check())) { 393 error = swsusp_swap_check();
394 if (error) {
354 printk(KERN_ERR "swsusp: Cannot find swap device, try " 395 printk(KERN_ERR "swsusp: Cannot find swap device, try "
355 "swapon -a.\n"); 396 "swapon -a.\n");
356 return error; 397 return error;
357 } 398 }
358 memset(&snapshot, 0, sizeof(struct snapshot_handle)); 399 memset(&snapshot, 0, sizeof(struct snapshot_handle));
359 error = snapshot_read_next(&snapshot, PAGE_SIZE); 400 error = snapshot_read_next(&snapshot, PAGE_SIZE);
360 if (error < PAGE_SIZE) 401 if (error < PAGE_SIZE) {
361 return error < 0 ? error : -EFAULT; 402 if (error >= 0)
403 error = -EFAULT;
404
405 goto out;
406 }
362 header = (struct swsusp_info *)data_of(snapshot); 407 header = (struct swsusp_info *)data_of(snapshot);
363 if (!enough_swap(header->pages)) { 408 if (!enough_swap(header->pages)) {
364 printk(KERN_ERR "swsusp: Not enough free swap\n"); 409 printk(KERN_ERR "swsusp: Not enough free swap\n");
365 return -ENOSPC; 410 error = -ENOSPC;
411 goto out;
366 } 412 }
367 error = get_swap_writer(&handle); 413 error = get_swap_writer(&handle);
368 if (!error) { 414 if (!error) {
369 unsigned long start = handle.cur_swap; 415 sector_t start = handle.cur_swap;
416
370 error = swap_write_page(&handle, header, NULL); 417 error = swap_write_page(&handle, header, NULL);
371 if (!error) 418 if (!error)
372 error = save_image(&handle, &snapshot, 419 error = save_image(&handle, &snapshot,
373 header->pages - 1); 420 header->pages - 1);
421
374 if (!error) { 422 if (!error) {
375 flush_swap_writer(&handle); 423 flush_swap_writer(&handle);
376 printk("S"); 424 printk("S");
377 error = mark_swapfiles(swp_entry(root_swap, start)); 425 error = mark_swapfiles(start);
378 printk("|\n"); 426 printk("|\n");
379 } 427 }
380 } 428 }
381 if (error) 429 if (error)
382 free_all_swap_pages(root_swap, handle.bitmap); 430 free_all_swap_pages(root_swap, handle.bitmap);
383 release_swap_writer(&handle); 431 release_swap_writer(&handle);
432 out:
433 swsusp_close();
384 return error; 434 return error;
385} 435}
386 436
387static struct block_device *resume_bdev;
388
389/**
390 * submit - submit BIO request.
391 * @rw: READ or WRITE.
392 * @off physical offset of page.
393 * @page: page we're reading or writing.
394 * @bio_chain: list of pending biod (for async reading)
395 *
396 * Straight from the textbook - allocate and initialize the bio.
397 * If we're reading, make sure the page is marked as dirty.
398 * Then submit it and, if @bio_chain == NULL, wait.
399 */
400static int submit(int rw, pgoff_t page_off, struct page *page,
401 struct bio **bio_chain)
402{
403 struct bio *bio;
404
405 bio = bio_alloc(GFP_ATOMIC, 1);
406 if (!bio)
407 return -ENOMEM;
408 bio->bi_sector = page_off * (PAGE_SIZE >> 9);
409 bio->bi_bdev = resume_bdev;
410 bio->bi_end_io = end_swap_bio_read;
411
412 if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) {
413 printk("swsusp: ERROR: adding page to bio at %ld\n", page_off);
414 bio_put(bio);
415 return -EFAULT;
416 }
417
418 lock_page(page);
419 bio_get(bio);
420
421 if (bio_chain == NULL) {
422 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
423 wait_on_page_locked(page);
424 if (rw == READ)
425 bio_set_pages_dirty(bio);
426 bio_put(bio);
427 } else {
428 if (rw == READ)
429 get_page(page); /* These pages are freed later */
430 bio->bi_private = *bio_chain;
431 *bio_chain = bio;
432 submit_bio(rw | (1 << BIO_RW_SYNC), bio);
433 }
434 return 0;
435}
436
437static int bio_read_page(pgoff_t page_off, void *addr, struct bio **bio_chain)
438{
439 return submit(READ, page_off, virt_to_page(addr), bio_chain);
440}
441
442static int bio_write_page(pgoff_t page_off, void *addr)
443{
444 return submit(WRITE, page_off, virt_to_page(addr), NULL);
445}
446
447/** 437/**
448 * The following functions allow us to read data using a swap map 438 * The following functions allow us to read data using a swap map
449 * in a file-alike way 439 * in a file-alike way
@@ -456,17 +446,18 @@ static void release_swap_reader(struct swap_map_handle *handle)
456 handle->cur = NULL; 446 handle->cur = NULL;
457} 447}
458 448
459static int get_swap_reader(struct swap_map_handle *handle, 449static int get_swap_reader(struct swap_map_handle *handle, sector_t start)
460 swp_entry_t start)
461{ 450{
462 int error; 451 int error;
463 452
464 if (!swp_offset(start)) 453 if (!start)
465 return -EINVAL; 454 return -EINVAL;
466 handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC); 455
456 handle->cur = (struct swap_map_page *)get_zeroed_page(__GFP_WAIT | __GFP_HIGH);
467 if (!handle->cur) 457 if (!handle->cur)
468 return -ENOMEM; 458 return -ENOMEM;
469 error = bio_read_page(swp_offset(start), handle->cur, NULL); 459
460 error = bio_read_page(start, handle->cur, NULL);
470 if (error) { 461 if (error) {
471 release_swap_reader(handle); 462 release_swap_reader(handle);
472 return error; 463 return error;
@@ -478,7 +469,7 @@ static int get_swap_reader(struct swap_map_handle *handle,
478static int swap_read_page(struct swap_map_handle *handle, void *buf, 469static int swap_read_page(struct swap_map_handle *handle, void *buf,
479 struct bio **bio_chain) 470 struct bio **bio_chain)
480{ 471{
481 unsigned long offset; 472 sector_t offset;
482 int error; 473 int error;
483 474
484 if (!handle->cur) 475 if (!handle->cur)
@@ -547,11 +538,11 @@ static int load_image(struct swap_map_handle *handle,
547 error = err2; 538 error = err2;
548 if (!error) { 539 if (!error) {
549 printk("\b\b\b\bdone\n"); 540 printk("\b\b\b\bdone\n");
550 snapshot_free_unused_memory(snapshot); 541 snapshot_write_finalize(snapshot);
551 if (!snapshot_image_loaded(snapshot)) 542 if (!snapshot_image_loaded(snapshot))
552 error = -ENODATA; 543 error = -ENODATA;
553 } 544 }
554 show_speed(&start, &stop, nr_to_read, "Read"); 545 swsusp_show_speed(&start, &stop, nr_to_read, "Read");
555 return error; 546 return error;
556} 547}
557 548
@@ -600,12 +591,16 @@ int swsusp_check(void)
600 if (!IS_ERR(resume_bdev)) { 591 if (!IS_ERR(resume_bdev)) {
601 set_blocksize(resume_bdev, PAGE_SIZE); 592 set_blocksize(resume_bdev, PAGE_SIZE);
602 memset(&swsusp_header, 0, sizeof(swsusp_header)); 593 memset(&swsusp_header, 0, sizeof(swsusp_header));
603 if ((error = bio_read_page(0, &swsusp_header, NULL))) 594 error = bio_read_page(swsusp_resume_block,
595 &swsusp_header, NULL);
596 if (error)
604 return error; 597 return error;
598
605 if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) { 599 if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
606 memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10); 600 memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
607 /* Reset swap signature now */ 601 /* Reset swap signature now */
608 error = bio_write_page(0, &swsusp_header); 602 error = bio_write_page(swsusp_resume_block,
603 &swsusp_header, NULL);
609 } else { 604 } else {
610 return -EINVAL; 605 return -EINVAL;
611 } 606 }
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 0b66659dc516..31aa0390c777 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -49,6 +49,7 @@
49#include <linux/bootmem.h> 49#include <linux/bootmem.h>
50#include <linux/syscalls.h> 50#include <linux/syscalls.h>
51#include <linux/highmem.h> 51#include <linux/highmem.h>
52#include <linux/time.h>
52 53
53#include "power.h" 54#include "power.h"
54 55
@@ -64,10 +65,8 @@ int in_suspend __nosavedata = 0;
64 65
65#ifdef CONFIG_HIGHMEM 66#ifdef CONFIG_HIGHMEM
66unsigned int count_highmem_pages(void); 67unsigned int count_highmem_pages(void);
67int save_highmem(void);
68int restore_highmem(void); 68int restore_highmem(void);
69#else 69#else
70static inline int save_highmem(void) { return 0; }
71static inline int restore_highmem(void) { return 0; } 70static inline int restore_highmem(void) { return 0; }
72static inline unsigned int count_highmem_pages(void) { return 0; } 71static inline unsigned int count_highmem_pages(void) { return 0; }
73#endif 72#endif
@@ -134,18 +133,18 @@ static int bitmap_set(struct bitmap_page *bitmap, unsigned long bit)
134 return 0; 133 return 0;
135} 134}
136 135
137unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap) 136sector_t alloc_swapdev_block(int swap, struct bitmap_page *bitmap)
138{ 137{
139 unsigned long offset; 138 unsigned long offset;
140 139
141 offset = swp_offset(get_swap_page_of_type(swap)); 140 offset = swp_offset(get_swap_page_of_type(swap));
142 if (offset) { 141 if (offset) {
143 if (bitmap_set(bitmap, offset)) { 142 if (bitmap_set(bitmap, offset))
144 swap_free(swp_entry(swap, offset)); 143 swap_free(swp_entry(swap, offset));
145 offset = 0; 144 else
146 } 145 return swapdev_block(swap, offset);
147 } 146 }
148 return offset; 147 return 0;
149} 148}
150 149
151void free_all_swap_pages(int swap, struct bitmap_page *bitmap) 150void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
@@ -166,6 +165,34 @@ void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
166} 165}
167 166
168/** 167/**
168 * swsusp_show_speed - print the time elapsed between two events represented by
169 * @start and @stop
170 *
171 * @nr_pages - number of pages processed between @start and @stop
172 * @msg - introductory message to print
173 */
174
175void swsusp_show_speed(struct timeval *start, struct timeval *stop,
176 unsigned nr_pages, char *msg)
177{
178 s64 elapsed_centisecs64;
179 int centisecs;
180 int k;
181 int kps;
182
183 elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
184 do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
185 centisecs = elapsed_centisecs64;
186 if (centisecs == 0)
187 centisecs = 1; /* avoid div-by-zero */
188 k = nr_pages * (PAGE_SIZE / 1024);
189 kps = (k * 100) / centisecs;
190 printk("%s %d kbytes in %d.%02d seconds (%d.%02d MB/s)\n", msg, k,
191 centisecs / 100, centisecs % 100,
192 kps / 1000, (kps % 1000) / 10);
193}
194
195/**
169 * swsusp_shrink_memory - Try to free as much memory as needed 196 * swsusp_shrink_memory - Try to free as much memory as needed
170 * 197 *
171 * ... but do not OOM-kill anyone 198 * ... but do not OOM-kill anyone
@@ -184,23 +211,37 @@ static inline unsigned long __shrink_memory(long tmp)
184 211
185int swsusp_shrink_memory(void) 212int swsusp_shrink_memory(void)
186{ 213{
187 long size, tmp; 214 long tmp;
188 struct zone *zone; 215 struct zone *zone;
189 unsigned long pages = 0; 216 unsigned long pages = 0;
190 unsigned int i = 0; 217 unsigned int i = 0;
191 char *p = "-\\|/"; 218 char *p = "-\\|/";
219 struct timeval start, stop;
192 220
193 printk("Shrinking memory... "); 221 printk("Shrinking memory... ");
222 do_gettimeofday(&start);
194 do { 223 do {
195 size = 2 * count_highmem_pages(); 224 long size, highmem_size;
196 size += size / 50 + count_data_pages() + PAGES_FOR_IO; 225
226 highmem_size = count_highmem_pages();
227 size = count_data_pages() + PAGES_FOR_IO;
197 tmp = size; 228 tmp = size;
229 size += highmem_size;
198 for_each_zone (zone) 230 for_each_zone (zone)
199 if (!is_highmem(zone) && populated_zone(zone)) { 231 if (populated_zone(zone)) {
200 tmp -= zone->free_pages; 232 if (is_highmem(zone)) {
201 tmp += zone->lowmem_reserve[ZONE_NORMAL]; 233 highmem_size -= zone->free_pages;
202 tmp += snapshot_additional_pages(zone); 234 } else {
235 tmp -= zone->free_pages;
236 tmp += zone->lowmem_reserve[ZONE_NORMAL];
237 tmp += snapshot_additional_pages(zone);
238 }
203 } 239 }
240
241 if (highmem_size < 0)
242 highmem_size = 0;
243
244 tmp += highmem_size;
204 if (tmp > 0) { 245 if (tmp > 0) {
205 tmp = __shrink_memory(tmp); 246 tmp = __shrink_memory(tmp);
206 if (!tmp) 247 if (!tmp)
@@ -212,7 +253,9 @@ int swsusp_shrink_memory(void)
212 } 253 }
213 printk("\b%c", p[i++%4]); 254 printk("\b%c", p[i++%4]);
214 } while (tmp > 0); 255 } while (tmp > 0);
256 do_gettimeofday(&stop);
215 printk("\bdone (%lu pages freed)\n", pages); 257 printk("\bdone (%lu pages freed)\n", pages);
258 swsusp_show_speed(&start, &stop, pages, "Freed");
216 259
217 return 0; 260 return 0;
218} 261}
@@ -223,6 +266,7 @@ int swsusp_suspend(void)
223 266
224 if ((error = arch_prepare_suspend())) 267 if ((error = arch_prepare_suspend()))
225 return error; 268 return error;
269
226 local_irq_disable(); 270 local_irq_disable();
227 /* At this point, device_suspend() has been called, but *not* 271 /* At this point, device_suspend() has been called, but *not*
228 * device_power_down(). We *must* device_power_down() now. 272 * device_power_down(). We *must* device_power_down() now.
@@ -235,23 +279,16 @@ int swsusp_suspend(void)
235 goto Enable_irqs; 279 goto Enable_irqs;
236 } 280 }
237 281
238 if ((error = save_highmem())) {
239 printk(KERN_ERR "swsusp: Not enough free pages for highmem\n");
240 goto Restore_highmem;
241 }
242
243 save_processor_state(); 282 save_processor_state();
244 if ((error = swsusp_arch_suspend())) 283 if ((error = swsusp_arch_suspend()))
245 printk(KERN_ERR "Error %d suspending\n", error); 284 printk(KERN_ERR "Error %d suspending\n", error);
246 /* Restore control flow magically appears here */ 285 /* Restore control flow magically appears here */
247 restore_processor_state(); 286 restore_processor_state();
248Restore_highmem:
249 restore_highmem();
250 /* NOTE: device_power_up() is just a resume() for devices 287 /* NOTE: device_power_up() is just a resume() for devices
251 * that suspended with irqs off ... no overall powerup. 288 * that suspended with irqs off ... no overall powerup.
252 */ 289 */
253 device_power_up(); 290 device_power_up();
254Enable_irqs: 291 Enable_irqs:
255 local_irq_enable(); 292 local_irq_enable();
256 return error; 293 return error;
257} 294}
@@ -268,18 +305,23 @@ int swsusp_resume(void)
268 printk(KERN_ERR "Some devices failed to power down, very bad\n"); 305 printk(KERN_ERR "Some devices failed to power down, very bad\n");
269 /* We'll ignore saved state, but this gets preempt count (etc) right */ 306 /* We'll ignore saved state, but this gets preempt count (etc) right */
270 save_processor_state(); 307 save_processor_state();
271 error = swsusp_arch_resume(); 308 error = restore_highmem();
272 /* Code below is only ever reached in case of failure. Otherwise 309 if (!error) {
273 * execution continues at place where swsusp_arch_suspend was called 310 error = swsusp_arch_resume();
274 */ 311 /* The code below is only ever reached in case of a failure.
275 BUG_ON(!error); 312 * Otherwise execution continues at place where
313 * swsusp_arch_suspend() was called
314 */
315 BUG_ON(!error);
316 /* This call to restore_highmem() undos the previous one */
317 restore_highmem();
318 }
276 /* The only reason why swsusp_arch_resume() can fail is memory being 319 /* The only reason why swsusp_arch_resume() can fail is memory being
277 * very tight, so we have to free it as soon as we can to avoid 320 * very tight, so we have to free it as soon as we can to avoid
278 * subsequent failures 321 * subsequent failures
279 */ 322 */
280 swsusp_free(); 323 swsusp_free();
281 restore_processor_state(); 324 restore_processor_state();
282 restore_highmem();
283 touch_softlockup_watchdog(); 325 touch_softlockup_watchdog();
284 device_power_up(); 326 device_power_up();
285 local_irq_enable(); 327 local_irq_enable();
diff --git a/kernel/power/user.c b/kernel/power/user.c
index d991d3b0e5a4..89443b85163b 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/suspend.h> 12#include <linux/suspend.h>
13#include <linux/syscalls.h> 13#include <linux/syscalls.h>
14#include <linux/reboot.h>
14#include <linux/string.h> 15#include <linux/string.h>
15#include <linux/device.h> 16#include <linux/device.h>
16#include <linux/miscdevice.h> 17#include <linux/miscdevice.h>
@@ -21,6 +22,7 @@
21#include <linux/fs.h> 22#include <linux/fs.h>
22#include <linux/console.h> 23#include <linux/console.h>
23#include <linux/cpu.h> 24#include <linux/cpu.h>
25#include <linux/freezer.h>
24 26
25#include <asm/uaccess.h> 27#include <asm/uaccess.h>
26 28
@@ -54,7 +56,8 @@ static int snapshot_open(struct inode *inode, struct file *filp)
54 filp->private_data = data; 56 filp->private_data = data;
55 memset(&data->handle, 0, sizeof(struct snapshot_handle)); 57 memset(&data->handle, 0, sizeof(struct snapshot_handle));
56 if ((filp->f_flags & O_ACCMODE) == O_RDONLY) { 58 if ((filp->f_flags & O_ACCMODE) == O_RDONLY) {
57 data->swap = swsusp_resume_device ? swap_type_of(swsusp_resume_device) : -1; 59 data->swap = swsusp_resume_device ?
60 swap_type_of(swsusp_resume_device, 0) : -1;
58 data->mode = O_RDONLY; 61 data->mode = O_RDONLY;
59 } else { 62 } else {
60 data->swap = -1; 63 data->swap = -1;
@@ -76,10 +79,10 @@ static int snapshot_release(struct inode *inode, struct file *filp)
76 free_all_swap_pages(data->swap, data->bitmap); 79 free_all_swap_pages(data->swap, data->bitmap);
77 free_bitmap(data->bitmap); 80 free_bitmap(data->bitmap);
78 if (data->frozen) { 81 if (data->frozen) {
79 down(&pm_sem); 82 mutex_lock(&pm_mutex);
80 thaw_processes(); 83 thaw_processes();
81 enable_nonboot_cpus(); 84 enable_nonboot_cpus();
82 up(&pm_sem); 85 mutex_unlock(&pm_mutex);
83 } 86 }
84 atomic_inc(&device_available); 87 atomic_inc(&device_available);
85 return 0; 88 return 0;
@@ -124,7 +127,8 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
124{ 127{
125 int error = 0; 128 int error = 0;
126 struct snapshot_data *data; 129 struct snapshot_data *data;
127 loff_t offset, avail; 130 loff_t avail;
131 sector_t offset;
128 132
129 if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC) 133 if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
130 return -ENOTTY; 134 return -ENOTTY;
@@ -140,7 +144,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
140 case SNAPSHOT_FREEZE: 144 case SNAPSHOT_FREEZE:
141 if (data->frozen) 145 if (data->frozen)
142 break; 146 break;
143 down(&pm_sem); 147 mutex_lock(&pm_mutex);
144 error = disable_nonboot_cpus(); 148 error = disable_nonboot_cpus();
145 if (!error) { 149 if (!error) {
146 error = freeze_processes(); 150 error = freeze_processes();
@@ -150,7 +154,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
150 error = -EBUSY; 154 error = -EBUSY;
151 } 155 }
152 } 156 }
153 up(&pm_sem); 157 mutex_unlock(&pm_mutex);
154 if (!error) 158 if (!error)
155 data->frozen = 1; 159 data->frozen = 1;
156 break; 160 break;
@@ -158,10 +162,10 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
158 case SNAPSHOT_UNFREEZE: 162 case SNAPSHOT_UNFREEZE:
159 if (!data->frozen) 163 if (!data->frozen)
160 break; 164 break;
161 down(&pm_sem); 165 mutex_lock(&pm_mutex);
162 thaw_processes(); 166 thaw_processes();
163 enable_nonboot_cpus(); 167 enable_nonboot_cpus();
164 up(&pm_sem); 168 mutex_unlock(&pm_mutex);
165 data->frozen = 0; 169 data->frozen = 0;
166 break; 170 break;
167 171
@@ -170,7 +174,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
170 error = -EPERM; 174 error = -EPERM;
171 break; 175 break;
172 } 176 }
173 down(&pm_sem); 177 mutex_lock(&pm_mutex);
174 /* Free memory before shutting down devices. */ 178 /* Free memory before shutting down devices. */
175 error = swsusp_shrink_memory(); 179 error = swsusp_shrink_memory();
176 if (!error) { 180 if (!error) {
@@ -183,7 +187,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
183 } 187 }
184 resume_console(); 188 resume_console();
185 } 189 }
186 up(&pm_sem); 190 mutex_unlock(&pm_mutex);
187 if (!error) 191 if (!error)
188 error = put_user(in_suspend, (unsigned int __user *)arg); 192 error = put_user(in_suspend, (unsigned int __user *)arg);
189 if (!error) 193 if (!error)
@@ -191,13 +195,13 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
191 break; 195 break;
192 196
193 case SNAPSHOT_ATOMIC_RESTORE: 197 case SNAPSHOT_ATOMIC_RESTORE:
198 snapshot_write_finalize(&data->handle);
194 if (data->mode != O_WRONLY || !data->frozen || 199 if (data->mode != O_WRONLY || !data->frozen ||
195 !snapshot_image_loaded(&data->handle)) { 200 !snapshot_image_loaded(&data->handle)) {
196 error = -EPERM; 201 error = -EPERM;
197 break; 202 break;
198 } 203 }
199 snapshot_free_unused_memory(&data->handle); 204 mutex_lock(&pm_mutex);
200 down(&pm_sem);
201 pm_prepare_console(); 205 pm_prepare_console();
202 suspend_console(); 206 suspend_console();
203 error = device_suspend(PMSG_PRETHAW); 207 error = device_suspend(PMSG_PRETHAW);
@@ -207,7 +211,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
207 } 211 }
208 resume_console(); 212 resume_console();
209 pm_restore_console(); 213 pm_restore_console();
210 up(&pm_sem); 214 mutex_unlock(&pm_mutex);
211 break; 215 break;
212 216
213 case SNAPSHOT_FREE: 217 case SNAPSHOT_FREE:
@@ -238,10 +242,10 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
238 break; 242 break;
239 } 243 }
240 } 244 }
241 offset = alloc_swap_page(data->swap, data->bitmap); 245 offset = alloc_swapdev_block(data->swap, data->bitmap);
242 if (offset) { 246 if (offset) {
243 offset <<= PAGE_SHIFT; 247 offset <<= PAGE_SHIFT;
244 error = put_user(offset, (loff_t __user *)arg); 248 error = put_user(offset, (sector_t __user *)arg);
245 } else { 249 } else {
246 error = -ENOSPC; 250 error = -ENOSPC;
247 } 251 }
@@ -264,7 +268,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
264 * so we need to recode them 268 * so we need to recode them
265 */ 269 */
266 if (old_decode_dev(arg)) { 270 if (old_decode_dev(arg)) {
267 data->swap = swap_type_of(old_decode_dev(arg)); 271 data->swap = swap_type_of(old_decode_dev(arg), 0);
268 if (data->swap < 0) 272 if (data->swap < 0)
269 error = -ENODEV; 273 error = -ENODEV;
270 } else { 274 } else {
@@ -282,7 +286,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
282 break; 286 break;
283 } 287 }
284 288
285 if (down_trylock(&pm_sem)) { 289 if (!mutex_trylock(&pm_mutex)) {
286 error = -EBUSY; 290 error = -EBUSY;
287 break; 291 break;
288 } 292 }
@@ -309,8 +313,66 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
309 if (pm_ops->finish) 313 if (pm_ops->finish)
310 pm_ops->finish(PM_SUSPEND_MEM); 314 pm_ops->finish(PM_SUSPEND_MEM);
311 315
312OutS3: 316 OutS3:
313 up(&pm_sem); 317 mutex_unlock(&pm_mutex);
318 break;
319
320 case SNAPSHOT_PMOPS:
321 switch (arg) {
322
323 case PMOPS_PREPARE:
324 if (pm_ops->prepare) {
325 error = pm_ops->prepare(PM_SUSPEND_DISK);
326 }
327 break;
328
329 case PMOPS_ENTER:
330 kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
331 error = pm_ops->enter(PM_SUSPEND_DISK);
332 break;
333
334 case PMOPS_FINISH:
335 if (pm_ops && pm_ops->finish) {
336 pm_ops->finish(PM_SUSPEND_DISK);
337 }
338 break;
339
340 default:
341 printk(KERN_ERR "SNAPSHOT_PMOPS: invalid argument %ld\n", arg);
342 error = -EINVAL;
343
344 }
345 break;
346
347 case SNAPSHOT_SET_SWAP_AREA:
348 if (data->bitmap) {
349 error = -EPERM;
350 } else {
351 struct resume_swap_area swap_area;
352 dev_t swdev;
353
354 error = copy_from_user(&swap_area, (void __user *)arg,
355 sizeof(struct resume_swap_area));
356 if (error) {
357 error = -EFAULT;
358 break;
359 }
360
361 /*
362 * User space encodes device types as two-byte values,
363 * so we need to recode them
364 */
365 swdev = old_decode_dev(swap_area.dev);
366 if (swdev) {
367 offset = swap_area.offset;
368 data->swap = swap_type_of(swdev, offset);
369 if (data->swap < 0)
370 error = -ENODEV;
371 } else {
372 data->swap = -1;
373 error = -EINVAL;
374 }
375 }
314 break; 376 break;
315 377
316 default: 378 default:
@@ -321,7 +383,7 @@ OutS3:
321 return error; 383 return error;
322} 384}
323 385
324static struct file_operations snapshot_fops = { 386static const struct file_operations snapshot_fops = {
325 .open = snapshot_open, 387 .open = snapshot_open,
326 .release = snapshot_release, 388 .release = snapshot_release,
327 .read = snapshot_read, 389 .read = snapshot_read,
diff --git a/kernel/printk.c b/kernel/printk.c
index 66426552fbfe..185bb45eacf7 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -53,8 +53,6 @@ int console_printk[4] = {
53 DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */ 53 DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */
54}; 54};
55 55
56EXPORT_UNUSED_SYMBOL(console_printk); /* June 2006 */
57
58/* 56/*
59 * Low lever drivers may need that to know if they can schedule in 57 * Low lever drivers may need that to know if they can schedule in
60 * their unblank() callback or not. So let's export it. 58 * their unblank() callback or not. So let's export it.
@@ -335,13 +333,25 @@ static void __call_console_drivers(unsigned long start, unsigned long end)
335 } 333 }
336} 334}
337 335
336static int __read_mostly ignore_loglevel;
337
338int __init ignore_loglevel_setup(char *str)
339{
340 ignore_loglevel = 1;
341 printk(KERN_INFO "debug: ignoring loglevel setting.\n");
342
343 return 1;
344}
345
346__setup("ignore_loglevel", ignore_loglevel_setup);
347
338/* 348/*
339 * Write out chars from start to end - 1 inclusive 349 * Write out chars from start to end - 1 inclusive
340 */ 350 */
341static void _call_console_drivers(unsigned long start, 351static void _call_console_drivers(unsigned long start,
342 unsigned long end, int msg_log_level) 352 unsigned long end, int msg_log_level)
343{ 353{
344 if (msg_log_level < console_loglevel && 354 if ((msg_log_level < console_loglevel || ignore_loglevel) &&
345 console_drivers && start != end) { 355 console_drivers && start != end) {
346 if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) { 356 if ((start & LOG_BUF_MASK) > (end & LOG_BUF_MASK)) {
347 /* wrapped write */ 357 /* wrapped write */
@@ -631,12 +641,7 @@ EXPORT_SYMBOL(vprintk);
631 641
632asmlinkage long sys_syslog(int type, char __user *buf, int len) 642asmlinkage long sys_syslog(int type, char __user *buf, int len)
633{ 643{
634 return 0; 644 return -ENOSYS;
635}
636
637int do_syslog(int type, char __user *buf, int len)
638{
639 return 0;
640} 645}
641 646
642static void call_console_drivers(unsigned long start, unsigned long end) 647static void call_console_drivers(unsigned long start, unsigned long end)
@@ -777,7 +782,6 @@ int is_console_locked(void)
777{ 782{
778 return console_locked; 783 return console_locked;
779} 784}
780EXPORT_UNUSED_SYMBOL(is_console_locked); /* June 2006 */
781 785
782/** 786/**
783 * release_console_sem - unlock the console system 787 * release_console_sem - unlock the console system
diff --git a/kernel/profile.c b/kernel/profile.c
index f940b462eec9..fb5e03d57e9d 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -40,7 +40,7 @@ int (*timer_hook)(struct pt_regs *) __read_mostly;
40 40
41static atomic_t *prof_buffer; 41static atomic_t *prof_buffer;
42static unsigned long prof_len, prof_shift; 42static unsigned long prof_len, prof_shift;
43static int prof_on __read_mostly; 43int prof_on __read_mostly;
44static cpumask_t prof_cpu_mask = CPU_MASK_ALL; 44static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
45#ifdef CONFIG_SMP 45#ifdef CONFIG_SMP
46static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits); 46static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
@@ -51,9 +51,19 @@ static DEFINE_MUTEX(profile_flip_mutex);
51static int __init profile_setup(char * str) 51static int __init profile_setup(char * str)
52{ 52{
53 static char __initdata schedstr[] = "schedule"; 53 static char __initdata schedstr[] = "schedule";
54 static char __initdata sleepstr[] = "sleep";
54 int par; 55 int par;
55 56
56 if (!strncmp(str, schedstr, strlen(schedstr))) { 57 if (!strncmp(str, sleepstr, strlen(sleepstr))) {
58 prof_on = SLEEP_PROFILING;
59 if (str[strlen(sleepstr)] == ',')
60 str += strlen(sleepstr) + 1;
61 if (get_option(&str, &par))
62 prof_shift = par;
63 printk(KERN_INFO
64 "kernel sleep profiling enabled (shift: %ld)\n",
65 prof_shift);
66 } else if (!strncmp(str, sleepstr, strlen(sleepstr))) {
57 prof_on = SCHED_PROFILING; 67 prof_on = SCHED_PROFILING;
58 if (str[strlen(schedstr)] == ',') 68 if (str[strlen(schedstr)] == ',')
59 str += strlen(schedstr) + 1; 69 str += strlen(schedstr) + 1;
@@ -204,7 +214,8 @@ EXPORT_SYMBOL_GPL(profile_event_unregister);
204 * positions to which hits are accounted during short intervals (e.g. 214 * positions to which hits are accounted during short intervals (e.g.
205 * several seconds) is usually very small. Exclusion from buffer 215 * several seconds) is usually very small. Exclusion from buffer
206 * flipping is provided by interrupt disablement (note that for 216 * flipping is provided by interrupt disablement (note that for
207 * SCHED_PROFILING profile_hit() may be called from process context). 217 * SCHED_PROFILING or SLEEP_PROFILING profile_hit() may be called from
218 * process context).
208 * The hash function is meant to be lightweight as opposed to strong, 219 * The hash function is meant to be lightweight as opposed to strong,
209 * and was vaguely inspired by ppc64 firmware-supported inverted 220 * and was vaguely inspired by ppc64 firmware-supported inverted
210 * pagetable hash functions, but uses a full hashtable full of finite 221 * pagetable hash functions, but uses a full hashtable full of finite
@@ -257,7 +268,7 @@ static void profile_discard_flip_buffers(void)
257 mutex_unlock(&profile_flip_mutex); 268 mutex_unlock(&profile_flip_mutex);
258} 269}
259 270
260void profile_hit(int type, void *__pc) 271void profile_hits(int type, void *__pc, unsigned int nr_hits)
261{ 272{
262 unsigned long primary, secondary, flags, pc = (unsigned long)__pc; 273 unsigned long primary, secondary, flags, pc = (unsigned long)__pc;
263 int i, j, cpu; 274 int i, j, cpu;
@@ -274,21 +285,31 @@ void profile_hit(int type, void *__pc)
274 put_cpu(); 285 put_cpu();
275 return; 286 return;
276 } 287 }
288 /*
289 * We buffer the global profiler buffer into a per-CPU
290 * queue and thus reduce the number of global (and possibly
291 * NUMA-alien) accesses. The write-queue is self-coalescing:
292 */
277 local_irq_save(flags); 293 local_irq_save(flags);
278 do { 294 do {
279 for (j = 0; j < PROFILE_GRPSZ; ++j) { 295 for (j = 0; j < PROFILE_GRPSZ; ++j) {
280 if (hits[i + j].pc == pc) { 296 if (hits[i + j].pc == pc) {
281 hits[i + j].hits++; 297 hits[i + j].hits += nr_hits;
282 goto out; 298 goto out;
283 } else if (!hits[i + j].hits) { 299 } else if (!hits[i + j].hits) {
284 hits[i + j].pc = pc; 300 hits[i + j].pc = pc;
285 hits[i + j].hits = 1; 301 hits[i + j].hits = nr_hits;
286 goto out; 302 goto out;
287 } 303 }
288 } 304 }
289 i = (i + secondary) & (NR_PROFILE_HIT - 1); 305 i = (i + secondary) & (NR_PROFILE_HIT - 1);
290 } while (i != primary); 306 } while (i != primary);
291 atomic_inc(&prof_buffer[pc]); 307
308 /*
309 * Add the current hit(s) and flush the write-queue out
310 * to the global buffer:
311 */
312 atomic_add(nr_hits, &prof_buffer[pc]);
292 for (i = 0; i < NR_PROFILE_HIT; ++i) { 313 for (i = 0; i < NR_PROFILE_HIT; ++i) {
293 atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]); 314 atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
294 hits[i].pc = hits[i].hits = 0; 315 hits[i].pc = hits[i].hits = 0;
@@ -298,7 +319,6 @@ out:
298 put_cpu(); 319 put_cpu();
299} 320}
300 321
301#ifdef CONFIG_HOTPLUG_CPU
302static int __devinit profile_cpu_callback(struct notifier_block *info, 322static int __devinit profile_cpu_callback(struct notifier_block *info,
303 unsigned long action, void *__cpu) 323 unsigned long action, void *__cpu)
304{ 324{
@@ -351,19 +371,19 @@ static int __devinit profile_cpu_callback(struct notifier_block *info,
351 } 371 }
352 return NOTIFY_OK; 372 return NOTIFY_OK;
353} 373}
354#endif /* CONFIG_HOTPLUG_CPU */
355#else /* !CONFIG_SMP */ 374#else /* !CONFIG_SMP */
356#define profile_flip_buffers() do { } while (0) 375#define profile_flip_buffers() do { } while (0)
357#define profile_discard_flip_buffers() do { } while (0) 376#define profile_discard_flip_buffers() do { } while (0)
377#define profile_cpu_callback NULL
358 378
359void profile_hit(int type, void *__pc) 379void profile_hits(int type, void *__pc, unsigned int nr_hits)
360{ 380{
361 unsigned long pc; 381 unsigned long pc;
362 382
363 if (prof_on != type || !prof_buffer) 383 if (prof_on != type || !prof_buffer)
364 return; 384 return;
365 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift; 385 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
366 atomic_inc(&prof_buffer[min(pc, prof_len - 1)]); 386 atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
367} 387}
368#endif /* !CONFIG_SMP */ 388#endif /* !CONFIG_SMP */
369 389
@@ -442,7 +462,8 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
442 read = 0; 462 read = 0;
443 463
444 while (p < sizeof(unsigned int) && count > 0) { 464 while (p < sizeof(unsigned int) && count > 0) {
445 put_user(*((char *)(&sample_step)+p),buf); 465 if (put_user(*((char *)(&sample_step)+p),buf))
466 return -EFAULT;
446 buf++; p++; count--; read++; 467 buf++; p++; count--; read++;
447 } 468 }
448 pnt = (char *)prof_buffer + p - sizeof(atomic_t); 469 pnt = (char *)prof_buffer + p - sizeof(atomic_t);
@@ -480,7 +501,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
480 return count; 501 return count;
481} 502}
482 503
483static struct file_operations proc_profile_operations = { 504static const struct file_operations proc_profile_operations = {
484 .read = read_profile, 505 .read = read_profile,
485 .write = write_profile, 506 .write = write_profile,
486}; 507};
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index 26bb5ffe1ef1..3554b76da84c 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -235,12 +235,14 @@ static void rcu_do_batch(struct rcu_data *rdp)
235 235
236 list = rdp->donelist; 236 list = rdp->donelist;
237 while (list) { 237 while (list) {
238 next = rdp->donelist = list->next; 238 next = list->next;
239 prefetch(next);
239 list->func(list); 240 list->func(list);
240 list = next; 241 list = next;
241 if (++count >= rdp->blimit) 242 if (++count >= rdp->blimit)
242 break; 243 break;
243 } 244 }
245 rdp->donelist = list;
244 246
245 local_irq_disable(); 247 local_irq_disable();
246 rdp->qlen -= count; 248 rdp->qlen -= count;
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index e2bda18f6f42..c52f981ea008 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -401,7 +401,7 @@ static void srcu_torture_cleanup(void)
401 cleanup_srcu_struct(&srcu_ctl); 401 cleanup_srcu_struct(&srcu_ctl);
402} 402}
403 403
404static int srcu_torture_read_lock(void) 404static int srcu_torture_read_lock(void) __acquires(&srcu_ctl)
405{ 405{
406 return srcu_read_lock(&srcu_ctl); 406 return srcu_read_lock(&srcu_ctl);
407} 407}
@@ -419,7 +419,7 @@ static void srcu_read_delay(struct rcu_random_state *rrsp)
419 schedule_timeout_interruptible(longdelay); 419 schedule_timeout_interruptible(longdelay);
420} 420}
421 421
422static void srcu_torture_read_unlock(int idx) 422static void srcu_torture_read_unlock(int idx) __releases(&srcu_ctl)
423{ 423{
424 srcu_read_unlock(&srcu_ctl, idx); 424 srcu_read_unlock(&srcu_ctl, idx);
425} 425}
diff --git a/kernel/relay.c b/kernel/relay.c
index 2b92e8ece85b..75a3a9a7efc2 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1013,7 +1013,7 @@ static ssize_t relay_file_sendfile(struct file *filp,
1013 actor, &desc); 1013 actor, &desc);
1014} 1014}
1015 1015
1016struct file_operations relay_file_operations = { 1016const struct file_operations relay_file_operations = {
1017 .open = relay_file_open, 1017 .open = relay_file_open,
1018 .poll = relay_file_poll, 1018 .poll = relay_file_poll,
1019 .mmap = relay_file_mmap, 1019 .mmap = relay_file_mmap,
diff --git a/kernel/resource.c b/kernel/resource.c
index 6de60c12143e..7b9a497419d9 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -88,7 +88,7 @@ static int r_show(struct seq_file *m, void *v)
88 return 0; 88 return 0;
89} 89}
90 90
91static struct seq_operations resource_op = { 91static const struct seq_operations resource_op = {
92 .start = r_start, 92 .start = r_start,
93 .next = r_next, 93 .next = r_next,
94 .stop = r_stop, 94 .stop = r_stop,
@@ -115,14 +115,14 @@ static int iomem_open(struct inode *inode, struct file *file)
115 return res; 115 return res;
116} 116}
117 117
118static struct file_operations proc_ioports_operations = { 118static const struct file_operations proc_ioports_operations = {
119 .open = ioports_open, 119 .open = ioports_open,
120 .read = seq_read, 120 .read = seq_read,
121 .llseek = seq_lseek, 121 .llseek = seq_lseek,
122 .release = seq_release, 122 .release = seq_release,
123}; 123};
124 124
125static struct file_operations proc_iomem_operations = { 125static const struct file_operations proc_iomem_operations = {
126 .open = iomem_open, 126 .open = iomem_open,
127 .read = seq_read, 127 .read = seq_read,
128 .llseek = seq_lseek, 128 .llseek = seq_lseek,
diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
index 6dcea9dd8c94..015fc633c96c 100644
--- a/kernel/rtmutex-tester.c
+++ b/kernel/rtmutex-tester.c
@@ -13,6 +13,7 @@
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14#include <linux/sysdev.h> 14#include <linux/sysdev.h>
15#include <linux/timer.h> 15#include <linux/timer.h>
16#include <linux/freezer.h>
16 17
17#include "rtmutex.h" 18#include "rtmutex.h"
18 19
diff --git a/kernel/sched.c b/kernel/sched.c
index 3399701c680e..f385eff4682d 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -34,7 +34,7 @@
34#include <linux/security.h> 34#include <linux/security.h>
35#include <linux/notifier.h> 35#include <linux/notifier.h>
36#include <linux/profile.h> 36#include <linux/profile.h>
37#include <linux/suspend.h> 37#include <linux/freezer.h>
38#include <linux/vmalloc.h> 38#include <linux/vmalloc.h>
39#include <linux/blkdev.h> 39#include <linux/blkdev.h>
40#include <linux/delay.h> 40#include <linux/delay.h>
@@ -505,7 +505,7 @@ static int schedstat_open(struct inode *inode, struct file *file)
505 return res; 505 return res;
506} 506}
507 507
508struct file_operations proc_schedstat_operations = { 508const struct file_operations proc_schedstat_operations = {
509 .open = schedstat_open, 509 .open = schedstat_open,
510 .read = seq_read, 510 .read = seq_read,
511 .llseek = seq_lseek, 511 .llseek = seq_lseek,
@@ -948,6 +948,17 @@ static void activate_task(struct task_struct *p, struct rq *rq, int local)
948 } 948 }
949#endif 949#endif
950 950
951 /*
952 * Sleep time is in units of nanosecs, so shift by 20 to get a
953 * milliseconds-range estimation of the amount of time that the task
954 * spent sleeping:
955 */
956 if (unlikely(prof_on == SLEEP_PROFILING)) {
957 if (p->state == TASK_UNINTERRUPTIBLE)
958 profile_hits(SLEEP_PROFILING, (void *)get_wchan(p),
959 (now - p->timestamp) >> 20);
960 }
961
951 if (!rt_task(p)) 962 if (!rt_task(p))
952 p->prio = recalc_task_prio(p, now); 963 p->prio = recalc_task_prio(p, now);
953 964
@@ -3333,6 +3344,7 @@ asmlinkage void __sched schedule(void)
3333 printk(KERN_ERR "BUG: scheduling while atomic: " 3344 printk(KERN_ERR "BUG: scheduling while atomic: "
3334 "%s/0x%08x/%d\n", 3345 "%s/0x%08x/%d\n",
3335 current->comm, preempt_count(), current->pid); 3346 current->comm, preempt_count(), current->pid);
3347 debug_show_held_locks(current);
3336 dump_stack(); 3348 dump_stack();
3337 } 3349 }
3338 profile_hit(SCHED_PROFILING, __builtin_return_address(0)); 3350 profile_hit(SCHED_PROFILING, __builtin_return_address(0));
@@ -4804,18 +4816,18 @@ static void show_task(struct task_struct *p)
4804 show_stack(p, NULL); 4816 show_stack(p, NULL);
4805} 4817}
4806 4818
4807void show_state(void) 4819void show_state_filter(unsigned long state_filter)
4808{ 4820{
4809 struct task_struct *g, *p; 4821 struct task_struct *g, *p;
4810 4822
4811#if (BITS_PER_LONG == 32) 4823#if (BITS_PER_LONG == 32)
4812 printk("\n" 4824 printk("\n"
4813 " sibling\n"); 4825 " free sibling\n");
4814 printk(" task PC pid father child younger older\n"); 4826 printk(" task PC stack pid father child younger older\n");
4815#else 4827#else
4816 printk("\n" 4828 printk("\n"
4817 " sibling\n"); 4829 " free sibling\n");
4818 printk(" task PC pid father child younger older\n"); 4830 printk(" task PC stack pid father child younger older\n");
4819#endif 4831#endif
4820 read_lock(&tasklist_lock); 4832 read_lock(&tasklist_lock);
4821 do_each_thread(g, p) { 4833 do_each_thread(g, p) {
@@ -4824,11 +4836,16 @@ void show_state(void)
4824 * console might take alot of time: 4836 * console might take alot of time:
4825 */ 4837 */
4826 touch_nmi_watchdog(); 4838 touch_nmi_watchdog();
4827 show_task(p); 4839 if (p->state & state_filter)
4840 show_task(p);
4828 } while_each_thread(g, p); 4841 } while_each_thread(g, p);
4829 4842
4830 read_unlock(&tasklist_lock); 4843 read_unlock(&tasklist_lock);
4831 debug_show_all_locks(); 4844 /*
4845 * Only show locks if all tasks are dumped:
4846 */
4847 if (state_filter == -1)
4848 debug_show_all_locks();
4832} 4849}
4833 4850
4834/** 4851/**
@@ -6723,8 +6740,6 @@ SYSDEV_ATTR(sched_smt_power_savings, 0644, sched_smt_power_savings_show,
6723 sched_smt_power_savings_store); 6740 sched_smt_power_savings_store);
6724#endif 6741#endif
6725 6742
6726
6727#ifdef CONFIG_HOTPLUG_CPU
6728/* 6743/*
6729 * Force a reinitialization of the sched domains hierarchy. The domains 6744 * Force a reinitialization of the sched domains hierarchy. The domains
6730 * and groups cannot be updated in place without racing with the balancing 6745 * and groups cannot be updated in place without racing with the balancing
@@ -6757,7 +6772,6 @@ static int update_sched_domains(struct notifier_block *nfb,
6757 6772
6758 return NOTIFY_OK; 6773 return NOTIFY_OK;
6759} 6774}
6760#endif
6761 6775
6762void __init sched_init_smp(void) 6776void __init sched_init_smp(void)
6763{ 6777{
@@ -6867,6 +6881,7 @@ void __might_sleep(char *file, int line)
6867 " context at %s:%d\n", file, line); 6881 " context at %s:%d\n", file, line);
6868 printk("in_atomic():%d, irqs_disabled():%d\n", 6882 printk("in_atomic():%d, irqs_disabled():%d\n",
6869 in_atomic(), irqs_disabled()); 6883 in_atomic(), irqs_disabled());
6884 debug_show_held_locks(current);
6870 dump_stack(); 6885 dump_stack();
6871 } 6886 }
6872#endif 6887#endif
diff --git a/kernel/signal.c b/kernel/signal.c
index df18c167a2a7..ec81defde339 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -23,6 +23,7 @@
23#include <linux/ptrace.h> 23#include <linux/ptrace.h>
24#include <linux/signal.h> 24#include <linux/signal.h>
25#include <linux/capability.h> 25#include <linux/capability.h>
26#include <linux/freezer.h>
26#include <asm/param.h> 27#include <asm/param.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28#include <asm/unistd.h> 29#include <asm/unistd.h>
@@ -33,7 +34,7 @@
33 * SLAB caches for signal bits. 34 * SLAB caches for signal bits.
34 */ 35 */
35 36
36static kmem_cache_t *sigqueue_cachep; 37static struct kmem_cache *sigqueue_cachep;
37 38
38/* 39/*
39 * In POSIX a signal is sent either to a specific thread (Linux task) 40 * In POSIX a signal is sent either to a specific thread (Linux task)
@@ -1133,8 +1134,7 @@ int kill_pid_info(int sig, struct siginfo *info, struct pid *pid)
1133 return error; 1134 return error;
1134} 1135}
1135 1136
1136int 1137static int kill_proc_info(int sig, struct siginfo *info, pid_t pid)
1137kill_proc_info(int sig, struct siginfo *info, pid_t pid)
1138{ 1138{
1139 int error; 1139 int error;
1140 rcu_read_lock(); 1140 rcu_read_lock();
diff --git a/kernel/softirq.c b/kernel/softirq.c
index bf25015dce16..918e52df090e 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -574,8 +574,6 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
574 574
575 switch (action) { 575 switch (action) {
576 case CPU_UP_PREPARE: 576 case CPU_UP_PREPARE:
577 BUG_ON(per_cpu(tasklet_vec, hotcpu).list);
578 BUG_ON(per_cpu(tasklet_hi_vec, hotcpu).list);
579 p = kthread_create(ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu); 577 p = kthread_create(ksoftirqd, hcpu, "ksoftirqd/%d", hotcpu);
580 if (IS_ERR(p)) { 578 if (IS_ERR(p)) {
581 printk("ksoftirqd for %i failed\n", hotcpu); 579 printk("ksoftirqd for %i failed\n", hotcpu);
diff --git a/kernel/sys.c b/kernel/sys.c
index c87b461de38d..a0c1a29a507f 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1102,14 +1102,14 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid)
1102asmlinkage long sys_setuid(uid_t uid) 1102asmlinkage long sys_setuid(uid_t uid)
1103{ 1103{
1104 int old_euid = current->euid; 1104 int old_euid = current->euid;
1105 int old_ruid, old_suid, new_ruid, new_suid; 1105 int old_ruid, old_suid, new_suid;
1106 int retval; 1106 int retval;
1107 1107
1108 retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID); 1108 retval = security_task_setuid(uid, (uid_t)-1, (uid_t)-1, LSM_SETID_ID);
1109 if (retval) 1109 if (retval)
1110 return retval; 1110 return retval;
1111 1111
1112 old_ruid = new_ruid = current->uid; 1112 old_ruid = current->uid;
1113 old_suid = current->suid; 1113 old_suid = current->suid;
1114 new_suid = old_suid; 1114 new_suid = old_suid;
1115 1115
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 09e569f4792b..8e9f00fd6d18 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -54,6 +54,7 @@ extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
54 54
55#ifdef CONFIG_X86 55#ifdef CONFIG_X86
56#include <asm/nmi.h> 56#include <asm/nmi.h>
57#include <asm/stacktrace.h>
57#endif 58#endif
58 59
59#if defined(CONFIG_SYSCTL) 60#if defined(CONFIG_SYSCTL)
@@ -170,7 +171,7 @@ static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
170static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *); 171static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
171static int proc_opensys(struct inode *, struct file *); 172static int proc_opensys(struct inode *, struct file *);
172 173
173struct file_operations proc_sys_file_operations = { 174const struct file_operations proc_sys_file_operations = {
174 .open = proc_opensys, 175 .open = proc_opensys,
175 .read = proc_readsys, 176 .read = proc_readsys,
176 .write = proc_writesys, 177 .write = proc_writesys,
@@ -707,6 +708,14 @@ static ctl_table kern_table[] = {
707 .mode = 0444, 708 .mode = 0444,
708 .proc_handler = &proc_dointvec, 709 .proc_handler = &proc_dointvec,
709 }, 710 },
711 {
712 .ctl_name = CTL_UNNUMBERED,
713 .procname = "kstack_depth_to_print",
714 .data = &kstack_depth_to_print,
715 .maxlen = sizeof(int),
716 .mode = 0644,
717 .proc_handler = &proc_dointvec,
718 },
710#endif 719#endif
711#if defined(CONFIG_MMU) 720#if defined(CONFIG_MMU)
712 { 721 {
@@ -977,17 +986,6 @@ static ctl_table vm_table[] = {
977 .extra1 = &zero, 986 .extra1 = &zero,
978 }, 987 },
979#endif 988#endif
980#ifdef CONFIG_SWAP
981 {
982 .ctl_name = VM_SWAP_TOKEN_TIMEOUT,
983 .procname = "swap_token_timeout",
984 .data = &swap_token_default_timeout,
985 .maxlen = sizeof(swap_token_default_timeout),
986 .mode = 0644,
987 .proc_handler = &proc_dointvec_jiffies,
988 .strategy = &sysctl_jiffies,
989 },
990#endif
991#ifdef CONFIG_NUMA 989#ifdef CONFIG_NUMA
992 { 990 {
993 .ctl_name = VM_ZONE_RECLAIM_MODE, 991 .ctl_name = VM_ZONE_RECLAIM_MODE,
@@ -1886,7 +1884,7 @@ static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
1886 p = buf; 1884 p = buf;
1887 if (*p == '-' && left > 1) { 1885 if (*p == '-' && left > 1) {
1888 neg = 1; 1886 neg = 1;
1889 left--, p++; 1887 p++;
1890 } 1888 }
1891 if (*p < '0' || *p > '9') 1889 if (*p < '0' || *p > '9')
1892 break; 1890 break;
@@ -2137,7 +2135,7 @@ static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
2137 p = buf; 2135 p = buf;
2138 if (*p == '-' && left > 1) { 2136 if (*p == '-' && left > 1) {
2139 neg = 1; 2137 neg = 1;
2140 left--, p++; 2138 p++;
2141 } 2139 }
2142 if (*p < '0' || *p > '9') 2140 if (*p < '0' || *p > '9')
2143 break; 2141 break;
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index d3d28919d4b4..4c3476fa058d 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -34,7 +34,7 @@
34 34
35static DEFINE_PER_CPU(__u32, taskstats_seqnum) = { 0 }; 35static DEFINE_PER_CPU(__u32, taskstats_seqnum) = { 0 };
36static int family_registered; 36static int family_registered;
37kmem_cache_t *taskstats_cache; 37struct kmem_cache *taskstats_cache;
38 38
39static struct genl_family family = { 39static struct genl_family family = {
40 .id = GENL_ID_GENERATE, 40 .id = GENL_ID_GENERATE,
@@ -69,7 +69,7 @@ enum actions {
69}; 69};
70 70
71static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp, 71static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
72 void **replyp, size_t size) 72 size_t size)
73{ 73{
74 struct sk_buff *skb; 74 struct sk_buff *skb;
75 void *reply; 75 void *reply;
@@ -94,7 +94,6 @@ static int prepare_reply(struct genl_info *info, u8 cmd, struct sk_buff **skbp,
94 } 94 }
95 95
96 *skbp = skb; 96 *skbp = skb;
97 *replyp = reply;
98 return 0; 97 return 0;
99} 98}
100 99
@@ -119,10 +118,10 @@ static int send_reply(struct sk_buff *skb, pid_t pid)
119/* 118/*
120 * Send taskstats data in @skb to listeners registered for @cpu's exit data 119 * Send taskstats data in @skb to listeners registered for @cpu's exit data
121 */ 120 */
122static void send_cpu_listeners(struct sk_buff *skb, unsigned int cpu) 121static void send_cpu_listeners(struct sk_buff *skb,
122 struct listener_list *listeners)
123{ 123{
124 struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data); 124 struct genlmsghdr *genlhdr = nlmsg_data((struct nlmsghdr *)skb->data);
125 struct listener_list *listeners;
126 struct listener *s, *tmp; 125 struct listener *s, *tmp;
127 struct sk_buff *skb_next, *skb_cur = skb; 126 struct sk_buff *skb_next, *skb_cur = skb;
128 void *reply = genlmsg_data(genlhdr); 127 void *reply = genlmsg_data(genlhdr);
@@ -135,7 +134,6 @@ static void send_cpu_listeners(struct sk_buff *skb, unsigned int cpu)
135 } 134 }
136 135
137 rc = 0; 136 rc = 0;
138 listeners = &per_cpu(listener_array, cpu);
139 down_read(&listeners->sem); 137 down_read(&listeners->sem);
140 list_for_each_entry(s, &listeners->list, list) { 138 list_for_each_entry(s, &listeners->list, list) {
141 skb_next = NULL; 139 skb_next = NULL;
@@ -186,6 +184,7 @@ static int fill_pid(pid_t pid, struct task_struct *tsk,
186 } else 184 } else
187 get_task_struct(tsk); 185 get_task_struct(tsk);
188 186
187 memset(stats, 0, sizeof(*stats));
189 /* 188 /*
190 * Each accounting subsystem adds calls to its functions to 189 * Each accounting subsystem adds calls to its functions to
191 * fill in relevant parts of struct taskstsats as follows 190 * fill in relevant parts of struct taskstsats as follows
@@ -228,6 +227,8 @@ static int fill_tgid(pid_t tgid, struct task_struct *first,
228 227
229 if (first->signal->stats) 228 if (first->signal->stats)
230 memcpy(stats, first->signal->stats, sizeof(*stats)); 229 memcpy(stats, first->signal->stats, sizeof(*stats));
230 else
231 memset(stats, 0, sizeof(*stats));
231 232
232 tsk = first; 233 tsk = first;
233 do { 234 do {
@@ -344,14 +345,36 @@ static int parse(struct nlattr *na, cpumask_t *mask)
344 return ret; 345 return ret;
345} 346}
346 347
348static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid)
349{
350 struct nlattr *na, *ret;
351 int aggr;
352
353 aggr = (type == TASKSTATS_TYPE_PID)
354 ? TASKSTATS_TYPE_AGGR_PID
355 : TASKSTATS_TYPE_AGGR_TGID;
356
357 na = nla_nest_start(skb, aggr);
358 if (!na)
359 goto err;
360 if (nla_put(skb, type, sizeof(pid), &pid) < 0)
361 goto err;
362 ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats));
363 if (!ret)
364 goto err;
365 nla_nest_end(skb, na);
366
367 return nla_data(ret);
368err:
369 return NULL;
370}
371
347static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info) 372static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
348{ 373{
349 int rc = 0; 374 int rc = 0;
350 struct sk_buff *rep_skb; 375 struct sk_buff *rep_skb;
351 struct taskstats stats; 376 struct taskstats *stats;
352 void *reply;
353 size_t size; 377 size_t size;
354 struct nlattr *na;
355 cpumask_t mask; 378 cpumask_t mask;
356 379
357 rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], &mask); 380 rc = parse(info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK], &mask);
@@ -372,83 +395,71 @@ static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
372 size = nla_total_size(sizeof(u32)) + 395 size = nla_total_size(sizeof(u32)) +
373 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0); 396 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
374 397
375 memset(&stats, 0, sizeof(stats)); 398 rc = prepare_reply(info, TASKSTATS_CMD_NEW, &rep_skb, size);
376 rc = prepare_reply(info, TASKSTATS_CMD_NEW, &rep_skb, &reply, size);
377 if (rc < 0) 399 if (rc < 0)
378 return rc; 400 return rc;
379 401
402 rc = -EINVAL;
380 if (info->attrs[TASKSTATS_CMD_ATTR_PID]) { 403 if (info->attrs[TASKSTATS_CMD_ATTR_PID]) {
381 u32 pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]); 404 u32 pid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_PID]);
382 rc = fill_pid(pid, NULL, &stats); 405 stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, pid);
383 if (rc < 0) 406 if (!stats)
384 goto err; 407 goto err;
385 408
386 na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_PID); 409 rc = fill_pid(pid, NULL, stats);
387 NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_PID, pid); 410 if (rc < 0)
388 NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS, 411 goto err;
389 stats);
390 } else if (info->attrs[TASKSTATS_CMD_ATTR_TGID]) { 412 } else if (info->attrs[TASKSTATS_CMD_ATTR_TGID]) {
391 u32 tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]); 413 u32 tgid = nla_get_u32(info->attrs[TASKSTATS_CMD_ATTR_TGID]);
392 rc = fill_tgid(tgid, NULL, &stats); 414 stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tgid);
393 if (rc < 0) 415 if (!stats)
394 goto err; 416 goto err;
395 417
396 na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_TGID); 418 rc = fill_tgid(tgid, NULL, stats);
397 NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_TGID, tgid); 419 if (rc < 0)
398 NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS, 420 goto err;
399 stats); 421 } else
400 } else {
401 rc = -EINVAL;
402 goto err; 422 goto err;
403 }
404
405 nla_nest_end(rep_skb, na);
406 423
407 return send_reply(rep_skb, info->snd_pid); 424 return send_reply(rep_skb, info->snd_pid);
408
409nla_put_failure:
410 rc = genlmsg_cancel(rep_skb, reply);
411err: 425err:
412 nlmsg_free(rep_skb); 426 nlmsg_free(rep_skb);
413 return rc; 427 return rc;
414} 428}
415 429
416void taskstats_exit_alloc(struct taskstats **ptidstats, unsigned int *mycpu) 430static struct taskstats *taskstats_tgid_alloc(struct task_struct *tsk)
417{ 431{
418 struct listener_list *listeners; 432 struct signal_struct *sig = tsk->signal;
419 struct taskstats *tmp; 433 struct taskstats *stats;
420 /*
421 * This is the cpu on which the task is exiting currently and will
422 * be the one for which the exit event is sent, even if the cpu
423 * on which this function is running changes later.
424 */
425 *mycpu = raw_smp_processor_id();
426 434
427 *ptidstats = NULL; 435 if (sig->stats || thread_group_empty(tsk))
428 tmp = kmem_cache_zalloc(taskstats_cache, SLAB_KERNEL); 436 goto ret;
429 if (!tmp)
430 return;
431 437
432 listeners = &per_cpu(listener_array, *mycpu); 438 /* No problem if kmem_cache_zalloc() fails */
433 down_read(&listeners->sem); 439 stats = kmem_cache_zalloc(taskstats_cache, GFP_KERNEL);
434 if (!list_empty(&listeners->list)) { 440
435 *ptidstats = tmp; 441 spin_lock_irq(&tsk->sighand->siglock);
436 tmp = NULL; 442 if (!sig->stats) {
443 sig->stats = stats;
444 stats = NULL;
437 } 445 }
438 up_read(&listeners->sem); 446 spin_unlock_irq(&tsk->sighand->siglock);
439 kfree(tmp); 447
448 if (stats)
449 kmem_cache_free(taskstats_cache, stats);
450ret:
451 return sig->stats;
440} 452}
441 453
442/* Send pid data out on exit */ 454/* Send pid data out on exit */
443void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats, 455void taskstats_exit(struct task_struct *tsk, int group_dead)
444 int group_dead, unsigned int mycpu)
445{ 456{
446 int rc; 457 int rc;
458 struct listener_list *listeners;
459 struct taskstats *stats;
447 struct sk_buff *rep_skb; 460 struct sk_buff *rep_skb;
448 void *reply;
449 size_t size; 461 size_t size;
450 int is_thread_group; 462 int is_thread_group;
451 struct nlattr *na;
452 463
453 if (!family_registered) 464 if (!family_registered)
454 return; 465 return;
@@ -459,7 +470,7 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
459 size = nla_total_size(sizeof(u32)) + 470 size = nla_total_size(sizeof(u32)) +
460 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0); 471 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
461 472
462 is_thread_group = (tsk->signal->stats != NULL); 473 is_thread_group = !!taskstats_tgid_alloc(tsk);
463 if (is_thread_group) { 474 if (is_thread_group) {
464 /* PID + STATS + TGID + STATS */ 475 /* PID + STATS + TGID + STATS */
465 size = 2 * size; 476 size = 2 * size;
@@ -467,49 +478,39 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
467 fill_tgid_exit(tsk); 478 fill_tgid_exit(tsk);
468 } 479 }
469 480
470 if (!tidstats) 481 listeners = &__raw_get_cpu_var(listener_array);
482 if (list_empty(&listeners->list))
471 return; 483 return;
472 484
473 rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, &reply, size); 485 rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, size);
474 if (rc < 0)
475 goto ret;
476
477 rc = fill_pid(tsk->pid, tsk, tidstats);
478 if (rc < 0) 486 if (rc < 0)
479 goto err_skb; 487 return;
480 488
481 na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_PID); 489 stats = mk_reply(rep_skb, TASKSTATS_TYPE_PID, tsk->pid);
482 NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_PID, (u32)tsk->pid); 490 if (!stats)
483 NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS, 491 goto err;
484 *tidstats);
485 nla_nest_end(rep_skb, na);
486 492
487 if (!is_thread_group) 493 rc = fill_pid(tsk->pid, tsk, stats);
488 goto send; 494 if (rc < 0)
495 goto err;
489 496
490 /* 497 /*
491 * Doesn't matter if tsk is the leader or the last group member leaving 498 * Doesn't matter if tsk is the leader or the last group member leaving
492 */ 499 */
493 if (!group_dead) 500 if (!is_thread_group || !group_dead)
494 goto send; 501 goto send;
495 502
496 na = nla_nest_start(rep_skb, TASKSTATS_TYPE_AGGR_TGID); 503 stats = mk_reply(rep_skb, TASKSTATS_TYPE_TGID, tsk->tgid);
497 NLA_PUT_U32(rep_skb, TASKSTATS_TYPE_TGID, (u32)tsk->tgid); 504 if (!stats)
498 /* No locking needed for tsk->signal->stats since group is dead */ 505 goto err;
499 NLA_PUT_TYPE(rep_skb, struct taskstats, TASKSTATS_TYPE_STATS, 506
500 *tsk->signal->stats); 507 memcpy(stats, tsk->signal->stats, sizeof(*stats));
501 nla_nest_end(rep_skb, na);
502 508
503send: 509send:
504 send_cpu_listeners(rep_skb, mycpu); 510 send_cpu_listeners(rep_skb, listeners);
505 return; 511 return;
506 512err:
507nla_put_failure:
508 genlmsg_cancel(rep_skb, reply);
509err_skb:
510 nlmsg_free(rep_skb); 513 nlmsg_free(rep_skb);
511ret:
512 return;
513} 514}
514 515
515static struct genl_ops taskstats_ops = { 516static struct genl_ops taskstats_ops = {
diff --git a/kernel/unwind.c b/kernel/unwind.c
index ed0a21d4a902..09c261329249 100644
--- a/kernel/unwind.c
+++ b/kernel/unwind.c
@@ -14,11 +14,12 @@
14#include <linux/bootmem.h> 14#include <linux/bootmem.h>
15#include <linux/sort.h> 15#include <linux/sort.h>
16#include <linux/stop_machine.h> 16#include <linux/stop_machine.h>
17#include <linux/uaccess.h>
17#include <asm/sections.h> 18#include <asm/sections.h>
18#include <asm/uaccess.h> 19#include <asm/uaccess.h>
19#include <asm/unaligned.h> 20#include <asm/unaligned.h>
20 21
21extern char __start_unwind[], __end_unwind[]; 22extern const char __start_unwind[], __end_unwind[];
22extern const u8 __start_unwind_hdr[], __end_unwind_hdr[]; 23extern const u8 __start_unwind_hdr[], __end_unwind_hdr[];
23 24
24#define MAX_STACK_DEPTH 8 25#define MAX_STACK_DEPTH 8
@@ -94,6 +95,7 @@ static const struct {
94 95
95typedef unsigned long uleb128_t; 96typedef unsigned long uleb128_t;
96typedef signed long sleb128_t; 97typedef signed long sleb128_t;
98#define sleb128abs __builtin_labs
97 99
98static struct unwind_table { 100static struct unwind_table {
99 struct { 101 struct {
@@ -135,6 +137,17 @@ struct unwind_state {
135 137
136static const struct cfa badCFA = { ARRAY_SIZE(reg_info), 1 }; 138static const struct cfa badCFA = { ARRAY_SIZE(reg_info), 1 };
137 139
140static unsigned unwind_debug;
141static int __init unwind_debug_setup(char *s)
142{
143 unwind_debug = simple_strtoul(s, NULL, 0);
144 return 1;
145}
146__setup("unwind_debug=", unwind_debug_setup);
147#define dprintk(lvl, fmt, args...) \
148 ((void)(lvl > unwind_debug \
149 || printk(KERN_DEBUG "unwind: " fmt "\n", ##args)))
150
138static struct unwind_table *find_table(unsigned long pc) 151static struct unwind_table *find_table(unsigned long pc)
139{ 152{
140 struct unwind_table *table; 153 struct unwind_table *table;
@@ -151,7 +164,9 @@ static struct unwind_table *find_table(unsigned long pc)
151 164
152static unsigned long read_pointer(const u8 **pLoc, 165static unsigned long read_pointer(const u8 **pLoc,
153 const void *end, 166 const void *end,
154 signed ptrType); 167 signed ptrType,
168 unsigned long text_base,
169 unsigned long data_base);
155 170
156static void init_unwind_table(struct unwind_table *table, 171static void init_unwind_table(struct unwind_table *table,
157 const char *name, 172 const char *name,
@@ -176,10 +191,13 @@ static void init_unwind_table(struct unwind_table *table,
176 /* See if the linker provided table looks valid. */ 191 /* See if the linker provided table looks valid. */
177 if (header_size <= 4 192 if (header_size <= 4
178 || header_start[0] != 1 193 || header_start[0] != 1
179 || (void *)read_pointer(&ptr, end, header_start[1]) != table_start 194 || (void *)read_pointer(&ptr, end, header_start[1], 0, 0)
180 || header_start[2] == DW_EH_PE_omit 195 != table_start
181 || read_pointer(&ptr, end, header_start[2]) <= 0 196 || !read_pointer(&ptr, end, header_start[2], 0, 0)
182 || header_start[3] == DW_EH_PE_omit) 197 || !read_pointer(&ptr, end, header_start[3], 0,
198 (unsigned long)header_start)
199 || !read_pointer(&ptr, end, header_start[3], 0,
200 (unsigned long)header_start))
183 header_start = NULL; 201 header_start = NULL;
184 table->hdrsz = header_size; 202 table->hdrsz = header_size;
185 smp_wmb(); 203 smp_wmb();
@@ -269,7 +287,7 @@ static void __init setup_unwind_table(struct unwind_table *table,
269 ptr = (const u8 *)(fde + 2); 287 ptr = (const u8 *)(fde + 2);
270 if (!read_pointer(&ptr, 288 if (!read_pointer(&ptr,
271 (const u8 *)(fde + 1) + *fde, 289 (const u8 *)(fde + 1) + *fde,
272 ptrType)) 290 ptrType, 0, 0))
273 return; 291 return;
274 ++n; 292 ++n;
275 } 293 }
@@ -279,6 +297,7 @@ static void __init setup_unwind_table(struct unwind_table *table,
279 297
280 hdrSize = 4 + sizeof(unsigned long) + sizeof(unsigned int) 298 hdrSize = 4 + sizeof(unsigned long) + sizeof(unsigned int)
281 + 2 * n * sizeof(unsigned long); 299 + 2 * n * sizeof(unsigned long);
300 dprintk(2, "Binary lookup table size for %s: %lu bytes", table->name, hdrSize);
282 header = alloc(hdrSize); 301 header = alloc(hdrSize);
283 if (!header) 302 if (!header)
284 return; 303 return;
@@ -303,7 +322,7 @@ static void __init setup_unwind_table(struct unwind_table *table,
303 ptr = (const u8 *)(fde + 2); 322 ptr = (const u8 *)(fde + 2);
304 header->table[n].start = read_pointer(&ptr, 323 header->table[n].start = read_pointer(&ptr,
305 (const u8 *)(fde + 1) + *fde, 324 (const u8 *)(fde + 1) + *fde,
306 fde_pointer_type(cie)); 325 fde_pointer_type(cie), 0, 0);
307 header->table[n].fde = (unsigned long)fde; 326 header->table[n].fde = (unsigned long)fde;
308 ++n; 327 ++n;
309 } 328 }
@@ -486,7 +505,9 @@ static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *table)
486 505
487static unsigned long read_pointer(const u8 **pLoc, 506static unsigned long read_pointer(const u8 **pLoc,
488 const void *end, 507 const void *end,
489 signed ptrType) 508 signed ptrType,
509 unsigned long text_base,
510 unsigned long data_base)
490{ 511{
491 unsigned long value = 0; 512 unsigned long value = 0;
492 union { 513 union {
@@ -498,13 +519,17 @@ static unsigned long read_pointer(const u8 **pLoc,
498 const unsigned long *pul; 519 const unsigned long *pul;
499 } ptr; 520 } ptr;
500 521
501 if (ptrType < 0 || ptrType == DW_EH_PE_omit) 522 if (ptrType < 0 || ptrType == DW_EH_PE_omit) {
523 dprintk(1, "Invalid pointer encoding %02X (%p,%p).", ptrType, *pLoc, end);
502 return 0; 524 return 0;
525 }
503 ptr.p8 = *pLoc; 526 ptr.p8 = *pLoc;
504 switch(ptrType & DW_EH_PE_FORM) { 527 switch(ptrType & DW_EH_PE_FORM) {
505 case DW_EH_PE_data2: 528 case DW_EH_PE_data2:
506 if (end < (const void *)(ptr.p16u + 1)) 529 if (end < (const void *)(ptr.p16u + 1)) {
530 dprintk(1, "Data16 overrun (%p,%p).", ptr.p8, end);
507 return 0; 531 return 0;
532 }
508 if(ptrType & DW_EH_PE_signed) 533 if(ptrType & DW_EH_PE_signed)
509 value = get_unaligned(ptr.p16s++); 534 value = get_unaligned(ptr.p16s++);
510 else 535 else
@@ -512,8 +537,10 @@ static unsigned long read_pointer(const u8 **pLoc,
512 break; 537 break;
513 case DW_EH_PE_data4: 538 case DW_EH_PE_data4:
514#ifdef CONFIG_64BIT 539#ifdef CONFIG_64BIT
515 if (end < (const void *)(ptr.p32u + 1)) 540 if (end < (const void *)(ptr.p32u + 1)) {
541 dprintk(1, "Data32 overrun (%p,%p).", ptr.p8, end);
516 return 0; 542 return 0;
543 }
517 if(ptrType & DW_EH_PE_signed) 544 if(ptrType & DW_EH_PE_signed)
518 value = get_unaligned(ptr.p32s++); 545 value = get_unaligned(ptr.p32s++);
519 else 546 else
@@ -525,8 +552,10 @@ static unsigned long read_pointer(const u8 **pLoc,
525 BUILD_BUG_ON(sizeof(u32) != sizeof(value)); 552 BUILD_BUG_ON(sizeof(u32) != sizeof(value));
526#endif 553#endif
527 case DW_EH_PE_native: 554 case DW_EH_PE_native:
528 if (end < (const void *)(ptr.pul + 1)) 555 if (end < (const void *)(ptr.pul + 1)) {
556 dprintk(1, "DataUL overrun (%p,%p).", ptr.p8, end);
529 return 0; 557 return 0;
558 }
530 value = get_unaligned(ptr.pul++); 559 value = get_unaligned(ptr.pul++);
531 break; 560 break;
532 case DW_EH_PE_leb128: 561 case DW_EH_PE_leb128:
@@ -534,10 +563,14 @@ static unsigned long read_pointer(const u8 **pLoc,
534 value = ptrType & DW_EH_PE_signed 563 value = ptrType & DW_EH_PE_signed
535 ? get_sleb128(&ptr.p8, end) 564 ? get_sleb128(&ptr.p8, end)
536 : get_uleb128(&ptr.p8, end); 565 : get_uleb128(&ptr.p8, end);
537 if ((const void *)ptr.p8 > end) 566 if ((const void *)ptr.p8 > end) {
567 dprintk(1, "DataLEB overrun (%p,%p).", ptr.p8, end);
538 return 0; 568 return 0;
569 }
539 break; 570 break;
540 default: 571 default:
572 dprintk(2, "Cannot decode pointer type %02X (%p,%p).",
573 ptrType, ptr.p8, end);
541 return 0; 574 return 0;
542 } 575 }
543 switch(ptrType & DW_EH_PE_ADJUST) { 576 switch(ptrType & DW_EH_PE_ADJUST) {
@@ -546,12 +579,33 @@ static unsigned long read_pointer(const u8 **pLoc,
546 case DW_EH_PE_pcrel: 579 case DW_EH_PE_pcrel:
547 value += (unsigned long)*pLoc; 580 value += (unsigned long)*pLoc;
548 break; 581 break;
582 case DW_EH_PE_textrel:
583 if (likely(text_base)) {
584 value += text_base;
585 break;
586 }
587 dprintk(2, "Text-relative encoding %02X (%p,%p), but zero text base.",
588 ptrType, *pLoc, end);
589 return 0;
590 case DW_EH_PE_datarel:
591 if (likely(data_base)) {
592 value += data_base;
593 break;
594 }
595 dprintk(2, "Data-relative encoding %02X (%p,%p), but zero data base.",
596 ptrType, *pLoc, end);
597 return 0;
549 default: 598 default:
599 dprintk(2, "Cannot adjust pointer type %02X (%p,%p).",
600 ptrType, *pLoc, end);
550 return 0; 601 return 0;
551 } 602 }
552 if ((ptrType & DW_EH_PE_indirect) 603 if ((ptrType & DW_EH_PE_indirect)
553 && __get_user(value, (unsigned long *)value)) 604 && probe_kernel_address((unsigned long *)value, value)) {
605 dprintk(1, "Cannot read indirect value %lx (%p,%p).",
606 value, *pLoc, end);
554 return 0; 607 return 0;
608 }
555 *pLoc = ptr.p8; 609 *pLoc = ptr.p8;
556 610
557 return value; 611 return value;
@@ -594,7 +648,8 @@ static signed fde_pointer_type(const u32 *cie)
594 case 'P': { 648 case 'P': {
595 signed ptrType = *ptr++; 649 signed ptrType = *ptr++;
596 650
597 if (!read_pointer(&ptr, end, ptrType) || ptr > end) 651 if (!read_pointer(&ptr, end, ptrType, 0, 0)
652 || ptr > end)
598 return -1; 653 return -1;
599 } 654 }
600 break; 655 break;
@@ -654,7 +709,8 @@ static int processCFI(const u8 *start,
654 case DW_CFA_nop: 709 case DW_CFA_nop:
655 break; 710 break;
656 case DW_CFA_set_loc: 711 case DW_CFA_set_loc:
657 if ((state->loc = read_pointer(&ptr.p8, end, ptrType)) == 0) 712 state->loc = read_pointer(&ptr.p8, end, ptrType, 0, 0);
713 if (state->loc == 0)
658 result = 0; 714 result = 0;
659 break; 715 break;
660 case DW_CFA_advance_loc1: 716 case DW_CFA_advance_loc1:
@@ -700,8 +756,10 @@ static int processCFI(const u8 *start,
700 state->label = NULL; 756 state->label = NULL;
701 return 1; 757 return 1;
702 } 758 }
703 if (state->stackDepth >= MAX_STACK_DEPTH) 759 if (state->stackDepth >= MAX_STACK_DEPTH) {
760 dprintk(1, "State stack overflow (%p,%p).", ptr.p8, end);
704 return 0; 761 return 0;
762 }
705 state->stack[state->stackDepth++] = ptr.p8; 763 state->stack[state->stackDepth++] = ptr.p8;
706 break; 764 break;
707 case DW_CFA_restore_state: 765 case DW_CFA_restore_state:
@@ -716,8 +774,10 @@ static int processCFI(const u8 *start,
716 result = processCFI(start, end, 0, ptrType, state); 774 result = processCFI(start, end, 0, ptrType, state);
717 state->loc = loc; 775 state->loc = loc;
718 state->label = label; 776 state->label = label;
719 } else 777 } else {
778 dprintk(1, "State stack underflow (%p,%p).", ptr.p8, end);
720 return 0; 779 return 0;
780 }
721 break; 781 break;
722 case DW_CFA_def_cfa: 782 case DW_CFA_def_cfa:
723 state->cfa.reg = get_uleb128(&ptr.p8, end); 783 state->cfa.reg = get_uleb128(&ptr.p8, end);
@@ -749,6 +809,7 @@ static int processCFI(const u8 *start,
749 break; 809 break;
750 case DW_CFA_GNU_window_save: 810 case DW_CFA_GNU_window_save:
751 default: 811 default:
812 dprintk(1, "Unrecognized CFI op %02X (%p,%p).", ptr.p8[-1], ptr.p8 - 1, end);
752 result = 0; 813 result = 0;
753 break; 814 break;
754 } 815 }
@@ -764,12 +825,17 @@ static int processCFI(const u8 *start,
764 set_rule(*ptr.p8++ & 0x3f, Nowhere, 0, state); 825 set_rule(*ptr.p8++ & 0x3f, Nowhere, 0, state);
765 break; 826 break;
766 } 827 }
767 if (ptr.p8 > end) 828 if (ptr.p8 > end) {
829 dprintk(1, "Data overrun (%p,%p).", ptr.p8, end);
768 result = 0; 830 result = 0;
831 }
769 if (result && targetLoc != 0 && targetLoc < state->loc) 832 if (result && targetLoc != 0 && targetLoc < state->loc)
770 return 1; 833 return 1;
771 } 834 }
772 835
836 if (result && ptr.p8 < end)
837 dprintk(1, "Data underrun (%p,%p).", ptr.p8, end);
838
773 return result 839 return result
774 && ptr.p8 == end 840 && ptr.p8 == end
775 && (targetLoc == 0 841 && (targetLoc == 0
@@ -786,7 +852,7 @@ int unwind(struct unwind_frame_info *frame)
786#define FRAME_REG(r, t) (((t *)frame)[reg_info[r].offs]) 852#define FRAME_REG(r, t) (((t *)frame)[reg_info[r].offs])
787 const u32 *fde = NULL, *cie = NULL; 853 const u32 *fde = NULL, *cie = NULL;
788 const u8 *ptr = NULL, *end = NULL; 854 const u8 *ptr = NULL, *end = NULL;
789 unsigned long pc = UNW_PC(frame) - frame->call_frame; 855 unsigned long pc = UNW_PC(frame) - frame->call_frame, sp;
790 unsigned long startLoc = 0, endLoc = 0, cfa; 856 unsigned long startLoc = 0, endLoc = 0, cfa;
791 unsigned i; 857 unsigned i;
792 signed ptrType = -1; 858 signed ptrType = -1;
@@ -813,9 +879,9 @@ int unwind(struct unwind_frame_info *frame)
813 ptr = hdr + 4; 879 ptr = hdr + 4;
814 end = hdr + table->hdrsz; 880 end = hdr + table->hdrsz;
815 if (tableSize 881 if (tableSize
816 && read_pointer(&ptr, end, hdr[1]) 882 && read_pointer(&ptr, end, hdr[1], 0, 0)
817 == (unsigned long)table->address 883 == (unsigned long)table->address
818 && (i = read_pointer(&ptr, end, hdr[2])) > 0 884 && (i = read_pointer(&ptr, end, hdr[2], 0, 0)) > 0
819 && i == (end - ptr) / (2 * tableSize) 885 && i == (end - ptr) / (2 * tableSize)
820 && !((end - ptr) % (2 * tableSize))) { 886 && !((end - ptr) % (2 * tableSize))) {
821 do { 887 do {
@@ -823,7 +889,8 @@ int unwind(struct unwind_frame_info *frame)
823 889
824 startLoc = read_pointer(&cur, 890 startLoc = read_pointer(&cur,
825 cur + tableSize, 891 cur + tableSize,
826 hdr[3]); 892 hdr[3], 0,
893 (unsigned long)hdr);
827 if (pc < startLoc) 894 if (pc < startLoc)
828 i /= 2; 895 i /= 2;
829 else { 896 else {
@@ -834,13 +901,17 @@ int unwind(struct unwind_frame_info *frame)
834 if (i == 1 901 if (i == 1
835 && (startLoc = read_pointer(&ptr, 902 && (startLoc = read_pointer(&ptr,
836 ptr + tableSize, 903 ptr + tableSize,
837 hdr[3])) != 0 904 hdr[3], 0,
905 (unsigned long)hdr)) != 0
838 && pc >= startLoc) 906 && pc >= startLoc)
839 fde = (void *)read_pointer(&ptr, 907 fde = (void *)read_pointer(&ptr,
840 ptr + tableSize, 908 ptr + tableSize,
841 hdr[3]); 909 hdr[3], 0,
910 (unsigned long)hdr);
842 } 911 }
843 } 912 }
913 if(hdr && !fde)
914 dprintk(3, "Binary lookup for %lx failed.", pc);
844 915
845 if (fde != NULL) { 916 if (fde != NULL) {
846 cie = cie_for_fde(fde, table); 917 cie = cie_for_fde(fde, table);
@@ -851,17 +922,19 @@ int unwind(struct unwind_frame_info *frame)
851 && (ptrType = fde_pointer_type(cie)) >= 0 922 && (ptrType = fde_pointer_type(cie)) >= 0
852 && read_pointer(&ptr, 923 && read_pointer(&ptr,
853 (const u8 *)(fde + 1) + *fde, 924 (const u8 *)(fde + 1) + *fde,
854 ptrType) == startLoc) { 925 ptrType, 0, 0) == startLoc) {
855 if (!(ptrType & DW_EH_PE_indirect)) 926 if (!(ptrType & DW_EH_PE_indirect))
856 ptrType &= DW_EH_PE_FORM|DW_EH_PE_signed; 927 ptrType &= DW_EH_PE_FORM|DW_EH_PE_signed;
857 endLoc = startLoc 928 endLoc = startLoc
858 + read_pointer(&ptr, 929 + read_pointer(&ptr,
859 (const u8 *)(fde + 1) + *fde, 930 (const u8 *)(fde + 1) + *fde,
860 ptrType); 931 ptrType, 0, 0);
861 if(pc >= endLoc) 932 if(pc >= endLoc)
862 fde = NULL; 933 fde = NULL;
863 } else 934 } else
864 fde = NULL; 935 fde = NULL;
936 if(!fde)
937 dprintk(1, "Binary lookup result for %lx discarded.", pc);
865 } 938 }
866 if (fde == NULL) { 939 if (fde == NULL) {
867 for (fde = table->address, tableSize = table->size; 940 for (fde = table->address, tableSize = table->size;
@@ -881,7 +954,7 @@ int unwind(struct unwind_frame_info *frame)
881 ptr = (const u8 *)(fde + 2); 954 ptr = (const u8 *)(fde + 2);
882 startLoc = read_pointer(&ptr, 955 startLoc = read_pointer(&ptr,
883 (const u8 *)(fde + 1) + *fde, 956 (const u8 *)(fde + 1) + *fde,
884 ptrType); 957 ptrType, 0, 0);
885 if (!startLoc) 958 if (!startLoc)
886 continue; 959 continue;
887 if (!(ptrType & DW_EH_PE_indirect)) 960 if (!(ptrType & DW_EH_PE_indirect))
@@ -889,10 +962,12 @@ int unwind(struct unwind_frame_info *frame)
889 endLoc = startLoc 962 endLoc = startLoc
890 + read_pointer(&ptr, 963 + read_pointer(&ptr,
891 (const u8 *)(fde + 1) + *fde, 964 (const u8 *)(fde + 1) + *fde,
892 ptrType); 965 ptrType, 0, 0);
893 if (pc >= startLoc && pc < endLoc) 966 if (pc >= startLoc && pc < endLoc)
894 break; 967 break;
895 } 968 }
969 if(!fde)
970 dprintk(3, "Linear lookup for %lx failed.", pc);
896 } 971 }
897 } 972 }
898 if (cie != NULL) { 973 if (cie != NULL) {
@@ -926,6 +1001,8 @@ int unwind(struct unwind_frame_info *frame)
926 if (ptr >= end || *ptr) 1001 if (ptr >= end || *ptr)
927 cie = NULL; 1002 cie = NULL;
928 } 1003 }
1004 if(!cie)
1005 dprintk(1, "CIE unusable (%p,%p).", ptr, end);
929 ++ptr; 1006 ++ptr;
930 } 1007 }
931 if (cie != NULL) { 1008 if (cie != NULL) {
@@ -935,7 +1012,12 @@ int unwind(struct unwind_frame_info *frame)
935 state.dataAlign = get_sleb128(&ptr, end); 1012 state.dataAlign = get_sleb128(&ptr, end);
936 if (state.codeAlign == 0 || state.dataAlign == 0 || ptr >= end) 1013 if (state.codeAlign == 0 || state.dataAlign == 0 || ptr >= end)
937 cie = NULL; 1014 cie = NULL;
938 else { 1015 else if (UNW_PC(frame) % state.codeAlign
1016 || UNW_SP(frame) % sleb128abs(state.dataAlign)) {
1017 dprintk(1, "Input pointer(s) misaligned (%lx,%lx).",
1018 UNW_PC(frame), UNW_SP(frame));
1019 return -EPERM;
1020 } else {
939 retAddrReg = state.version <= 1 ? *ptr++ : get_uleb128(&ptr, end); 1021 retAddrReg = state.version <= 1 ? *ptr++ : get_uleb128(&ptr, end);
940 /* skip augmentation */ 1022 /* skip augmentation */
941 if (((const char *)(cie + 2))[1] == 'z') { 1023 if (((const char *)(cie + 2))[1] == 'z') {
@@ -949,6 +1031,8 @@ int unwind(struct unwind_frame_info *frame)
949 || reg_info[retAddrReg].width != sizeof(unsigned long)) 1031 || reg_info[retAddrReg].width != sizeof(unsigned long))
950 cie = NULL; 1032 cie = NULL;
951 } 1033 }
1034 if(!cie)
1035 dprintk(1, "CIE validation failed (%p,%p).", ptr, end);
952 } 1036 }
953 if (cie != NULL) { 1037 if (cie != NULL) {
954 state.cieStart = ptr; 1038 state.cieStart = ptr;
@@ -962,11 +1046,15 @@ int unwind(struct unwind_frame_info *frame)
962 if ((ptr += augSize) > end) 1046 if ((ptr += augSize) > end)
963 fde = NULL; 1047 fde = NULL;
964 } 1048 }
1049 if(!fde)
1050 dprintk(1, "FDE validation failed (%p,%p).", ptr, end);
965 } 1051 }
966 if (cie == NULL || fde == NULL) { 1052 if (cie == NULL || fde == NULL) {
967#ifdef CONFIG_FRAME_POINTER 1053#ifdef CONFIG_FRAME_POINTER
968 unsigned long top, bottom; 1054 unsigned long top, bottom;
969 1055
1056 if ((UNW_SP(frame) | UNW_FP(frame)) % sizeof(unsigned long))
1057 return -EPERM;
970 top = STACK_TOP(frame->task); 1058 top = STACK_TOP(frame->task);
971 bottom = STACK_BOTTOM(frame->task); 1059 bottom = STACK_BOTTOM(frame->task);
972# if FRAME_RETADDR_OFFSET < 0 1060# if FRAME_RETADDR_OFFSET < 0
@@ -982,18 +1070,19 @@ int unwind(struct unwind_frame_info *frame)
982 & (sizeof(unsigned long) - 1))) { 1070 & (sizeof(unsigned long) - 1))) {
983 unsigned long link; 1071 unsigned long link;
984 1072
985 if (!__get_user(link, 1073 if (!probe_kernel_address(
986 (unsigned long *)(UNW_FP(frame) 1074 (unsigned long *)(UNW_FP(frame)
987 + FRAME_LINK_OFFSET)) 1075 + FRAME_LINK_OFFSET),
1076 link)
988# if FRAME_RETADDR_OFFSET < 0 1077# if FRAME_RETADDR_OFFSET < 0
989 && link > bottom && link < UNW_FP(frame) 1078 && link > bottom && link < UNW_FP(frame)
990# else 1079# else
991 && link > UNW_FP(frame) && link < bottom 1080 && link > UNW_FP(frame) && link < bottom
992# endif 1081# endif
993 && !(link & (sizeof(link) - 1)) 1082 && !(link & (sizeof(link) - 1))
994 && !__get_user(UNW_PC(frame), 1083 && !probe_kernel_address(
995 (unsigned long *)(UNW_FP(frame) 1084 (unsigned long *)(UNW_FP(frame)
996 + FRAME_RETADDR_OFFSET))) { 1085 + FRAME_RETADDR_OFFSET), UNW_PC(frame))) {
997 UNW_SP(frame) = UNW_FP(frame) + FRAME_RETADDR_OFFSET 1086 UNW_SP(frame) = UNW_FP(frame) + FRAME_RETADDR_OFFSET
998# if FRAME_RETADDR_OFFSET < 0 1087# if FRAME_RETADDR_OFFSET < 0
999 - 1088 -
@@ -1016,8 +1105,11 @@ int unwind(struct unwind_frame_info *frame)
1016 || state.regs[retAddrReg].where == Nowhere 1105 || state.regs[retAddrReg].where == Nowhere
1017 || state.cfa.reg >= ARRAY_SIZE(reg_info) 1106 || state.cfa.reg >= ARRAY_SIZE(reg_info)
1018 || reg_info[state.cfa.reg].width != sizeof(unsigned long) 1107 || reg_info[state.cfa.reg].width != sizeof(unsigned long)
1019 || state.cfa.offs % sizeof(unsigned long)) 1108 || FRAME_REG(state.cfa.reg, unsigned long) % sizeof(unsigned long)
1109 || state.cfa.offs % sizeof(unsigned long)) {
1110 dprintk(1, "Unusable unwind info (%p,%p).", ptr, end);
1020 return -EIO; 1111 return -EIO;
1112 }
1021 /* update frame */ 1113 /* update frame */
1022#ifndef CONFIG_AS_CFI_SIGNAL_FRAME 1114#ifndef CONFIG_AS_CFI_SIGNAL_FRAME
1023 if(frame->call_frame 1115 if(frame->call_frame
@@ -1036,10 +1128,14 @@ int unwind(struct unwind_frame_info *frame)
1036#else 1128#else
1037# define CASES CASE(8); CASE(16); CASE(32); CASE(64) 1129# define CASES CASE(8); CASE(16); CASE(32); CASE(64)
1038#endif 1130#endif
1131 pc = UNW_PC(frame);
1132 sp = UNW_SP(frame);
1039 for (i = 0; i < ARRAY_SIZE(state.regs); ++i) { 1133 for (i = 0; i < ARRAY_SIZE(state.regs); ++i) {
1040 if (REG_INVALID(i)) { 1134 if (REG_INVALID(i)) {
1041 if (state.regs[i].where == Nowhere) 1135 if (state.regs[i].where == Nowhere)
1042 continue; 1136 continue;
1137 dprintk(1, "Cannot restore register %u (%d).",
1138 i, state.regs[i].where);
1043 return -EIO; 1139 return -EIO;
1044 } 1140 }
1045 switch(state.regs[i].where) { 1141 switch(state.regs[i].where) {
@@ -1048,8 +1144,11 @@ int unwind(struct unwind_frame_info *frame)
1048 case Register: 1144 case Register:
1049 if (state.regs[i].value >= ARRAY_SIZE(reg_info) 1145 if (state.regs[i].value >= ARRAY_SIZE(reg_info)
1050 || REG_INVALID(state.regs[i].value) 1146 || REG_INVALID(state.regs[i].value)
1051 || reg_info[i].width > reg_info[state.regs[i].value].width) 1147 || reg_info[i].width > reg_info[state.regs[i].value].width) {
1148 dprintk(1, "Cannot restore register %u from register %lu.",
1149 i, state.regs[i].value);
1052 return -EIO; 1150 return -EIO;
1151 }
1053 switch(reg_info[state.regs[i].value].width) { 1152 switch(reg_info[state.regs[i].value].width) {
1054#define CASE(n) \ 1153#define CASE(n) \
1055 case sizeof(u##n): \ 1154 case sizeof(u##n): \
@@ -1059,6 +1158,9 @@ int unwind(struct unwind_frame_info *frame)
1059 CASES; 1158 CASES;
1060#undef CASE 1159#undef CASE
1061 default: 1160 default:
1161 dprintk(1, "Unsupported register size %u (%lu).",
1162 reg_info[state.regs[i].value].width,
1163 state.regs[i].value);
1062 return -EIO; 1164 return -EIO;
1063 } 1165 }
1064 break; 1166 break;
@@ -1083,12 +1185,17 @@ int unwind(struct unwind_frame_info *frame)
1083 CASES; 1185 CASES;
1084#undef CASE 1186#undef CASE
1085 default: 1187 default:
1188 dprintk(1, "Unsupported register size %u (%u).",
1189 reg_info[i].width, i);
1086 return -EIO; 1190 return -EIO;
1087 } 1191 }
1088 break; 1192 break;
1089 case Value: 1193 case Value:
1090 if (reg_info[i].width != sizeof(unsigned long)) 1194 if (reg_info[i].width != sizeof(unsigned long)) {
1195 dprintk(1, "Unsupported value size %u (%u).",
1196 reg_info[i].width, i);
1091 return -EIO; 1197 return -EIO;
1198 }
1092 FRAME_REG(i, unsigned long) = cfa + state.regs[i].value 1199 FRAME_REG(i, unsigned long) = cfa + state.regs[i].value
1093 * state.dataAlign; 1200 * state.dataAlign;
1094 break; 1201 break;
@@ -1100,15 +1207,20 @@ int unwind(struct unwind_frame_info *frame)
1100 % sizeof(unsigned long) 1207 % sizeof(unsigned long)
1101 || addr < startLoc 1208 || addr < startLoc
1102 || addr + sizeof(unsigned long) < addr 1209 || addr + sizeof(unsigned long) < addr
1103 || addr + sizeof(unsigned long) > endLoc) 1210 || addr + sizeof(unsigned long) > endLoc) {
1211 dprintk(1, "Bad memory location %lx (%lx).",
1212 addr, state.regs[i].value);
1104 return -EIO; 1213 return -EIO;
1214 }
1105 switch(reg_info[i].width) { 1215 switch(reg_info[i].width) {
1106#define CASE(n) case sizeof(u##n): \ 1216#define CASE(n) case sizeof(u##n): \
1107 __get_user(FRAME_REG(i, u##n), (u##n *)addr); \ 1217 probe_kernel_address((u##n *)addr, FRAME_REG(i, u##n)); \
1108 break 1218 break
1109 CASES; 1219 CASES;
1110#undef CASE 1220#undef CASE
1111 default: 1221 default:
1222 dprintk(1, "Unsupported memory size %u (%u).",
1223 reg_info[i].width, i);
1112 return -EIO; 1224 return -EIO;
1113 } 1225 }
1114 } 1226 }
@@ -1116,6 +1228,17 @@ int unwind(struct unwind_frame_info *frame)
1116 } 1228 }
1117 } 1229 }
1118 1230
1231 if (UNW_PC(frame) % state.codeAlign
1232 || UNW_SP(frame) % sleb128abs(state.dataAlign)) {
1233 dprintk(1, "Output pointer(s) misaligned (%lx,%lx).",
1234 UNW_PC(frame), UNW_SP(frame));
1235 return -EIO;
1236 }
1237 if (pc == UNW_PC(frame) && sp == UNW_SP(frame)) {
1238 dprintk(1, "No progress (%lx,%lx).", pc, sp);
1239 return -EIO;
1240 }
1241
1119 return 0; 1242 return 0;
1120#undef CASES 1243#undef CASES
1121#undef FRAME_REG 1244#undef FRAME_REG
diff --git a/kernel/user.c b/kernel/user.c
index 220e586127a0..4869563080e9 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -26,7 +26,7 @@
26#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK) 26#define __uidhashfn(uid) (((uid >> UIDHASH_BITS) + uid) & UIDHASH_MASK)
27#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid))) 27#define uidhashentry(uid) (uidhash_table + __uidhashfn((uid)))
28 28
29static kmem_cache_t *uid_cachep; 29static struct kmem_cache *uid_cachep;
30static struct list_head uidhash_table[UIDHASH_SZ]; 30static struct list_head uidhash_table[UIDHASH_SZ];
31 31
32/* 32/*
@@ -132,7 +132,7 @@ struct user_struct * alloc_uid(uid_t uid)
132 if (!up) { 132 if (!up) {
133 struct user_struct *new; 133 struct user_struct *new;
134 134
135 new = kmem_cache_alloc(uid_cachep, SLAB_KERNEL); 135 new = kmem_cache_alloc(uid_cachep, GFP_KERNEL);
136 if (!new) 136 if (!new)
137 return NULL; 137 return NULL;
138 new->uid = uid; 138 new->uid = uid;
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 8d1e7cb8a51a..6b186750e9be 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -29,6 +29,9 @@
29#include <linux/kthread.h> 29#include <linux/kthread.h>
30#include <linux/hardirq.h> 30#include <linux/hardirq.h>
31#include <linux/mempolicy.h> 31#include <linux/mempolicy.h>
32#include <linux/freezer.h>
33#include <linux/kallsyms.h>
34#include <linux/debug_locks.h>
32 35
33/* 36/*
34 * The per-CPU workqueue (if single thread, we always use the first 37 * The per-CPU workqueue (if single thread, we always use the first
@@ -55,6 +58,8 @@ struct cpu_workqueue_struct {
55 struct task_struct *thread; 58 struct task_struct *thread;
56 59
57 int run_depth; /* Detect run_workqueue() recursion depth */ 60 int run_depth; /* Detect run_workqueue() recursion depth */
61
62 int freezeable; /* Freeze the thread during suspend */
58} ____cacheline_aligned; 63} ____cacheline_aligned;
59 64
60/* 65/*
@@ -103,6 +108,79 @@ static inline void *get_wq_data(struct work_struct *work)
103 return (void *) (work->management & WORK_STRUCT_WQ_DATA_MASK); 108 return (void *) (work->management & WORK_STRUCT_WQ_DATA_MASK);
104} 109}
105 110
111static int __run_work(struct cpu_workqueue_struct *cwq, struct work_struct *work)
112{
113 int ret = 0;
114 unsigned long flags;
115
116 spin_lock_irqsave(&cwq->lock, flags);
117 /*
118 * We need to re-validate the work info after we've gotten
119 * the cpu_workqueue lock. We can run the work now iff:
120 *
121 * - the wq_data still matches the cpu_workqueue_struct
122 * - AND the work is still marked pending
123 * - AND the work is still on a list (which will be this
124 * workqueue_struct list)
125 *
126 * All these conditions are important, because we
127 * need to protect against the work being run right
128 * now on another CPU (all but the last one might be
129 * true if it's currently running and has not been
130 * released yet, for example).
131 */
132 if (get_wq_data(work) == cwq
133 && work_pending(work)
134 && !list_empty(&work->entry)) {
135 work_func_t f = work->func;
136 list_del_init(&work->entry);
137 spin_unlock_irqrestore(&cwq->lock, flags);
138
139 if (!test_bit(WORK_STRUCT_NOAUTOREL, &work->management))
140 work_release(work);
141 f(work);
142
143 spin_lock_irqsave(&cwq->lock, flags);
144 cwq->remove_sequence++;
145 wake_up(&cwq->work_done);
146 ret = 1;
147 }
148 spin_unlock_irqrestore(&cwq->lock, flags);
149 return ret;
150}
151
152/**
153 * run_scheduled_work - run scheduled work synchronously
154 * @work: work to run
155 *
156 * This checks if the work was pending, and runs it
157 * synchronously if so. It returns a boolean to indicate
158 * whether it had any scheduled work to run or not.
159 *
160 * NOTE! This _only_ works for normal work_structs. You
161 * CANNOT use this for delayed work, because the wq data
162 * for delayed work will not point properly to the per-
163 * CPU workqueue struct, but will change!
164 */
165int fastcall run_scheduled_work(struct work_struct *work)
166{
167 for (;;) {
168 struct cpu_workqueue_struct *cwq;
169
170 if (!work_pending(work))
171 return 0;
172 if (list_empty(&work->entry))
173 return 0;
174 /* NOTE! This depends intimately on __queue_work! */
175 cwq = get_wq_data(work);
176 if (!cwq)
177 return 0;
178 if (__run_work(cwq, work))
179 return 1;
180 }
181}
182EXPORT_SYMBOL(run_scheduled_work);
183
106/* Preempt must be disabled. */ 184/* Preempt must be disabled. */
107static void __queue_work(struct cpu_workqueue_struct *cwq, 185static void __queue_work(struct cpu_workqueue_struct *cwq,
108 struct work_struct *work) 186 struct work_struct *work)
@@ -250,6 +328,17 @@ static void run_workqueue(struct cpu_workqueue_struct *cwq)
250 work_release(work); 328 work_release(work);
251 f(work); 329 f(work);
252 330
331 if (unlikely(in_atomic() || lockdep_depth(current) > 0)) {
332 printk(KERN_ERR "BUG: workqueue leaked lock or atomic: "
333 "%s/0x%08x/%d\n",
334 current->comm, preempt_count(),
335 current->pid);
336 printk(KERN_ERR " last function: ");
337 print_symbol("%s\n", (unsigned long)f);
338 debug_show_held_locks(current);
339 dump_stack();
340 }
341
253 spin_lock_irqsave(&cwq->lock, flags); 342 spin_lock_irqsave(&cwq->lock, flags);
254 cwq->remove_sequence++; 343 cwq->remove_sequence++;
255 wake_up(&cwq->work_done); 344 wake_up(&cwq->work_done);
@@ -265,7 +354,8 @@ static int worker_thread(void *__cwq)
265 struct k_sigaction sa; 354 struct k_sigaction sa;
266 sigset_t blocked; 355 sigset_t blocked;
267 356
268 current->flags |= PF_NOFREEZE; 357 if (!cwq->freezeable)
358 current->flags |= PF_NOFREEZE;
269 359
270 set_user_nice(current, -5); 360 set_user_nice(current, -5);
271 361
@@ -288,6 +378,9 @@ static int worker_thread(void *__cwq)
288 378
289 set_current_state(TASK_INTERRUPTIBLE); 379 set_current_state(TASK_INTERRUPTIBLE);
290 while (!kthread_should_stop()) { 380 while (!kthread_should_stop()) {
381 if (cwq->freezeable)
382 try_to_freeze();
383
291 add_wait_queue(&cwq->more_work, &wait); 384 add_wait_queue(&cwq->more_work, &wait);
292 if (list_empty(&cwq->worklist)) 385 if (list_empty(&cwq->worklist))
293 schedule(); 386 schedule();
@@ -364,7 +457,7 @@ void fastcall flush_workqueue(struct workqueue_struct *wq)
364EXPORT_SYMBOL_GPL(flush_workqueue); 457EXPORT_SYMBOL_GPL(flush_workqueue);
365 458
366static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq, 459static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
367 int cpu) 460 int cpu, int freezeable)
368{ 461{
369 struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu); 462 struct cpu_workqueue_struct *cwq = per_cpu_ptr(wq->cpu_wq, cpu);
370 struct task_struct *p; 463 struct task_struct *p;
@@ -374,6 +467,7 @@ static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
374 cwq->thread = NULL; 467 cwq->thread = NULL;
375 cwq->insert_sequence = 0; 468 cwq->insert_sequence = 0;
376 cwq->remove_sequence = 0; 469 cwq->remove_sequence = 0;
470 cwq->freezeable = freezeable;
377 INIT_LIST_HEAD(&cwq->worklist); 471 INIT_LIST_HEAD(&cwq->worklist);
378 init_waitqueue_head(&cwq->more_work); 472 init_waitqueue_head(&cwq->more_work);
379 init_waitqueue_head(&cwq->work_done); 473 init_waitqueue_head(&cwq->work_done);
@@ -389,7 +483,7 @@ static struct task_struct *create_workqueue_thread(struct workqueue_struct *wq,
389} 483}
390 484
391struct workqueue_struct *__create_workqueue(const char *name, 485struct workqueue_struct *__create_workqueue(const char *name,
392 int singlethread) 486 int singlethread, int freezeable)
393{ 487{
394 int cpu, destroy = 0; 488 int cpu, destroy = 0;
395 struct workqueue_struct *wq; 489 struct workqueue_struct *wq;
@@ -409,7 +503,7 @@ struct workqueue_struct *__create_workqueue(const char *name,
409 mutex_lock(&workqueue_mutex); 503 mutex_lock(&workqueue_mutex);
410 if (singlethread) { 504 if (singlethread) {
411 INIT_LIST_HEAD(&wq->list); 505 INIT_LIST_HEAD(&wq->list);
412 p = create_workqueue_thread(wq, singlethread_cpu); 506 p = create_workqueue_thread(wq, singlethread_cpu, freezeable);
413 if (!p) 507 if (!p)
414 destroy = 1; 508 destroy = 1;
415 else 509 else
@@ -417,7 +511,7 @@ struct workqueue_struct *__create_workqueue(const char *name,
417 } else { 511 } else {
418 list_add(&wq->list, &workqueues); 512 list_add(&wq->list, &workqueues);
419 for_each_online_cpu(cpu) { 513 for_each_online_cpu(cpu) {
420 p = create_workqueue_thread(wq, cpu); 514 p = create_workqueue_thread(wq, cpu, freezeable);
421 if (p) { 515 if (p) {
422 kthread_bind(p, cpu); 516 kthread_bind(p, cpu);
423 wake_up_process(p); 517 wake_up_process(p);
@@ -634,7 +728,6 @@ int current_is_keventd(void)
634 728
635} 729}
636 730
637#ifdef CONFIG_HOTPLUG_CPU
638/* Take the work from this (downed) CPU. */ 731/* Take the work from this (downed) CPU. */
639static void take_over_work(struct workqueue_struct *wq, unsigned int cpu) 732static void take_over_work(struct workqueue_struct *wq, unsigned int cpu)
640{ 733{
@@ -667,7 +760,7 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
667 mutex_lock(&workqueue_mutex); 760 mutex_lock(&workqueue_mutex);
668 /* Create a new workqueue thread for it. */ 761 /* Create a new workqueue thread for it. */
669 list_for_each_entry(wq, &workqueues, list) { 762 list_for_each_entry(wq, &workqueues, list) {
670 if (!create_workqueue_thread(wq, hotcpu)) { 763 if (!create_workqueue_thread(wq, hotcpu, 0)) {
671 printk("workqueue for %i failed\n", hotcpu); 764 printk("workqueue for %i failed\n", hotcpu);
672 return NOTIFY_BAD; 765 return NOTIFY_BAD;
673 } 766 }
@@ -717,7 +810,6 @@ static int __devinit workqueue_cpu_callback(struct notifier_block *nfb,
717 810
718 return NOTIFY_OK; 811 return NOTIFY_OK;
719} 812}
720#endif
721 813
722void init_workqueues(void) 814void init_workqueues(void)
723{ 815{
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index d3679103a8e4..b75fed737f25 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1,6 +1,7 @@
1 1
2config PRINTK_TIME 2config PRINTK_TIME
3 bool "Show timing information on printks" 3 bool "Show timing information on printks"
4 depends on PRINTK
4 help 5 help
5 Selecting this option causes timing information to be 6 Selecting this option causes timing information to be
6 included in printk output. This allows you to measure 7 included in printk output. This allows you to measure
diff --git a/lib/Makefile b/lib/Makefile
index cf98fabaa549..fea8f9035f07 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -25,7 +25,7 @@ lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
25lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o 25lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
26lib-$(CONFIG_SEMAPHORE_SLEEPERS) += semaphore-sleepers.o 26lib-$(CONFIG_SEMAPHORE_SLEEPERS) += semaphore-sleepers.o
27lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o 27lib-$(CONFIG_GENERIC_FIND_NEXT_BIT) += find_next_bit.o
28lib-$(CONFIG_GENERIC_HWEIGHT) += hweight.o 28obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
29obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o 29obj-$(CONFIG_LOCK_KERNEL) += kernel_lock.o
30obj-$(CONFIG_PLIST) += plist.o 30obj-$(CONFIG_PLIST) += plist.o
31obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o 31obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
diff --git a/lib/cmdline.c b/lib/cmdline.c
index 0331ed825ea7..8a5b5303bd4f 100644
--- a/lib/cmdline.c
+++ b/lib/cmdline.c
@@ -16,6 +16,23 @@
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/string.h> 17#include <linux/string.h>
18 18
19/*
20 * If a hyphen was found in get_option, this will handle the
21 * range of numbers, M-N. This will expand the range and insert
22 * the values[M, M+1, ..., N] into the ints array in get_options.
23 */
24
25static int get_range(char **str, int *pint)
26{
27 int x, inc_counter, upper_range;
28
29 (*str)++;
30 upper_range = simple_strtol((*str), NULL, 0);
31 inc_counter = upper_range - *pint;
32 for (x = *pint; x < upper_range; x++)
33 *pint++ = x;
34 return inc_counter;
35}
19 36
20/** 37/**
21 * get_option - Parse integer from an option string 38 * get_option - Parse integer from an option string
@@ -29,6 +46,7 @@
29 * 0 : no int in string 46 * 0 : no int in string
30 * 1 : int found, no subsequent comma 47 * 1 : int found, no subsequent comma
31 * 2 : int found including a subsequent comma 48 * 2 : int found including a subsequent comma
49 * 3 : hyphen found to denote a range
32 */ 50 */
33 51
34int get_option (char **str, int *pint) 52int get_option (char **str, int *pint)
@@ -44,6 +62,8 @@ int get_option (char **str, int *pint)
44 (*str)++; 62 (*str)++;
45 return 2; 63 return 2;
46 } 64 }
65 if (**str == '-')
66 return 3;
47 67
48 return 1; 68 return 1;
49} 69}
@@ -55,7 +75,8 @@ int get_option (char **str, int *pint)
55 * @ints: integer array 75 * @ints: integer array
56 * 76 *
57 * This function parses a string containing a comma-separated 77 * This function parses a string containing a comma-separated
58 * list of integers. The parse halts when the array is 78 * list of integers, a hyphen-separated range of _positive_ integers,
79 * or a combination of both. The parse halts when the array is
59 * full, or when no more numbers can be retrieved from the 80 * full, or when no more numbers can be retrieved from the
60 * string. 81 * string.
61 * 82 *
@@ -72,6 +93,18 @@ char *get_options(const char *str, int nints, int *ints)
72 res = get_option ((char **)&str, ints + i); 93 res = get_option ((char **)&str, ints + i);
73 if (res == 0) 94 if (res == 0)
74 break; 95 break;
96 if (res == 3) {
97 int range_nums;
98 range_nums = get_range((char **)&str, ints + i);
99 if (range_nums < 0)
100 break;
101 /*
102 * Decrement the result by one to leave out the
103 * last number in the range. The next iteration
104 * will handle the upper number in the range
105 */
106 i += (range_nums - 1);
107 }
75 i++; 108 i++;
76 if (res == 1) 109 if (res == 1)
77 break; 110 break;
diff --git a/lib/idr.c b/lib/idr.c
index 16d2143fea48..71853531d3b0 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -33,7 +33,7 @@
33#include <linux/string.h> 33#include <linux/string.h>
34#include <linux/idr.h> 34#include <linux/idr.h>
35 35
36static kmem_cache_t *idr_layer_cache; 36static struct kmem_cache *idr_layer_cache;
37 37
38static struct idr_layer *alloc_layer(struct idr *idp) 38static struct idr_layer *alloc_layer(struct idr *idp)
39{ 39{
@@ -445,7 +445,7 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
445} 445}
446EXPORT_SYMBOL(idr_replace); 446EXPORT_SYMBOL(idr_replace);
447 447
448static void idr_cache_ctor(void * idr_layer, kmem_cache_t *idr_layer_cache, 448static void idr_cache_ctor(void * idr_layer, struct kmem_cache *idr_layer_cache,
449 unsigned long flags) 449 unsigned long flags)
450{ 450{
451 memset(idr_layer, 0, sizeof(struct idr_layer)); 451 memset(idr_layer, 0, sizeof(struct idr_layer));
diff --git a/lib/kobject.c b/lib/kobject.c
index 744a4b102c7f..7ce6dc138e90 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -111,10 +111,9 @@ char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
111 len = get_kobj_path_length(kobj); 111 len = get_kobj_path_length(kobj);
112 if (len == 0) 112 if (len == 0)
113 return NULL; 113 return NULL;
114 path = kmalloc(len, gfp_mask); 114 path = kzalloc(len, gfp_mask);
115 if (!path) 115 if (!path)
116 return NULL; 116 return NULL;
117 memset(path, 0x00, len);
118 fill_kobj_path(kobj, path, len); 117 fill_kobj_path(kobj, path, len);
119 118
120 return path; 119 return path;
diff --git a/lib/list_debug.c b/lib/list_debug.c
index 7ba9d823d388..4350ba9655bd 100644
--- a/lib/list_debug.c
+++ b/lib/list_debug.c
@@ -21,13 +21,15 @@ void __list_add(struct list_head *new,
21 struct list_head *next) 21 struct list_head *next)
22{ 22{
23 if (unlikely(next->prev != prev)) { 23 if (unlikely(next->prev != prev)) {
24 printk(KERN_ERR "list_add corruption. next->prev should be %p, but was %p\n", 24 printk(KERN_ERR "list_add corruption. next->prev should be "
25 prev, next->prev); 25 "prev (%p), but was %p. (next=%p).\n",
26 prev, next->prev, next);
26 BUG(); 27 BUG();
27 } 28 }
28 if (unlikely(prev->next != next)) { 29 if (unlikely(prev->next != next)) {
29 printk(KERN_ERR "list_add corruption. prev->next should be %p, but was %p\n", 30 printk(KERN_ERR "list_add corruption. prev->next should be "
30 next, prev->next); 31 "next (%p), but was %p. (prev=%p).\n",
32 next, prev->next, prev);
31 BUG(); 33 BUG();
32 } 34 }
33 next->prev = new; 35 next->prev = new;
diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c
index 7945787f439a..280332c1827c 100644
--- a/lib/locking-selftest.c
+++ b/lib/locking-selftest.c
@@ -963,7 +963,9 @@ static void dotest(void (*testcase_fn)(void), int expected, int lockclass_mask)
963 printk("failed|"); 963 printk("failed|");
964 } else { 964 } else {
965 unexpected_testcase_failures++; 965 unexpected_testcase_failures++;
966
966 printk("FAILED|"); 967 printk("FAILED|");
968 dump_stack();
967 } 969 }
968 } else { 970 } else {
969 testcase_successes++; 971 testcase_successes++;
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index aa9bfd0bdbd1..d69ddbe43865 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -2,6 +2,7 @@
2 * Copyright (C) 2001 Momchil Velikov 2 * Copyright (C) 2001 Momchil Velikov
3 * Portions Copyright (C) 2001 Christoph Hellwig 3 * Portions Copyright (C) 2001 Christoph Hellwig
4 * Copyright (C) 2005 SGI, Christoph Lameter <clameter@sgi.com> 4 * Copyright (C) 2005 SGI, Christoph Lameter <clameter@sgi.com>
5 * Copyright (C) 2006 Nick Piggin
5 * 6 *
6 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
@@ -30,6 +31,7 @@
30#include <linux/gfp.h> 31#include <linux/gfp.h>
31#include <linux/string.h> 32#include <linux/string.h>
32#include <linux/bitops.h> 33#include <linux/bitops.h>
34#include <linux/rcupdate.h>
33 35
34 36
35#ifdef __KERNEL__ 37#ifdef __KERNEL__
@@ -45,7 +47,9 @@
45 ((RADIX_TREE_MAP_SIZE + BITS_PER_LONG - 1) / BITS_PER_LONG) 47 ((RADIX_TREE_MAP_SIZE + BITS_PER_LONG - 1) / BITS_PER_LONG)
46 48
47struct radix_tree_node { 49struct radix_tree_node {
50 unsigned int height; /* Height from the bottom */
48 unsigned int count; 51 unsigned int count;
52 struct rcu_head rcu_head;
49 void *slots[RADIX_TREE_MAP_SIZE]; 53 void *slots[RADIX_TREE_MAP_SIZE];
50 unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS]; 54 unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS];
51}; 55};
@@ -63,7 +67,7 @@ static unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH] __read_mostly;
63/* 67/*
64 * Radix tree node cache. 68 * Radix tree node cache.
65 */ 69 */
66static kmem_cache_t *radix_tree_node_cachep; 70static struct kmem_cache *radix_tree_node_cachep;
67 71
68/* 72/*
69 * Per-cpu pool of preloaded nodes 73 * Per-cpu pool of preloaded nodes
@@ -100,13 +104,21 @@ radix_tree_node_alloc(struct radix_tree_root *root)
100 rtp->nr--; 104 rtp->nr--;
101 } 105 }
102 } 106 }
107 BUG_ON(radix_tree_is_direct_ptr(ret));
103 return ret; 108 return ret;
104} 109}
105 110
111static void radix_tree_node_rcu_free(struct rcu_head *head)
112{
113 struct radix_tree_node *node =
114 container_of(head, struct radix_tree_node, rcu_head);
115 kmem_cache_free(radix_tree_node_cachep, node);
116}
117
106static inline void 118static inline void
107radix_tree_node_free(struct radix_tree_node *node) 119radix_tree_node_free(struct radix_tree_node *node)
108{ 120{
109 kmem_cache_free(radix_tree_node_cachep, node); 121 call_rcu(&node->rcu_head, radix_tree_node_rcu_free);
110} 122}
111 123
112/* 124/*
@@ -222,11 +234,12 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
222 } 234 }
223 235
224 do { 236 do {
237 unsigned int newheight;
225 if (!(node = radix_tree_node_alloc(root))) 238 if (!(node = radix_tree_node_alloc(root)))
226 return -ENOMEM; 239 return -ENOMEM;
227 240
228 /* Increase the height. */ 241 /* Increase the height. */
229 node->slots[0] = root->rnode; 242 node->slots[0] = radix_tree_direct_to_ptr(root->rnode);
230 243
231 /* Propagate the aggregated tag info into the new root */ 244 /* Propagate the aggregated tag info into the new root */
232 for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) { 245 for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
@@ -234,9 +247,11 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
234 tag_set(node, tag, 0); 247 tag_set(node, tag, 0);
235 } 248 }
236 249
250 newheight = root->height+1;
251 node->height = newheight;
237 node->count = 1; 252 node->count = 1;
238 root->rnode = node; 253 rcu_assign_pointer(root->rnode, node);
239 root->height++; 254 root->height = newheight;
240 } while (height > root->height); 255 } while (height > root->height);
241out: 256out:
242 return 0; 257 return 0;
@@ -258,6 +273,8 @@ int radix_tree_insert(struct radix_tree_root *root,
258 int offset; 273 int offset;
259 int error; 274 int error;
260 275
276 BUG_ON(radix_tree_is_direct_ptr(item));
277
261 /* Make sure the tree is high enough. */ 278 /* Make sure the tree is high enough. */
262 if (index > radix_tree_maxindex(root->height)) { 279 if (index > radix_tree_maxindex(root->height)) {
263 error = radix_tree_extend(root, index); 280 error = radix_tree_extend(root, index);
@@ -275,11 +292,12 @@ int radix_tree_insert(struct radix_tree_root *root,
275 /* Have to add a child node. */ 292 /* Have to add a child node. */
276 if (!(slot = radix_tree_node_alloc(root))) 293 if (!(slot = radix_tree_node_alloc(root)))
277 return -ENOMEM; 294 return -ENOMEM;
295 slot->height = height;
278 if (node) { 296 if (node) {
279 node->slots[offset] = slot; 297 rcu_assign_pointer(node->slots[offset], slot);
280 node->count++; 298 node->count++;
281 } else 299 } else
282 root->rnode = slot; 300 rcu_assign_pointer(root->rnode, slot);
283 } 301 }
284 302
285 /* Go a level down */ 303 /* Go a level down */
@@ -295,11 +313,11 @@ int radix_tree_insert(struct radix_tree_root *root,
295 313
296 if (node) { 314 if (node) {
297 node->count++; 315 node->count++;
298 node->slots[offset] = item; 316 rcu_assign_pointer(node->slots[offset], item);
299 BUG_ON(tag_get(node, 0, offset)); 317 BUG_ON(tag_get(node, 0, offset));
300 BUG_ON(tag_get(node, 1, offset)); 318 BUG_ON(tag_get(node, 1, offset));
301 } else { 319 } else {
302 root->rnode = item; 320 rcu_assign_pointer(root->rnode, radix_tree_ptr_to_direct(item));
303 BUG_ON(root_tag_get(root, 0)); 321 BUG_ON(root_tag_get(root, 0));
304 BUG_ON(root_tag_get(root, 1)); 322 BUG_ON(root_tag_get(root, 1));
305 } 323 }
@@ -308,49 +326,54 @@ int radix_tree_insert(struct radix_tree_root *root,
308} 326}
309EXPORT_SYMBOL(radix_tree_insert); 327EXPORT_SYMBOL(radix_tree_insert);
310 328
311static inline void **__lookup_slot(struct radix_tree_root *root, 329/**
312 unsigned long index) 330 * radix_tree_lookup_slot - lookup a slot in a radix tree
331 * @root: radix tree root
332 * @index: index key
333 *
334 * Returns: the slot corresponding to the position @index in the
335 * radix tree @root. This is useful for update-if-exists operations.
336 *
337 * This function cannot be called under rcu_read_lock, it must be
338 * excluded from writers, as must the returned slot for subsequent
339 * use by radix_tree_deref_slot() and radix_tree_replace slot.
340 * Caller must hold tree write locked across slot lookup and
341 * replace.
342 */
343void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
313{ 344{
314 unsigned int height, shift; 345 unsigned int height, shift;
315 struct radix_tree_node **slot; 346 struct radix_tree_node *node, **slot;
316
317 height = root->height;
318 347
319 if (index > radix_tree_maxindex(height)) 348 node = root->rnode;
349 if (node == NULL)
320 return NULL; 350 return NULL;
321 351
322 if (height == 0 && root->rnode) 352 if (radix_tree_is_direct_ptr(node)) {
353 if (index > 0)
354 return NULL;
323 return (void **)&root->rnode; 355 return (void **)&root->rnode;
356 }
357
358 height = node->height;
359 if (index > radix_tree_maxindex(height))
360 return NULL;
324 361
325 shift = (height-1) * RADIX_TREE_MAP_SHIFT; 362 shift = (height-1) * RADIX_TREE_MAP_SHIFT;
326 slot = &root->rnode;
327 363
328 while (height > 0) { 364 do {
329 if (*slot == NULL) 365 slot = (struct radix_tree_node **)
366 (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK));
367 node = *slot;
368 if (node == NULL)
330 return NULL; 369 return NULL;
331 370
332 slot = (struct radix_tree_node **)
333 ((*slot)->slots +
334 ((index >> shift) & RADIX_TREE_MAP_MASK));
335 shift -= RADIX_TREE_MAP_SHIFT; 371 shift -= RADIX_TREE_MAP_SHIFT;
336 height--; 372 height--;
337 } 373 } while (height > 0);
338 374
339 return (void **)slot; 375 return (void **)slot;
340} 376}
341
342/**
343 * radix_tree_lookup_slot - lookup a slot in a radix tree
344 * @root: radix tree root
345 * @index: index key
346 *
347 * Lookup the slot corresponding to the position @index in the radix tree
348 * @root. This is useful for update-if-exists operations.
349 */
350void **radix_tree_lookup_slot(struct radix_tree_root *root, unsigned long index)
351{
352 return __lookup_slot(root, index);
353}
354EXPORT_SYMBOL(radix_tree_lookup_slot); 377EXPORT_SYMBOL(radix_tree_lookup_slot);
355 378
356/** 379/**
@@ -359,13 +382,45 @@ EXPORT_SYMBOL(radix_tree_lookup_slot);
359 * @index: index key 382 * @index: index key
360 * 383 *
361 * Lookup the item at the position @index in the radix tree @root. 384 * Lookup the item at the position @index in the radix tree @root.
385 *
386 * This function can be called under rcu_read_lock, however the caller
387 * must manage lifetimes of leaf nodes (eg. RCU may also be used to free
388 * them safely). No RCU barriers are required to access or modify the
389 * returned item, however.
362 */ 390 */
363void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index) 391void *radix_tree_lookup(struct radix_tree_root *root, unsigned long index)
364{ 392{
365 void **slot; 393 unsigned int height, shift;
394 struct radix_tree_node *node, **slot;
395
396 node = rcu_dereference(root->rnode);
397 if (node == NULL)
398 return NULL;
399
400 if (radix_tree_is_direct_ptr(node)) {
401 if (index > 0)
402 return NULL;
403 return radix_tree_direct_to_ptr(node);
404 }
405
406 height = node->height;
407 if (index > radix_tree_maxindex(height))
408 return NULL;
409
410 shift = (height-1) * RADIX_TREE_MAP_SHIFT;
366 411
367 slot = __lookup_slot(root, index); 412 do {
368 return slot != NULL ? *slot : NULL; 413 slot = (struct radix_tree_node **)
414 (node->slots + ((index>>shift) & RADIX_TREE_MAP_MASK));
415 node = rcu_dereference(*slot);
416 if (node == NULL)
417 return NULL;
418
419 shift -= RADIX_TREE_MAP_SHIFT;
420 height--;
421 } while (height > 0);
422
423 return node;
369} 424}
370EXPORT_SYMBOL(radix_tree_lookup); 425EXPORT_SYMBOL(radix_tree_lookup);
371 426
@@ -495,27 +550,30 @@ int radix_tree_tag_get(struct radix_tree_root *root,
495 unsigned long index, unsigned int tag) 550 unsigned long index, unsigned int tag)
496{ 551{
497 unsigned int height, shift; 552 unsigned int height, shift;
498 struct radix_tree_node *slot; 553 struct radix_tree_node *node;
499 int saw_unset_tag = 0; 554 int saw_unset_tag = 0;
500 555
501 height = root->height;
502 if (index > radix_tree_maxindex(height))
503 return 0;
504
505 /* check the root's tag bit */ 556 /* check the root's tag bit */
506 if (!root_tag_get(root, tag)) 557 if (!root_tag_get(root, tag))
507 return 0; 558 return 0;
508 559
509 if (height == 0) 560 node = rcu_dereference(root->rnode);
510 return 1; 561 if (node == NULL)
562 return 0;
563
564 if (radix_tree_is_direct_ptr(node))
565 return (index == 0);
566
567 height = node->height;
568 if (index > radix_tree_maxindex(height))
569 return 0;
511 570
512 shift = (height - 1) * RADIX_TREE_MAP_SHIFT; 571 shift = (height - 1) * RADIX_TREE_MAP_SHIFT;
513 slot = root->rnode;
514 572
515 for ( ; ; ) { 573 for ( ; ; ) {
516 int offset; 574 int offset;
517 575
518 if (slot == NULL) 576 if (node == NULL)
519 return 0; 577 return 0;
520 578
521 offset = (index >> shift) & RADIX_TREE_MAP_MASK; 579 offset = (index >> shift) & RADIX_TREE_MAP_MASK;
@@ -524,15 +582,15 @@ int radix_tree_tag_get(struct radix_tree_root *root,
524 * This is just a debug check. Later, we can bale as soon as 582 * This is just a debug check. Later, we can bale as soon as
525 * we see an unset tag. 583 * we see an unset tag.
526 */ 584 */
527 if (!tag_get(slot, tag, offset)) 585 if (!tag_get(node, tag, offset))
528 saw_unset_tag = 1; 586 saw_unset_tag = 1;
529 if (height == 1) { 587 if (height == 1) {
530 int ret = tag_get(slot, tag, offset); 588 int ret = tag_get(node, tag, offset);
531 589
532 BUG_ON(ret && saw_unset_tag); 590 BUG_ON(ret && saw_unset_tag);
533 return !!ret; 591 return !!ret;
534 } 592 }
535 slot = slot->slots[offset]; 593 node = rcu_dereference(node->slots[offset]);
536 shift -= RADIX_TREE_MAP_SHIFT; 594 shift -= RADIX_TREE_MAP_SHIFT;
537 height--; 595 height--;
538 } 596 }
@@ -541,47 +599,45 @@ EXPORT_SYMBOL(radix_tree_tag_get);
541#endif 599#endif
542 600
543static unsigned int 601static unsigned int
544__lookup(struct radix_tree_root *root, void **results, unsigned long index, 602__lookup(struct radix_tree_node *slot, void **results, unsigned long index,
545 unsigned int max_items, unsigned long *next_index) 603 unsigned int max_items, unsigned long *next_index)
546{ 604{
547 unsigned int nr_found = 0; 605 unsigned int nr_found = 0;
548 unsigned int shift, height; 606 unsigned int shift, height;
549 struct radix_tree_node *slot;
550 unsigned long i; 607 unsigned long i;
551 608
552 height = root->height; 609 height = slot->height;
553 if (height == 0) { 610 if (height == 0)
554 if (root->rnode && index == 0)
555 results[nr_found++] = root->rnode;
556 goto out; 611 goto out;
557 }
558
559 shift = (height-1) * RADIX_TREE_MAP_SHIFT; 612 shift = (height-1) * RADIX_TREE_MAP_SHIFT;
560 slot = root->rnode;
561 613
562 for ( ; height > 1; height--) { 614 for ( ; height > 1; height--) {
563 615 i = (index >> shift) & RADIX_TREE_MAP_MASK;
564 for (i = (index >> shift) & RADIX_TREE_MAP_MASK ; 616 for (;;) {
565 i < RADIX_TREE_MAP_SIZE; i++) {
566 if (slot->slots[i] != NULL) 617 if (slot->slots[i] != NULL)
567 break; 618 break;
568 index &= ~((1UL << shift) - 1); 619 index &= ~((1UL << shift) - 1);
569 index += 1UL << shift; 620 index += 1UL << shift;
570 if (index == 0) 621 if (index == 0)
571 goto out; /* 32-bit wraparound */ 622 goto out; /* 32-bit wraparound */
623 i++;
624 if (i == RADIX_TREE_MAP_SIZE)
625 goto out;
572 } 626 }
573 if (i == RADIX_TREE_MAP_SIZE)
574 goto out;
575 627
576 shift -= RADIX_TREE_MAP_SHIFT; 628 shift -= RADIX_TREE_MAP_SHIFT;
577 slot = slot->slots[i]; 629 slot = rcu_dereference(slot->slots[i]);
630 if (slot == NULL)
631 goto out;
578 } 632 }
579 633
580 /* Bottom level: grab some items */ 634 /* Bottom level: grab some items */
581 for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) { 635 for (i = index & RADIX_TREE_MAP_MASK; i < RADIX_TREE_MAP_SIZE; i++) {
636 struct radix_tree_node *node;
582 index++; 637 index++;
583 if (slot->slots[i]) { 638 node = slot->slots[i];
584 results[nr_found++] = slot->slots[i]; 639 if (node) {
640 results[nr_found++] = rcu_dereference(node);
585 if (nr_found == max_items) 641 if (nr_found == max_items)
586 goto out; 642 goto out;
587 } 643 }
@@ -603,28 +659,51 @@ out:
603 * *@results. 659 * *@results.
604 * 660 *
605 * The implementation is naive. 661 * The implementation is naive.
662 *
663 * Like radix_tree_lookup, radix_tree_gang_lookup may be called under
664 * rcu_read_lock. In this case, rather than the returned results being
665 * an atomic snapshot of the tree at a single point in time, the semantics
666 * of an RCU protected gang lookup are as though multiple radix_tree_lookups
667 * have been issued in individual locks, and results stored in 'results'.
606 */ 668 */
607unsigned int 669unsigned int
608radix_tree_gang_lookup(struct radix_tree_root *root, void **results, 670radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
609 unsigned long first_index, unsigned int max_items) 671 unsigned long first_index, unsigned int max_items)
610{ 672{
611 const unsigned long max_index = radix_tree_maxindex(root->height); 673 unsigned long max_index;
674 struct radix_tree_node *node;
612 unsigned long cur_index = first_index; 675 unsigned long cur_index = first_index;
613 unsigned int ret = 0; 676 unsigned int ret;
677
678 node = rcu_dereference(root->rnode);
679 if (!node)
680 return 0;
614 681
682 if (radix_tree_is_direct_ptr(node)) {
683 if (first_index > 0)
684 return 0;
685 node = radix_tree_direct_to_ptr(node);
686 results[0] = rcu_dereference(node);
687 return 1;
688 }
689
690 max_index = radix_tree_maxindex(node->height);
691
692 ret = 0;
615 while (ret < max_items) { 693 while (ret < max_items) {
616 unsigned int nr_found; 694 unsigned int nr_found;
617 unsigned long next_index; /* Index of next search */ 695 unsigned long next_index; /* Index of next search */
618 696
619 if (cur_index > max_index) 697 if (cur_index > max_index)
620 break; 698 break;
621 nr_found = __lookup(root, results + ret, cur_index, 699 nr_found = __lookup(node, results + ret, cur_index,
622 max_items - ret, &next_index); 700 max_items - ret, &next_index);
623 ret += nr_found; 701 ret += nr_found;
624 if (next_index == 0) 702 if (next_index == 0)
625 break; 703 break;
626 cur_index = next_index; 704 cur_index = next_index;
627 } 705 }
706
628 return ret; 707 return ret;
629} 708}
630EXPORT_SYMBOL(radix_tree_gang_lookup); 709EXPORT_SYMBOL(radix_tree_gang_lookup);
@@ -634,55 +713,64 @@ EXPORT_SYMBOL(radix_tree_gang_lookup);
634 * open-coding the search. 713 * open-coding the search.
635 */ 714 */
636static unsigned int 715static unsigned int
637__lookup_tag(struct radix_tree_root *root, void **results, unsigned long index, 716__lookup_tag(struct radix_tree_node *slot, void **results, unsigned long index,
638 unsigned int max_items, unsigned long *next_index, unsigned int tag) 717 unsigned int max_items, unsigned long *next_index, unsigned int tag)
639{ 718{
640 unsigned int nr_found = 0; 719 unsigned int nr_found = 0;
641 unsigned int shift; 720 unsigned int shift, height;
642 unsigned int height = root->height;
643 struct radix_tree_node *slot;
644 721
645 if (height == 0) { 722 height = slot->height;
646 if (root->rnode && index == 0) 723 if (height == 0)
647 results[nr_found++] = root->rnode;
648 goto out; 724 goto out;
649 } 725 shift = (height-1) * RADIX_TREE_MAP_SHIFT;
650
651 shift = (height - 1) * RADIX_TREE_MAP_SHIFT;
652 slot = root->rnode;
653 726
654 do { 727 while (height > 0) {
655 unsigned long i = (index >> shift) & RADIX_TREE_MAP_MASK; 728 unsigned long i = (index >> shift) & RADIX_TREE_MAP_MASK ;
656 729
657 for ( ; i < RADIX_TREE_MAP_SIZE; i++) { 730 for (;;) {
658 if (tag_get(slot, tag, i)) { 731 if (tag_get(slot, tag, i))
659 BUG_ON(slot->slots[i] == NULL);
660 break; 732 break;
661 }
662 index &= ~((1UL << shift) - 1); 733 index &= ~((1UL << shift) - 1);
663 index += 1UL << shift; 734 index += 1UL << shift;
664 if (index == 0) 735 if (index == 0)
665 goto out; /* 32-bit wraparound */ 736 goto out; /* 32-bit wraparound */
737 i++;
738 if (i == RADIX_TREE_MAP_SIZE)
739 goto out;
666 } 740 }
667 if (i == RADIX_TREE_MAP_SIZE)
668 goto out;
669 height--; 741 height--;
670 if (height == 0) { /* Bottom level: grab some items */ 742 if (height == 0) { /* Bottom level: grab some items */
671 unsigned long j = index & RADIX_TREE_MAP_MASK; 743 unsigned long j = index & RADIX_TREE_MAP_MASK;
672 744
673 for ( ; j < RADIX_TREE_MAP_SIZE; j++) { 745 for ( ; j < RADIX_TREE_MAP_SIZE; j++) {
746 struct radix_tree_node *node;
674 index++; 747 index++;
675 if (tag_get(slot, tag, j)) { 748 if (!tag_get(slot, tag, j))
676 BUG_ON(slot->slots[j] == NULL); 749 continue;
677 results[nr_found++] = slot->slots[j]; 750 node = slot->slots[j];
751 /*
752 * Even though the tag was found set, we need to
753 * recheck that we have a non-NULL node, because
754 * if this lookup is lockless, it may have been
755 * subsequently deleted.
756 *
757 * Similar care must be taken in any place that
758 * lookup ->slots[x] without a lock (ie. can't
759 * rely on its value remaining the same).
760 */
761 if (node) {
762 node = rcu_dereference(node);
763 results[nr_found++] = node;
678 if (nr_found == max_items) 764 if (nr_found == max_items)
679 goto out; 765 goto out;
680 } 766 }
681 } 767 }
682 } 768 }
683 shift -= RADIX_TREE_MAP_SHIFT; 769 shift -= RADIX_TREE_MAP_SHIFT;
684 slot = slot->slots[i]; 770 slot = rcu_dereference(slot->slots[i]);
685 } while (height > 0); 771 if (slot == NULL)
772 break;
773 }
686out: 774out:
687 *next_index = index; 775 *next_index = index;
688 return nr_found; 776 return nr_found;
@@ -706,27 +794,44 @@ radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
706 unsigned long first_index, unsigned int max_items, 794 unsigned long first_index, unsigned int max_items,
707 unsigned int tag) 795 unsigned int tag)
708{ 796{
709 const unsigned long max_index = radix_tree_maxindex(root->height); 797 struct radix_tree_node *node;
798 unsigned long max_index;
710 unsigned long cur_index = first_index; 799 unsigned long cur_index = first_index;
711 unsigned int ret = 0; 800 unsigned int ret;
712 801
713 /* check the root's tag bit */ 802 /* check the root's tag bit */
714 if (!root_tag_get(root, tag)) 803 if (!root_tag_get(root, tag))
715 return 0; 804 return 0;
716 805
806 node = rcu_dereference(root->rnode);
807 if (!node)
808 return 0;
809
810 if (radix_tree_is_direct_ptr(node)) {
811 if (first_index > 0)
812 return 0;
813 node = radix_tree_direct_to_ptr(node);
814 results[0] = rcu_dereference(node);
815 return 1;
816 }
817
818 max_index = radix_tree_maxindex(node->height);
819
820 ret = 0;
717 while (ret < max_items) { 821 while (ret < max_items) {
718 unsigned int nr_found; 822 unsigned int nr_found;
719 unsigned long next_index; /* Index of next search */ 823 unsigned long next_index; /* Index of next search */
720 824
721 if (cur_index > max_index) 825 if (cur_index > max_index)
722 break; 826 break;
723 nr_found = __lookup_tag(root, results + ret, cur_index, 827 nr_found = __lookup_tag(node, results + ret, cur_index,
724 max_items - ret, &next_index, tag); 828 max_items - ret, &next_index, tag);
725 ret += nr_found; 829 ret += nr_found;
726 if (next_index == 0) 830 if (next_index == 0)
727 break; 831 break;
728 cur_index = next_index; 832 cur_index = next_index;
729 } 833 }
834
730 return ret; 835 return ret;
731} 836}
732EXPORT_SYMBOL(radix_tree_gang_lookup_tag); 837EXPORT_SYMBOL(radix_tree_gang_lookup_tag);
@@ -742,8 +847,19 @@ static inline void radix_tree_shrink(struct radix_tree_root *root)
742 root->rnode->count == 1 && 847 root->rnode->count == 1 &&
743 root->rnode->slots[0]) { 848 root->rnode->slots[0]) {
744 struct radix_tree_node *to_free = root->rnode; 849 struct radix_tree_node *to_free = root->rnode;
850 void *newptr;
745 851
746 root->rnode = to_free->slots[0]; 852 /*
853 * We don't need rcu_assign_pointer(), since we are simply
854 * moving the node from one part of the tree to another. If
855 * it was safe to dereference the old pointer to it
856 * (to_free->slots[0]), it will be safe to dereference the new
857 * one (root->rnode).
858 */
859 newptr = to_free->slots[0];
860 if (root->height == 1)
861 newptr = radix_tree_ptr_to_direct(newptr);
862 root->rnode = newptr;
747 root->height--; 863 root->height--;
748 /* must only free zeroed nodes into the slab */ 864 /* must only free zeroed nodes into the slab */
749 tag_clear(to_free, 0, 0); 865 tag_clear(to_free, 0, 0);
@@ -767,6 +883,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
767{ 883{
768 struct radix_tree_path path[RADIX_TREE_MAX_PATH], *pathp = path; 884 struct radix_tree_path path[RADIX_TREE_MAX_PATH], *pathp = path;
769 struct radix_tree_node *slot = NULL; 885 struct radix_tree_node *slot = NULL;
886 struct radix_tree_node *to_free;
770 unsigned int height, shift; 887 unsigned int height, shift;
771 int tag; 888 int tag;
772 int offset; 889 int offset;
@@ -777,6 +894,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
777 894
778 slot = root->rnode; 895 slot = root->rnode;
779 if (height == 0 && root->rnode) { 896 if (height == 0 && root->rnode) {
897 slot = radix_tree_direct_to_ptr(slot);
780 root_tag_clear_all(root); 898 root_tag_clear_all(root);
781 root->rnode = NULL; 899 root->rnode = NULL;
782 goto out; 900 goto out;
@@ -809,10 +927,17 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
809 radix_tree_tag_clear(root, index, tag); 927 radix_tree_tag_clear(root, index, tag);
810 } 928 }
811 929
930 to_free = NULL;
812 /* Now free the nodes we do not need anymore */ 931 /* Now free the nodes we do not need anymore */
813 while (pathp->node) { 932 while (pathp->node) {
814 pathp->node->slots[pathp->offset] = NULL; 933 pathp->node->slots[pathp->offset] = NULL;
815 pathp->node->count--; 934 pathp->node->count--;
935 /*
936 * Queue the node for deferred freeing after the
937 * last reference to it disappears (set NULL, above).
938 */
939 if (to_free)
940 radix_tree_node_free(to_free);
816 941
817 if (pathp->node->count) { 942 if (pathp->node->count) {
818 if (pathp->node == root->rnode) 943 if (pathp->node == root->rnode)
@@ -821,13 +946,15 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
821 } 946 }
822 947
823 /* Node with zero slots in use so free it */ 948 /* Node with zero slots in use so free it */
824 radix_tree_node_free(pathp->node); 949 to_free = pathp->node;
825
826 pathp--; 950 pathp--;
951
827 } 952 }
828 root_tag_clear_all(root); 953 root_tag_clear_all(root);
829 root->height = 0; 954 root->height = 0;
830 root->rnode = NULL; 955 root->rnode = NULL;
956 if (to_free)
957 radix_tree_node_free(to_free);
831 958
832out: 959out:
833 return slot; 960 return slot;
@@ -846,7 +973,7 @@ int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag)
846EXPORT_SYMBOL(radix_tree_tagged); 973EXPORT_SYMBOL(radix_tree_tagged);
847 974
848static void 975static void
849radix_tree_node_ctor(void *node, kmem_cache_t *cachep, unsigned long flags) 976radix_tree_node_ctor(void *node, struct kmem_cache *cachep, unsigned long flags)
850{ 977{
851 memset(node, 0, sizeof(struct radix_tree_node)); 978 memset(node, 0, sizeof(struct radix_tree_node));
852} 979}
@@ -869,7 +996,6 @@ static __init void radix_tree_init_maxindex(void)
869 height_to_maxindex[i] = __maxindex(i); 996 height_to_maxindex[i] = __maxindex(i);
870} 997}
871 998
872#ifdef CONFIG_HOTPLUG_CPU
873static int radix_tree_callback(struct notifier_block *nfb, 999static int radix_tree_callback(struct notifier_block *nfb,
874 unsigned long action, 1000 unsigned long action,
875 void *hcpu) 1001 void *hcpu)
@@ -889,7 +1015,6 @@ static int radix_tree_callback(struct notifier_block *nfb,
889 } 1015 }
890 return NOTIFY_OK; 1016 return NOTIFY_OK;
891} 1017}
892#endif /* CONFIG_HOTPLUG_CPU */
893 1018
894void __init radix_tree_init(void) 1019void __init radix_tree_init(void)
895{ 1020{
diff --git a/lib/spinlock_debug.c b/lib/spinlock_debug.c
index b6c4f898197c..479fd462eaa9 100644
--- a/lib/spinlock_debug.c
+++ b/lib/spinlock_debug.c
@@ -7,6 +7,7 @@
7 */ 7 */
8 8
9#include <linux/spinlock.h> 9#include <linux/spinlock.h>
10#include <linux/nmi.h>
10#include <linux/interrupt.h> 11#include <linux/interrupt.h>
11#include <linux/debug_locks.h> 12#include <linux/debug_locks.h>
12#include <linux/delay.h> 13#include <linux/delay.h>
@@ -117,6 +118,9 @@ static void __spin_lock_debug(spinlock_t *lock)
117 raw_smp_processor_id(), current->comm, 118 raw_smp_processor_id(), current->comm,
118 current->pid, lock); 119 current->pid, lock);
119 dump_stack(); 120 dump_stack();
121#ifdef CONFIG_SMP
122 trigger_all_cpu_backtrace();
123#endif
120 } 124 }
121 } 125 }
122} 126}
diff --git a/mm/allocpercpu.c b/mm/allocpercpu.c
index eaa9abeea536..b2486cf887a0 100644
--- a/mm/allocpercpu.c
+++ b/mm/allocpercpu.c
@@ -17,10 +17,9 @@
17void percpu_depopulate(void *__pdata, int cpu) 17void percpu_depopulate(void *__pdata, int cpu)
18{ 18{
19 struct percpu_data *pdata = __percpu_disguise(__pdata); 19 struct percpu_data *pdata = __percpu_disguise(__pdata);
20 if (pdata->ptrs[cpu]) { 20
21 kfree(pdata->ptrs[cpu]); 21 kfree(pdata->ptrs[cpu]);
22 pdata->ptrs[cpu] = NULL; 22 pdata->ptrs[cpu] = NULL;
23 }
24} 23}
25EXPORT_SYMBOL_GPL(percpu_depopulate); 24EXPORT_SYMBOL_GPL(percpu_depopulate);
26 25
@@ -123,6 +122,8 @@ EXPORT_SYMBOL_GPL(__percpu_alloc_mask);
123 */ 122 */
124void percpu_free(void *__pdata) 123void percpu_free(void *__pdata)
125{ 124{
125 if (unlikely(!__pdata))
126 return;
126 __percpu_depopulate_mask(__pdata, &cpu_possible_map); 127 __percpu_depopulate_mask(__pdata, &cpu_possible_map);
127 kfree(__percpu_disguise(__pdata)); 128 kfree(__percpu_disguise(__pdata));
128} 129}
diff --git a/mm/bootmem.c b/mm/bootmem.c
index d53112fcb404..00a96970b237 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -27,8 +27,6 @@ unsigned long max_low_pfn;
27unsigned long min_low_pfn; 27unsigned long min_low_pfn;
28unsigned long max_pfn; 28unsigned long max_pfn;
29 29
30EXPORT_UNUSED_SYMBOL(max_pfn); /* June 2006 */
31
32static LIST_HEAD(bdata_list); 30static LIST_HEAD(bdata_list);
33#ifdef CONFIG_CRASH_DUMP 31#ifdef CONFIG_CRASH_DUMP
34/* 32/*
@@ -196,6 +194,10 @@ __alloc_bootmem_core(struct bootmem_data *bdata, unsigned long size,
196 if (limit && bdata->node_boot_start >= limit) 194 if (limit && bdata->node_boot_start >= limit)
197 return NULL; 195 return NULL;
198 196
197 /* on nodes without memory - bootmem_map is NULL */
198 if (!bdata->node_bootmem_map)
199 return NULL;
200
199 end_pfn = bdata->node_low_pfn; 201 end_pfn = bdata->node_low_pfn;
200 limit = PFN_DOWN(limit); 202 limit = PFN_DOWN(limit);
201 if (limit && end_pfn > limit) 203 if (limit && end_pfn > limit)
diff --git a/mm/filemap.c b/mm/filemap.c
index 13df01c50479..af7e2f5caea9 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1445,7 +1445,6 @@ no_cached_page:
1445 * effect. 1445 * effect.
1446 */ 1446 */
1447 error = page_cache_read(file, pgoff); 1447 error = page_cache_read(file, pgoff);
1448 grab_swap_token();
1449 1448
1450 /* 1449 /*
1451 * The page we want has now been added to the page cache. 1450 * The page we want has now been added to the page cache.
diff --git a/mm/fremap.c b/mm/fremap.c
index 7a9d0f5d246d..b77a002c3352 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -101,7 +101,6 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
101{ 101{
102 int err = -ENOMEM; 102 int err = -ENOMEM;
103 pte_t *pte; 103 pte_t *pte;
104 pte_t pte_val;
105 spinlock_t *ptl; 104 spinlock_t *ptl;
106 105
107 pte = get_locked_pte(mm, addr, &ptl); 106 pte = get_locked_pte(mm, addr, &ptl);
@@ -114,7 +113,6 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
114 } 113 }
115 114
116 set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff)); 115 set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff));
117 pte_val = *pte;
118 /* 116 /*
119 * We don't need to run update_mmu_cache() here because the "file pte" 117 * We don't need to run update_mmu_cache() here because the "file pte"
120 * being installed by install_file_pte() is not a real pte - it's a 118 * being installed by install_file_pte() is not a real pte - it's a
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a088f593a807..0ccc7f230252 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -109,7 +109,7 @@ static int alloc_fresh_huge_page(void)
109 if (nid == MAX_NUMNODES) 109 if (nid == MAX_NUMNODES)
110 nid = first_node(node_online_map); 110 nid = first_node(node_online_map);
111 if (page) { 111 if (page) {
112 page[1].lru.next = (void *)free_huge_page; /* dtor */ 112 set_compound_page_dtor(page, free_huge_page);
113 spin_lock(&hugetlb_lock); 113 spin_lock(&hugetlb_lock);
114 nr_huge_pages++; 114 nr_huge_pages++;
115 nr_huge_pages_node[page_to_nid(page)]++; 115 nr_huge_pages_node[page_to_nid(page)]++;
@@ -344,7 +344,6 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
344 entry = *src_pte; 344 entry = *src_pte;
345 ptepage = pte_page(entry); 345 ptepage = pte_page(entry);
346 get_page(ptepage); 346 get_page(ptepage);
347 add_mm_counter(dst, file_rss, HPAGE_SIZE / PAGE_SIZE);
348 set_huge_pte_at(dst, addr, dst_pte, entry); 347 set_huge_pte_at(dst, addr, dst_pte, entry);
349 } 348 }
350 spin_unlock(&src->page_table_lock); 349 spin_unlock(&src->page_table_lock);
@@ -365,6 +364,11 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
365 pte_t pte; 364 pte_t pte;
366 struct page *page; 365 struct page *page;
367 struct page *tmp; 366 struct page *tmp;
367 /*
368 * A page gathering list, protected by per file i_mmap_lock. The
369 * lock is used to avoid list corruption from multiple unmapping
370 * of the same page since we are using page->lru.
371 */
368 LIST_HEAD(page_list); 372 LIST_HEAD(page_list);
369 373
370 WARN_ON(!is_vm_hugetlb_page(vma)); 374 WARN_ON(!is_vm_hugetlb_page(vma));
@@ -372,24 +376,21 @@ void __unmap_hugepage_range(struct vm_area_struct *vma, unsigned long start,
372 BUG_ON(end & ~HPAGE_MASK); 376 BUG_ON(end & ~HPAGE_MASK);
373 377
374 spin_lock(&mm->page_table_lock); 378 spin_lock(&mm->page_table_lock);
375
376 /* Update high watermark before we lower rss */
377 update_hiwater_rss(mm);
378
379 for (address = start; address < end; address += HPAGE_SIZE) { 379 for (address = start; address < end; address += HPAGE_SIZE) {
380 ptep = huge_pte_offset(mm, address); 380 ptep = huge_pte_offset(mm, address);
381 if (!ptep) 381 if (!ptep)
382 continue; 382 continue;
383 383
384 if (huge_pmd_unshare(mm, &address, ptep))
385 continue;
386
384 pte = huge_ptep_get_and_clear(mm, address, ptep); 387 pte = huge_ptep_get_and_clear(mm, address, ptep);
385 if (pte_none(pte)) 388 if (pte_none(pte))
386 continue; 389 continue;
387 390
388 page = pte_page(pte); 391 page = pte_page(pte);
389 list_add(&page->lru, &page_list); 392 list_add(&page->lru, &page_list);
390 add_mm_counter(mm, file_rss, (int) -(HPAGE_SIZE / PAGE_SIZE));
391 } 393 }
392
393 spin_unlock(&mm->page_table_lock); 394 spin_unlock(&mm->page_table_lock);
394 flush_tlb_range(vma, start, end); 395 flush_tlb_range(vma, start, end);
395 list_for_each_entry_safe(page, tmp, &page_list, lru) { 396 list_for_each_entry_safe(page, tmp, &page_list, lru) {
@@ -515,7 +516,6 @@ retry:
515 if (!pte_none(*ptep)) 516 if (!pte_none(*ptep))
516 goto backout; 517 goto backout;
517 518
518 add_mm_counter(mm, file_rss, HPAGE_SIZE / PAGE_SIZE);
519 new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE) 519 new_pte = make_huge_pte(vma, page, ((vma->vm_flags & VM_WRITE)
520 && (vma->vm_flags & VM_SHARED))); 520 && (vma->vm_flags & VM_SHARED)));
521 set_huge_pte_at(mm, address, ptep, new_pte); 521 set_huge_pte_at(mm, address, ptep, new_pte);
@@ -653,11 +653,14 @@ void hugetlb_change_protection(struct vm_area_struct *vma,
653 BUG_ON(address >= end); 653 BUG_ON(address >= end);
654 flush_cache_range(vma, address, end); 654 flush_cache_range(vma, address, end);
655 655
656 spin_lock(&vma->vm_file->f_mapping->i_mmap_lock);
656 spin_lock(&mm->page_table_lock); 657 spin_lock(&mm->page_table_lock);
657 for (; address < end; address += HPAGE_SIZE) { 658 for (; address < end; address += HPAGE_SIZE) {
658 ptep = huge_pte_offset(mm, address); 659 ptep = huge_pte_offset(mm, address);
659 if (!ptep) 660 if (!ptep)
660 continue; 661 continue;
662 if (huge_pmd_unshare(mm, &address, ptep))
663 continue;
661 if (!pte_none(*ptep)) { 664 if (!pte_none(*ptep)) {
662 pte = huge_ptep_get_and_clear(mm, address, ptep); 665 pte = huge_ptep_get_and_clear(mm, address, ptep);
663 pte = pte_mkhuge(pte_modify(pte, newprot)); 666 pte = pte_mkhuge(pte_modify(pte, newprot));
@@ -666,6 +669,7 @@ void hugetlb_change_protection(struct vm_area_struct *vma,
666 } 669 }
667 } 670 }
668 spin_unlock(&mm->page_table_lock); 671 spin_unlock(&mm->page_table_lock);
672 spin_unlock(&vma->vm_file->f_mapping->i_mmap_lock);
669 673
670 flush_tlb_range(vma, start, end); 674 flush_tlb_range(vma, start, end);
671} 675}
diff --git a/mm/memory.c b/mm/memory.c
index 156861fcac43..4198df0dff1c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1902,7 +1902,6 @@ int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end)
1902 1902
1903 return 0; 1903 return 0;
1904} 1904}
1905EXPORT_UNUSED_SYMBOL(vmtruncate_range); /* June 2006 */
1906 1905
1907/** 1906/**
1908 * swapin_readahead - swap in pages in hope we need them soon 1907 * swapin_readahead - swap in pages in hope we need them soon
@@ -1991,6 +1990,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
1991 delayacct_set_flag(DELAYACCT_PF_SWAPIN); 1990 delayacct_set_flag(DELAYACCT_PF_SWAPIN);
1992 page = lookup_swap_cache(entry); 1991 page = lookup_swap_cache(entry);
1993 if (!page) { 1992 if (!page) {
1993 grab_swap_token(); /* Contend for token _before_ read-in */
1994 swapin_readahead(entry, address, vma); 1994 swapin_readahead(entry, address, vma);
1995 page = read_swap_cache_async(entry, vma, address); 1995 page = read_swap_cache_async(entry, vma, address);
1996 if (!page) { 1996 if (!page) {
@@ -2008,7 +2008,6 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
2008 /* Had to read the page from swap area: Major fault */ 2008 /* Had to read the page from swap area: Major fault */
2009 ret = VM_FAULT_MAJOR; 2009 ret = VM_FAULT_MAJOR;
2010 count_vm_event(PGMAJFAULT); 2010 count_vm_event(PGMAJFAULT);
2011 grab_swap_token();
2012 } 2011 }
2013 2012
2014 delayacct_clear_flag(DELAYACCT_PF_SWAPIN); 2013 delayacct_clear_flag(DELAYACCT_PF_SWAPIN);
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index fd678a662eae..0c055a090f4d 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -72,7 +72,6 @@ static int __add_zone(struct zone *zone, unsigned long phys_start_pfn)
72 return ret; 72 return ret;
73 } 73 }
74 memmap_init_zone(nr_pages, nid, zone_type, phys_start_pfn); 74 memmap_init_zone(nr_pages, nid, zone_type, phys_start_pfn);
75 zonetable_add(zone, nid, zone_type, phys_start_pfn, nr_pages);
76 return 0; 75 return 0;
77} 76}
78 77
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 617fb31086ee..b917d6fdc1bb 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -141,9 +141,11 @@ static struct zonelist *bind_zonelist(nodemask_t *nodes)
141 enum zone_type k; 141 enum zone_type k;
142 142
143 max = 1 + MAX_NR_ZONES * nodes_weight(*nodes); 143 max = 1 + MAX_NR_ZONES * nodes_weight(*nodes);
144 max++; /* space for zlcache_ptr (see mmzone.h) */
144 zl = kmalloc(sizeof(struct zone *) * max, GFP_KERNEL); 145 zl = kmalloc(sizeof(struct zone *) * max, GFP_KERNEL);
145 if (!zl) 146 if (!zl)
146 return NULL; 147 return NULL;
148 zl->zlcache_ptr = NULL;
147 num = 0; 149 num = 0;
148 /* First put in the highest zones from all nodes, then all the next 150 /* First put in the highest zones from all nodes, then all the next
149 lower zones etc. Avoid empty zones because the memory allocator 151 lower zones etc. Avoid empty zones because the memory allocator
@@ -219,7 +221,7 @@ static int check_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
219 orig_pte = pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl); 221 orig_pte = pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
220 do { 222 do {
221 struct page *page; 223 struct page *page;
222 unsigned int nid; 224 int nid;
223 225
224 if (!pte_present(*pte)) 226 if (!pte_present(*pte))
225 continue; 227 continue;
@@ -1324,7 +1326,7 @@ struct mempolicy *__mpol_copy(struct mempolicy *old)
1324 atomic_set(&new->refcnt, 1); 1326 atomic_set(&new->refcnt, 1);
1325 if (new->policy == MPOL_BIND) { 1327 if (new->policy == MPOL_BIND) {
1326 int sz = ksize(old->v.zonelist); 1328 int sz = ksize(old->v.zonelist);
1327 new->v.zonelist = kmemdup(old->v.zonelist, sz, SLAB_KERNEL); 1329 new->v.zonelist = kmemdup(old->v.zonelist, sz, GFP_KERNEL);
1328 if (!new->v.zonelist) { 1330 if (!new->v.zonelist) {
1329 kmem_cache_free(policy_cache, new); 1331 kmem_cache_free(policy_cache, new);
1330 return ERR_PTR(-ENOMEM); 1332 return ERR_PTR(-ENOMEM);
@@ -1705,8 +1707,8 @@ void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
1705 * Display pages allocated per node and memory policy via /proc. 1707 * Display pages allocated per node and memory policy via /proc.
1706 */ 1708 */
1707 1709
1708static const char *policy_types[] = { "default", "prefer", "bind", 1710static const char * const policy_types[] =
1709 "interleave" }; 1711 { "default", "prefer", "bind", "interleave" };
1710 1712
1711/* 1713/*
1712 * Convert a mempolicy into a string. 1714 * Convert a mempolicy into a string.
diff --git a/mm/migrate.c b/mm/migrate.c
index b4979d423d2b..e9b161bde95b 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -294,7 +294,7 @@ out:
294static int migrate_page_move_mapping(struct address_space *mapping, 294static int migrate_page_move_mapping(struct address_space *mapping,
295 struct page *newpage, struct page *page) 295 struct page *newpage, struct page *page)
296{ 296{
297 struct page **radix_pointer; 297 void **pslot;
298 298
299 if (!mapping) { 299 if (!mapping) {
300 /* Anonymous page */ 300 /* Anonymous page */
@@ -305,12 +305,11 @@ static int migrate_page_move_mapping(struct address_space *mapping,
305 305
306 write_lock_irq(&mapping->tree_lock); 306 write_lock_irq(&mapping->tree_lock);
307 307
308 radix_pointer = (struct page **)radix_tree_lookup_slot( 308 pslot = radix_tree_lookup_slot(&mapping->page_tree,
309 &mapping->page_tree, 309 page_index(page));
310 page_index(page));
311 310
312 if (page_count(page) != 2 + !!PagePrivate(page) || 311 if (page_count(page) != 2 + !!PagePrivate(page) ||
313 *radix_pointer != page) { 312 (struct page *)radix_tree_deref_slot(pslot) != page) {
314 write_unlock_irq(&mapping->tree_lock); 313 write_unlock_irq(&mapping->tree_lock);
315 return -EAGAIN; 314 return -EAGAIN;
316 } 315 }
@@ -318,7 +317,7 @@ static int migrate_page_move_mapping(struct address_space *mapping,
318 /* 317 /*
319 * Now we know that no one else is looking at the page. 318 * Now we know that no one else is looking at the page.
320 */ 319 */
321 get_page(newpage); 320 get_page(newpage); /* add cache reference */
322#ifdef CONFIG_SWAP 321#ifdef CONFIG_SWAP
323 if (PageSwapCache(page)) { 322 if (PageSwapCache(page)) {
324 SetPageSwapCache(newpage); 323 SetPageSwapCache(newpage);
@@ -326,8 +325,14 @@ static int migrate_page_move_mapping(struct address_space *mapping,
326 } 325 }
327#endif 326#endif
328 327
329 *radix_pointer = newpage; 328 radix_tree_replace_slot(pslot, newpage);
329
330 /*
331 * Drop cache reference from old page.
332 * We know this isn't the last reference.
333 */
330 __put_page(page); 334 __put_page(page);
335
331 write_unlock_irq(&mapping->tree_lock); 336 write_unlock_irq(&mapping->tree_lock);
332 337
333 return 0; 338 return 0;
diff --git a/mm/mlock.c b/mm/mlock.c
index b90c59573abf..3446b7ef731e 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -65,7 +65,7 @@ success:
65 ret = make_pages_present(start, end); 65 ret = make_pages_present(start, end);
66 } 66 }
67 67
68 vma->vm_mm->locked_vm -= pages; 68 mm->locked_vm -= pages;
69out: 69out:
70 if (ret == -ENOMEM) 70 if (ret == -ENOMEM)
71 ret = -EAGAIN; 71 ret = -EAGAIN;
diff --git a/mm/mmap.c b/mm/mmap.c
index 7b40abd7cba2..7be110e98d4c 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1736,7 +1736,7 @@ int split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
1736 if (mm->map_count >= sysctl_max_map_count) 1736 if (mm->map_count >= sysctl_max_map_count)
1737 return -ENOMEM; 1737 return -ENOMEM;
1738 1738
1739 new = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 1739 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
1740 if (!new) 1740 if (!new)
1741 return -ENOMEM; 1741 return -ENOMEM;
1742 1742
@@ -2057,7 +2057,7 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
2057 vma_start < new_vma->vm_end) 2057 vma_start < new_vma->vm_end)
2058 *vmap = new_vma; 2058 *vmap = new_vma;
2059 } else { 2059 } else {
2060 new_vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL); 2060 new_vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
2061 if (new_vma) { 2061 if (new_vma) {
2062 *new_vma = *vma; 2062 *new_vma = *vma;
2063 pol = mpol_copy(vma_policy(vma)); 2063 pol = mpol_copy(vma_policy(vma));
diff --git a/mm/mmzone.c b/mm/mmzone.c
index febea1c98168..eb5838634f18 100644
--- a/mm/mmzone.c
+++ b/mm/mmzone.c
@@ -14,8 +14,6 @@ struct pglist_data *first_online_pgdat(void)
14 return NODE_DATA(first_online_node); 14 return NODE_DATA(first_online_node);
15} 15}
16 16
17EXPORT_UNUSED_SYMBOL(first_online_pgdat); /* June 2006 */
18
19struct pglist_data *next_online_pgdat(struct pglist_data *pgdat) 17struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
20{ 18{
21 int nid = next_online_node(pgdat->node_id); 19 int nid = next_online_node(pgdat->node_id);
@@ -24,8 +22,6 @@ struct pglist_data *next_online_pgdat(struct pglist_data *pgdat)
24 return NULL; 22 return NULL;
25 return NODE_DATA(nid); 23 return NODE_DATA(nid);
26} 24}
27EXPORT_UNUSED_SYMBOL(next_online_pgdat); /* June 2006 */
28
29 25
30/* 26/*
31 * next_zone - helper magic for for_each_zone() 27 * next_zone - helper magic for for_each_zone()
@@ -45,5 +41,4 @@ struct zone *next_zone(struct zone *zone)
45 } 41 }
46 return zone; 42 return zone;
47} 43}
48EXPORT_UNUSED_SYMBOL(next_zone); /* June 2006 */
49 44
diff --git a/mm/nommu.c b/mm/nommu.c
index 6a2a8aada401..af874569d0f1 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -808,10 +808,9 @@ unsigned long do_mmap_pgoff(struct file *file,
808 vm_flags = determine_vm_flags(file, prot, flags, capabilities); 808 vm_flags = determine_vm_flags(file, prot, flags, capabilities);
809 809
810 /* we're going to need to record the mapping if it works */ 810 /* we're going to need to record the mapping if it works */
811 vml = kmalloc(sizeof(struct vm_list_struct), GFP_KERNEL); 811 vml = kzalloc(sizeof(struct vm_list_struct), GFP_KERNEL);
812 if (!vml) 812 if (!vml)
813 goto error_getting_vml; 813 goto error_getting_vml;
814 memset(vml, 0, sizeof(*vml));
815 814
816 down_write(&nommu_vma_sem); 815 down_write(&nommu_vma_sem);
817 816
@@ -887,11 +886,10 @@ unsigned long do_mmap_pgoff(struct file *file,
887 } 886 }
888 887
889 /* we're going to need a VMA struct as well */ 888 /* we're going to need a VMA struct as well */
890 vma = kmalloc(sizeof(struct vm_area_struct), GFP_KERNEL); 889 vma = kzalloc(sizeof(struct vm_area_struct), GFP_KERNEL);
891 if (!vma) 890 if (!vma)
892 goto error_getting_vma; 891 goto error_getting_vma;
893 892
894 memset(vma, 0, sizeof(*vma));
895 INIT_LIST_HEAD(&vma->anon_vma_node); 893 INIT_LIST_HEAD(&vma->anon_vma_node);
896 atomic_set(&vma->vm_usage, 1); 894 atomic_set(&vma->vm_usage, 1);
897 if (file) 895 if (file)
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 2e3ce3a928b9..223d9ccb7d64 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -264,7 +264,7 @@ static struct task_struct *select_bad_process(unsigned long *ppoints)
264 * flag though it's unlikely that we select a process with CAP_SYS_RAW_IO 264 * flag though it's unlikely that we select a process with CAP_SYS_RAW_IO
265 * set. 265 * set.
266 */ 266 */
267static void __oom_kill_task(struct task_struct *p, const char *message) 267static void __oom_kill_task(struct task_struct *p, int verbose)
268{ 268{
269 if (is_init(p)) { 269 if (is_init(p)) {
270 WARN_ON(1); 270 WARN_ON(1);
@@ -278,10 +278,8 @@ static void __oom_kill_task(struct task_struct *p, const char *message)
278 return; 278 return;
279 } 279 }
280 280
281 if (message) { 281 if (verbose)
282 printk(KERN_ERR "%s: Killed process %d (%s).\n", 282 printk(KERN_ERR "Killed process %d (%s)\n", p->pid, p->comm);
283 message, p->pid, p->comm);
284 }
285 283
286 /* 284 /*
287 * We give our sacrificial lamb high priority and access to 285 * We give our sacrificial lamb high priority and access to
@@ -294,7 +292,7 @@ static void __oom_kill_task(struct task_struct *p, const char *message)
294 force_sig(SIGKILL, p); 292 force_sig(SIGKILL, p);
295} 293}
296 294
297static int oom_kill_task(struct task_struct *p, const char *message) 295static int oom_kill_task(struct task_struct *p)
298{ 296{
299 struct mm_struct *mm; 297 struct mm_struct *mm;
300 struct task_struct *g, *q; 298 struct task_struct *g, *q;
@@ -313,15 +311,25 @@ static int oom_kill_task(struct task_struct *p, const char *message)
313 if (mm == NULL) 311 if (mm == NULL)
314 return 1; 312 return 1;
315 313
316 __oom_kill_task(p, message); 314 /*
315 * Don't kill the process if any threads are set to OOM_DISABLE
316 */
317 do_each_thread(g, q) {
318 if (q->mm == mm && p->oomkilladj == OOM_DISABLE)
319 return 1;
320 } while_each_thread(g, q);
321
322 __oom_kill_task(p, 1);
323
317 /* 324 /*
318 * kill all processes that share the ->mm (i.e. all threads), 325 * kill all processes that share the ->mm (i.e. all threads),
319 * but are in a different thread group 326 * but are in a different thread group. Don't let them have access
327 * to memory reserves though, otherwise we might deplete all memory.
320 */ 328 */
321 do_each_thread(g, q) 329 do_each_thread(g, q) {
322 if (q->mm == mm && q->tgid != p->tgid) 330 if (q->mm == mm && q->tgid != p->tgid)
323 __oom_kill_task(q, message); 331 force_sig(SIGKILL, p);
324 while_each_thread(g, q); 332 } while_each_thread(g, q);
325 333
326 return 0; 334 return 0;
327} 335}
@@ -337,21 +345,22 @@ static int oom_kill_process(struct task_struct *p, unsigned long points,
337 * its children or threads, just set TIF_MEMDIE so it can die quickly 345 * its children or threads, just set TIF_MEMDIE so it can die quickly
338 */ 346 */
339 if (p->flags & PF_EXITING) { 347 if (p->flags & PF_EXITING) {
340 __oom_kill_task(p, NULL); 348 __oom_kill_task(p, 0);
341 return 0; 349 return 0;
342 } 350 }
343 351
344 printk(KERN_ERR "Out of Memory: Kill process %d (%s) score %li" 352 printk(KERN_ERR "%s: kill process %d (%s) score %li or a child\n",
345 " and children.\n", p->pid, p->comm, points); 353 message, p->pid, p->comm, points);
354
346 /* Try to kill a child first */ 355 /* Try to kill a child first */
347 list_for_each(tsk, &p->children) { 356 list_for_each(tsk, &p->children) {
348 c = list_entry(tsk, struct task_struct, sibling); 357 c = list_entry(tsk, struct task_struct, sibling);
349 if (c->mm == p->mm) 358 if (c->mm == p->mm)
350 continue; 359 continue;
351 if (!oom_kill_task(c, message)) 360 if (!oom_kill_task(c))
352 return 0; 361 return 0;
353 } 362 }
354 return oom_kill_task(p, message); 363 return oom_kill_task(p);
355} 364}
356 365
357static BLOCKING_NOTIFIER_HEAD(oom_notify_list); 366static BLOCKING_NOTIFIER_HEAD(oom_notify_list);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index aa6fcc7ca66f..cace22b3ac25 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -83,14 +83,7 @@ int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {
83 83
84EXPORT_SYMBOL(totalram_pages); 84EXPORT_SYMBOL(totalram_pages);
85 85
86/* 86static char * const zone_names[MAX_NR_ZONES] = {
87 * Used by page_zone() to look up the address of the struct zone whose
88 * id is encoded in the upper bits of page->flags
89 */
90struct zone *zone_table[1 << ZONETABLE_SHIFT] __read_mostly;
91EXPORT_SYMBOL(zone_table);
92
93static char *zone_names[MAX_NR_ZONES] = {
94 "DMA", 87 "DMA",
95#ifdef CONFIG_ZONE_DMA32 88#ifdef CONFIG_ZONE_DMA32
96 "DMA32", 89 "DMA32",
@@ -237,7 +230,7 @@ static void prep_compound_page(struct page *page, unsigned long order)
237 int i; 230 int i;
238 int nr_pages = 1 << order; 231 int nr_pages = 1 << order;
239 232
240 page[1].lru.next = (void *)free_compound_page; /* set dtor */ 233 set_compound_page_dtor(page, free_compound_page);
241 page[1].lru.prev = (void *)order; 234 page[1].lru.prev = (void *)order;
242 for (i = 0; i < nr_pages; i++) { 235 for (i = 0; i < nr_pages; i++) {
243 struct page *p = page + i; 236 struct page *p = page + i;
@@ -486,7 +479,7 @@ static void free_one_page(struct zone *zone, struct page *page, int order)
486 spin_lock(&zone->lock); 479 spin_lock(&zone->lock);
487 zone->all_unreclaimable = 0; 480 zone->all_unreclaimable = 0;
488 zone->pages_scanned = 0; 481 zone->pages_scanned = 0;
489 __free_one_page(page, zone ,order); 482 __free_one_page(page, zone, order);
490 spin_unlock(&zone->lock); 483 spin_unlock(&zone->lock);
491} 484}
492 485
@@ -605,6 +598,8 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
605 1 << PG_checked | 1 << PG_mappedtodisk); 598 1 << PG_checked | 1 << PG_mappedtodisk);
606 set_page_private(page, 0); 599 set_page_private(page, 0);
607 set_page_refcounted(page); 600 set_page_refcounted(page);
601
602 arch_alloc_page(page, order);
608 kernel_map_pages(page, 1 << order, 1); 603 kernel_map_pages(page, 1 << order, 1);
609 604
610 if (gfp_flags & __GFP_ZERO) 605 if (gfp_flags & __GFP_ZERO)
@@ -690,9 +685,15 @@ void drain_node_pages(int nodeid)
690 685
691 pcp = &pset->pcp[i]; 686 pcp = &pset->pcp[i];
692 if (pcp->count) { 687 if (pcp->count) {
688 int to_drain;
689
693 local_irq_save(flags); 690 local_irq_save(flags);
694 free_pages_bulk(zone, pcp->count, &pcp->list, 0); 691 if (pcp->count >= pcp->batch)
695 pcp->count = 0; 692 to_drain = pcp->batch;
693 else
694 to_drain = pcp->count;
695 free_pages_bulk(zone, to_drain, &pcp->list, 0);
696 pcp->count -= to_drain;
696 local_irq_restore(flags); 697 local_irq_restore(flags);
697 } 698 }
698 } 699 }
@@ -700,7 +701,6 @@ void drain_node_pages(int nodeid)
700} 701}
701#endif 702#endif
702 703
703#if defined(CONFIG_PM) || defined(CONFIG_HOTPLUG_CPU)
704static void __drain_pages(unsigned int cpu) 704static void __drain_pages(unsigned int cpu)
705{ 705{
706 unsigned long flags; 706 unsigned long flags;
@@ -722,7 +722,6 @@ static void __drain_pages(unsigned int cpu)
722 } 722 }
723 } 723 }
724} 724}
725#endif /* CONFIG_PM || CONFIG_HOTPLUG_CPU */
726 725
727#ifdef CONFIG_PM 726#ifdef CONFIG_PM
728 727
@@ -925,31 +924,160 @@ int zone_watermark_ok(struct zone *z, int order, unsigned long mark,
925 return 1; 924 return 1;
926} 925}
927 926
927#ifdef CONFIG_NUMA
928/*
929 * zlc_setup - Setup for "zonelist cache". Uses cached zone data to
930 * skip over zones that are not allowed by the cpuset, or that have
931 * been recently (in last second) found to be nearly full. See further
932 * comments in mmzone.h. Reduces cache footprint of zonelist scans
933 * that have to skip over alot of full or unallowed zones.
934 *
935 * If the zonelist cache is present in the passed in zonelist, then
936 * returns a pointer to the allowed node mask (either the current
937 * tasks mems_allowed, or node_online_map.)
938 *
939 * If the zonelist cache is not available for this zonelist, does
940 * nothing and returns NULL.
941 *
942 * If the fullzones BITMAP in the zonelist cache is stale (more than
943 * a second since last zap'd) then we zap it out (clear its bits.)
944 *
945 * We hold off even calling zlc_setup, until after we've checked the
946 * first zone in the zonelist, on the theory that most allocations will
947 * be satisfied from that first zone, so best to examine that zone as
948 * quickly as we can.
949 */
950static nodemask_t *zlc_setup(struct zonelist *zonelist, int alloc_flags)
951{
952 struct zonelist_cache *zlc; /* cached zonelist speedup info */
953 nodemask_t *allowednodes; /* zonelist_cache approximation */
954
955 zlc = zonelist->zlcache_ptr;
956 if (!zlc)
957 return NULL;
958
959 if (jiffies - zlc->last_full_zap > 1 * HZ) {
960 bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST);
961 zlc->last_full_zap = jiffies;
962 }
963
964 allowednodes = !in_interrupt() && (alloc_flags & ALLOC_CPUSET) ?
965 &cpuset_current_mems_allowed :
966 &node_online_map;
967 return allowednodes;
968}
969
970/*
971 * Given 'z' scanning a zonelist, run a couple of quick checks to see
972 * if it is worth looking at further for free memory:
973 * 1) Check that the zone isn't thought to be full (doesn't have its
974 * bit set in the zonelist_cache fullzones BITMAP).
975 * 2) Check that the zones node (obtained from the zonelist_cache
976 * z_to_n[] mapping) is allowed in the passed in allowednodes mask.
977 * Return true (non-zero) if zone is worth looking at further, or
978 * else return false (zero) if it is not.
979 *
980 * This check -ignores- the distinction between various watermarks,
981 * such as GFP_HIGH, GFP_ATOMIC, PF_MEMALLOC, ... If a zone is
982 * found to be full for any variation of these watermarks, it will
983 * be considered full for up to one second by all requests, unless
984 * we are so low on memory on all allowed nodes that we are forced
985 * into the second scan of the zonelist.
986 *
987 * In the second scan we ignore this zonelist cache and exactly
988 * apply the watermarks to all zones, even it is slower to do so.
989 * We are low on memory in the second scan, and should leave no stone
990 * unturned looking for a free page.
991 */
992static int zlc_zone_worth_trying(struct zonelist *zonelist, struct zone **z,
993 nodemask_t *allowednodes)
994{
995 struct zonelist_cache *zlc; /* cached zonelist speedup info */
996 int i; /* index of *z in zonelist zones */
997 int n; /* node that zone *z is on */
998
999 zlc = zonelist->zlcache_ptr;
1000 if (!zlc)
1001 return 1;
1002
1003 i = z - zonelist->zones;
1004 n = zlc->z_to_n[i];
1005
1006 /* This zone is worth trying if it is allowed but not full */
1007 return node_isset(n, *allowednodes) && !test_bit(i, zlc->fullzones);
1008}
1009
928/* 1010/*
929 * get_page_from_freeliest goes through the zonelist trying to allocate 1011 * Given 'z' scanning a zonelist, set the corresponding bit in
1012 * zlc->fullzones, so that subsequent attempts to allocate a page
1013 * from that zone don't waste time re-examining it.
1014 */
1015static void zlc_mark_zone_full(struct zonelist *zonelist, struct zone **z)
1016{
1017 struct zonelist_cache *zlc; /* cached zonelist speedup info */
1018 int i; /* index of *z in zonelist zones */
1019
1020 zlc = zonelist->zlcache_ptr;
1021 if (!zlc)
1022 return;
1023
1024 i = z - zonelist->zones;
1025
1026 set_bit(i, zlc->fullzones);
1027}
1028
1029#else /* CONFIG_NUMA */
1030
1031static nodemask_t *zlc_setup(struct zonelist *zonelist, int alloc_flags)
1032{
1033 return NULL;
1034}
1035
1036static int zlc_zone_worth_trying(struct zonelist *zonelist, struct zone **z,
1037 nodemask_t *allowednodes)
1038{
1039 return 1;
1040}
1041
1042static void zlc_mark_zone_full(struct zonelist *zonelist, struct zone **z)
1043{
1044}
1045#endif /* CONFIG_NUMA */
1046
1047/*
1048 * get_page_from_freelist goes through the zonelist trying to allocate
930 * a page. 1049 * a page.
931 */ 1050 */
932static struct page * 1051static struct page *
933get_page_from_freelist(gfp_t gfp_mask, unsigned int order, 1052get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
934 struct zonelist *zonelist, int alloc_flags) 1053 struct zonelist *zonelist, int alloc_flags)
935{ 1054{
936 struct zone **z = zonelist->zones; 1055 struct zone **z;
937 struct page *page = NULL; 1056 struct page *page = NULL;
938 int classzone_idx = zone_idx(*z); 1057 int classzone_idx = zone_idx(zonelist->zones[0]);
939 struct zone *zone; 1058 struct zone *zone;
1059 nodemask_t *allowednodes = NULL;/* zonelist_cache approximation */
1060 int zlc_active = 0; /* set if using zonelist_cache */
1061 int did_zlc_setup = 0; /* just call zlc_setup() one time */
940 1062
1063zonelist_scan:
941 /* 1064 /*
942 * Go through the zonelist once, looking for a zone with enough free. 1065 * Scan zonelist, looking for a zone with enough free.
943 * See also cpuset_zone_allowed() comment in kernel/cpuset.c. 1066 * See also cpuset_zone_allowed() comment in kernel/cpuset.c.
944 */ 1067 */
1068 z = zonelist->zones;
1069
945 do { 1070 do {
1071 if (NUMA_BUILD && zlc_active &&
1072 !zlc_zone_worth_trying(zonelist, z, allowednodes))
1073 continue;
946 zone = *z; 1074 zone = *z;
947 if (unlikely(NUMA_BUILD && (gfp_mask & __GFP_THISNODE) && 1075 if (unlikely(NUMA_BUILD && (gfp_mask & __GFP_THISNODE) &&
948 zone->zone_pgdat != zonelist->zones[0]->zone_pgdat)) 1076 zone->zone_pgdat != zonelist->zones[0]->zone_pgdat))
949 break; 1077 break;
950 if ((alloc_flags & ALLOC_CPUSET) && 1078 if ((alloc_flags & ALLOC_CPUSET) &&
951 !cpuset_zone_allowed(zone, gfp_mask)) 1079 !cpuset_zone_allowed(zone, gfp_mask))
952 continue; 1080 goto try_next_zone;
953 1081
954 if (!(alloc_flags & ALLOC_NO_WATERMARKS)) { 1082 if (!(alloc_flags & ALLOC_NO_WATERMARKS)) {
955 unsigned long mark; 1083 unsigned long mark;
@@ -959,18 +1087,34 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
959 mark = zone->pages_low; 1087 mark = zone->pages_low;
960 else 1088 else
961 mark = zone->pages_high; 1089 mark = zone->pages_high;
962 if (!zone_watermark_ok(zone , order, mark, 1090 if (!zone_watermark_ok(zone, order, mark,
963 classzone_idx, alloc_flags)) 1091 classzone_idx, alloc_flags)) {
964 if (!zone_reclaim_mode || 1092 if (!zone_reclaim_mode ||
965 !zone_reclaim(zone, gfp_mask, order)) 1093 !zone_reclaim(zone, gfp_mask, order))
966 continue; 1094 goto this_zone_full;
1095 }
967 } 1096 }
968 1097
969 page = buffered_rmqueue(zonelist, zone, order, gfp_mask); 1098 page = buffered_rmqueue(zonelist, zone, order, gfp_mask);
970 if (page) { 1099 if (page)
971 break; 1100 break;
1101this_zone_full:
1102 if (NUMA_BUILD)
1103 zlc_mark_zone_full(zonelist, z);
1104try_next_zone:
1105 if (NUMA_BUILD && !did_zlc_setup) {
1106 /* we do zlc_setup after the first zone is tried */
1107 allowednodes = zlc_setup(zonelist, alloc_flags);
1108 zlc_active = 1;
1109 did_zlc_setup = 1;
972 } 1110 }
973 } while (*(++z) != NULL); 1111 } while (*(++z) != NULL);
1112
1113 if (unlikely(NUMA_BUILD && page == NULL && zlc_active)) {
1114 /* Disable zlc cache for second zonelist scan */
1115 zlc_active = 0;
1116 goto zonelist_scan;
1117 }
974 return page; 1118 return page;
975} 1119}
976 1120
@@ -1005,9 +1149,19 @@ restart:
1005 if (page) 1149 if (page)
1006 goto got_pg; 1150 goto got_pg;
1007 1151
1008 do { 1152 /*
1153 * GFP_THISNODE (meaning __GFP_THISNODE, __GFP_NORETRY and
1154 * __GFP_NOWARN set) should not cause reclaim since the subsystem
1155 * (f.e. slab) using GFP_THISNODE may choose to trigger reclaim
1156 * using a larger set of nodes after it has established that the
1157 * allowed per node queues are empty and that nodes are
1158 * over allocated.
1159 */
1160 if (NUMA_BUILD && (gfp_mask & GFP_THISNODE) == GFP_THISNODE)
1161 goto nopage;
1162
1163 for (z = zonelist->zones; *z; z++)
1009 wakeup_kswapd(*z, order); 1164 wakeup_kswapd(*z, order);
1010 } while (*(++z));
1011 1165
1012 /* 1166 /*
1013 * OK, we're below the kswapd watermark and have kicked background 1167 * OK, we're below the kswapd watermark and have kicked background
@@ -1041,6 +1195,7 @@ restart:
1041 1195
1042 /* This allocation should allow future memory freeing. */ 1196 /* This allocation should allow future memory freeing. */
1043 1197
1198rebalance:
1044 if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE))) 1199 if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE)))
1045 && !in_interrupt()) { 1200 && !in_interrupt()) {
1046 if (!(gfp_mask & __GFP_NOMEMALLOC)) { 1201 if (!(gfp_mask & __GFP_NOMEMALLOC)) {
@@ -1062,7 +1217,6 @@ nofail_alloc:
1062 if (!wait) 1217 if (!wait)
1063 goto nopage; 1218 goto nopage;
1064 1219
1065rebalance:
1066 cond_resched(); 1220 cond_resched();
1067 1221
1068 /* We now go into synchronous reclaim */ 1222 /* We now go into synchronous reclaim */
@@ -1262,7 +1416,7 @@ unsigned int nr_free_pagecache_pages(void)
1262static inline void show_node(struct zone *zone) 1416static inline void show_node(struct zone *zone)
1263{ 1417{
1264 if (NUMA_BUILD) 1418 if (NUMA_BUILD)
1265 printk("Node %ld ", zone_to_nid(zone)); 1419 printk("Node %d ", zone_to_nid(zone));
1266} 1420}
1267 1421
1268void si_meminfo(struct sysinfo *val) 1422void si_meminfo(struct sysinfo *val)
@@ -1542,6 +1696,24 @@ static void __meminit build_zonelists(pg_data_t *pgdat)
1542 } 1696 }
1543} 1697}
1544 1698
1699/* Construct the zonelist performance cache - see further mmzone.h */
1700static void __meminit build_zonelist_cache(pg_data_t *pgdat)
1701{
1702 int i;
1703
1704 for (i = 0; i < MAX_NR_ZONES; i++) {
1705 struct zonelist *zonelist;
1706 struct zonelist_cache *zlc;
1707 struct zone **z;
1708
1709 zonelist = pgdat->node_zonelists + i;
1710 zonelist->zlcache_ptr = zlc = &zonelist->zlcache;
1711 bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST);
1712 for (z = zonelist->zones; *z; z++)
1713 zlc->z_to_n[z - zonelist->zones] = zone_to_nid(*z);
1714 }
1715}
1716
1545#else /* CONFIG_NUMA */ 1717#else /* CONFIG_NUMA */
1546 1718
1547static void __meminit build_zonelists(pg_data_t *pgdat) 1719static void __meminit build_zonelists(pg_data_t *pgdat)
@@ -1579,14 +1751,26 @@ static void __meminit build_zonelists(pg_data_t *pgdat)
1579 } 1751 }
1580} 1752}
1581 1753
1754/* non-NUMA variant of zonelist performance cache - just NULL zlcache_ptr */
1755static void __meminit build_zonelist_cache(pg_data_t *pgdat)
1756{
1757 int i;
1758
1759 for (i = 0; i < MAX_NR_ZONES; i++)
1760 pgdat->node_zonelists[i].zlcache_ptr = NULL;
1761}
1762
1582#endif /* CONFIG_NUMA */ 1763#endif /* CONFIG_NUMA */
1583 1764
1584/* return values int ....just for stop_machine_run() */ 1765/* return values int ....just for stop_machine_run() */
1585static int __meminit __build_all_zonelists(void *dummy) 1766static int __meminit __build_all_zonelists(void *dummy)
1586{ 1767{
1587 int nid; 1768 int nid;
1588 for_each_online_node(nid) 1769
1770 for_each_online_node(nid) {
1589 build_zonelists(NODE_DATA(nid)); 1771 build_zonelists(NODE_DATA(nid));
1772 build_zonelist_cache(NODE_DATA(nid));
1773 }
1590 return 0; 1774 return 0;
1591} 1775}
1592 1776
@@ -1715,20 +1899,6 @@ void zone_init_free_lists(struct pglist_data *pgdat, struct zone *zone,
1715 } 1899 }
1716} 1900}
1717 1901
1718#define ZONETABLE_INDEX(x, zone_nr) ((x << ZONES_SHIFT) | zone_nr)
1719void zonetable_add(struct zone *zone, int nid, enum zone_type zid,
1720 unsigned long pfn, unsigned long size)
1721{
1722 unsigned long snum = pfn_to_section_nr(pfn);
1723 unsigned long end = pfn_to_section_nr(pfn + size);
1724
1725 if (FLAGS_HAS_NODE)
1726 zone_table[ZONETABLE_INDEX(nid, zid)] = zone;
1727 else
1728 for (; snum <= end; snum++)
1729 zone_table[ZONETABLE_INDEX(snum, zid)] = zone;
1730}
1731
1732#ifndef __HAVE_ARCH_MEMMAP_INIT 1902#ifndef __HAVE_ARCH_MEMMAP_INIT
1733#define memmap_init(size, nid, zone, start_pfn) \ 1903#define memmap_init(size, nid, zone, start_pfn) \
1734 memmap_init_zone((size), (nid), (zone), (start_pfn)) 1904 memmap_init_zone((size), (nid), (zone), (start_pfn))
@@ -1881,16 +2051,16 @@ static int __cpuinit pageset_cpuup_callback(struct notifier_block *nfb,
1881 int ret = NOTIFY_OK; 2051 int ret = NOTIFY_OK;
1882 2052
1883 switch (action) { 2053 switch (action) {
1884 case CPU_UP_PREPARE: 2054 case CPU_UP_PREPARE:
1885 if (process_zones(cpu)) 2055 if (process_zones(cpu))
1886 ret = NOTIFY_BAD; 2056 ret = NOTIFY_BAD;
1887 break; 2057 break;
1888 case CPU_UP_CANCELED: 2058 case CPU_UP_CANCELED:
1889 case CPU_DEAD: 2059 case CPU_DEAD:
1890 free_zone_pagesets(cpu); 2060 free_zone_pagesets(cpu);
1891 break; 2061 break;
1892 default: 2062 default:
1893 break; 2063 break;
1894 } 2064 }
1895 return ret; 2065 return ret;
1896} 2066}
@@ -2421,7 +2591,6 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
2421 if (!size) 2591 if (!size)
2422 continue; 2592 continue;
2423 2593
2424 zonetable_add(zone, nid, j, zone_start_pfn, size);
2425 ret = init_currently_empty_zone(zone, zone_start_pfn, size); 2594 ret = init_currently_empty_zone(zone, zone_start_pfn, size);
2426 BUG_ON(ret); 2595 BUG_ON(ret);
2427 zone_start_pfn += size; 2596 zone_start_pfn += size;
@@ -2736,7 +2905,6 @@ void __init free_area_init(unsigned long *zones_size)
2736 __pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL); 2905 __pa(PAGE_OFFSET) >> PAGE_SHIFT, NULL);
2737} 2906}
2738 2907
2739#ifdef CONFIG_HOTPLUG_CPU
2740static int page_alloc_cpu_notify(struct notifier_block *self, 2908static int page_alloc_cpu_notify(struct notifier_block *self,
2741 unsigned long action, void *hcpu) 2909 unsigned long action, void *hcpu)
2742{ 2910{
@@ -2751,7 +2919,6 @@ static int page_alloc_cpu_notify(struct notifier_block *self,
2751 } 2919 }
2752 return NOTIFY_OK; 2920 return NOTIFY_OK;
2753} 2921}
2754#endif /* CONFIG_HOTPLUG_CPU */
2755 2922
2756void __init page_alloc_init(void) 2923void __init page_alloc_init(void)
2757{ 2924{
@@ -3055,7 +3222,7 @@ void *__init alloc_large_system_hash(const char *tablename,
3055 /* allow the kernel cmdline to have a say */ 3222 /* allow the kernel cmdline to have a say */
3056 if (!numentries) { 3223 if (!numentries) {
3057 /* round applicable memory size up to nearest megabyte */ 3224 /* round applicable memory size up to nearest megabyte */
3058 numentries = (flags & HASH_HIGHMEM) ? nr_all_pages : nr_kernel_pages; 3225 numentries = nr_kernel_pages;
3059 numentries += (1UL << (20 - PAGE_SHIFT)) - 1; 3226 numentries += (1UL << (20 - PAGE_SHIFT)) - 1;
3060 numentries >>= 20 - PAGE_SHIFT; 3227 numentries >>= 20 - PAGE_SHIFT;
3061 numentries <<= 20 - PAGE_SHIFT; 3228 numentries <<= 20 - PAGE_SHIFT;
diff --git a/mm/page_io.c b/mm/page_io.c
index d4840ecbf8f9..dbffec0d78c9 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -147,48 +147,3 @@ int swap_readpage(struct file *file, struct page *page)
147out: 147out:
148 return ret; 148 return ret;
149} 149}
150
151#ifdef CONFIG_SOFTWARE_SUSPEND
152/*
153 * A scruffy utility function to read or write an arbitrary swap page
154 * and wait on the I/O. The caller must have a ref on the page.
155 *
156 * We use end_swap_bio_read() even for writes, because it happens to do what
157 * we want.
158 */
159int rw_swap_page_sync(int rw, swp_entry_t entry, struct page *page,
160 struct bio **bio_chain)
161{
162 struct bio *bio;
163 int ret = 0;
164 int bio_rw;
165
166 lock_page(page);
167
168 bio = get_swap_bio(GFP_KERNEL, entry.val, page, end_swap_bio_read);
169 if (bio == NULL) {
170 unlock_page(page);
171 ret = -ENOMEM;
172 goto out;
173 }
174
175 bio_rw = rw;
176 if (!bio_chain)
177 bio_rw |= (1 << BIO_RW_SYNC);
178 if (bio_chain)
179 bio_get(bio);
180 submit_bio(bio_rw, bio);
181 if (bio_chain == NULL) {
182 wait_on_page_locked(page);
183
184 if (!PageUptodate(page) || PageError(page))
185 ret = -EIO;
186 }
187 if (bio_chain) {
188 bio->bi_private = *bio_chain;
189 *bio_chain = bio;
190 }
191out:
192 return ret;
193}
194#endif
diff --git a/mm/pdflush.c b/mm/pdflush.c
index b02102feeb4b..8ce0900dc95c 100644
--- a/mm/pdflush.c
+++ b/mm/pdflush.c
@@ -21,6 +21,7 @@
21#include <linux/writeback.h> // Prototypes pdflush_operation() 21#include <linux/writeback.h> // Prototypes pdflush_operation()
22#include <linux/kthread.h> 22#include <linux/kthread.h>
23#include <linux/cpuset.h> 23#include <linux/cpuset.h>
24#include <linux/freezer.h>
24 25
25 26
26/* 27/*
diff --git a/mm/readahead.c b/mm/readahead.c
index 23cb61a01c6e..a386f2b6b335 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -148,13 +148,7 @@ int read_cache_pages(struct address_space *mapping, struct list_head *pages,
148 if (!pagevec_add(&lru_pvec, page)) 148 if (!pagevec_add(&lru_pvec, page))
149 __pagevec_lru_add(&lru_pvec); 149 __pagevec_lru_add(&lru_pvec);
150 if (ret) { 150 if (ret) {
151 while (!list_empty(pages)) { 151 put_pages_list(pages);
152 struct page *victim;
153
154 victim = list_to_page(pages);
155 list_del(&victim->lru);
156 page_cache_release(victim);
157 }
158 break; 152 break;
159 } 153 }
160 } 154 }
diff --git a/mm/shmem.c b/mm/shmem.c
index 4959535fc14c..c820b4f77b8d 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -177,7 +177,7 @@ static inline void shmem_unacct_blocks(unsigned long flags, long pages)
177 177
178static struct super_operations shmem_ops; 178static struct super_operations shmem_ops;
179static const struct address_space_operations shmem_aops; 179static const struct address_space_operations shmem_aops;
180static struct file_operations shmem_file_operations; 180static const struct file_operations shmem_file_operations;
181static struct inode_operations shmem_inode_operations; 181static struct inode_operations shmem_inode_operations;
182static struct inode_operations shmem_dir_inode_operations; 182static struct inode_operations shmem_dir_inode_operations;
183static struct inode_operations shmem_special_inode_operations; 183static struct inode_operations shmem_special_inode_operations;
@@ -1943,7 +1943,7 @@ static int shmem_xattr_security_set(struct inode *inode, const char *name,
1943 return security_inode_setsecurity(inode, name, value, size, flags); 1943 return security_inode_setsecurity(inode, name, value, size, flags);
1944} 1944}
1945 1945
1946struct xattr_handler shmem_xattr_security_handler = { 1946static struct xattr_handler shmem_xattr_security_handler = {
1947 .prefix = XATTR_SECURITY_PREFIX, 1947 .prefix = XATTR_SECURITY_PREFIX,
1948 .list = shmem_xattr_security_list, 1948 .list = shmem_xattr_security_list,
1949 .get = shmem_xattr_security_get, 1949 .get = shmem_xattr_security_get,
@@ -2263,7 +2263,7 @@ static struct kmem_cache *shmem_inode_cachep;
2263static struct inode *shmem_alloc_inode(struct super_block *sb) 2263static struct inode *shmem_alloc_inode(struct super_block *sb)
2264{ 2264{
2265 struct shmem_inode_info *p; 2265 struct shmem_inode_info *p;
2266 p = (struct shmem_inode_info *)kmem_cache_alloc(shmem_inode_cachep, SLAB_KERNEL); 2266 p = (struct shmem_inode_info *)kmem_cache_alloc(shmem_inode_cachep, GFP_KERNEL);
2267 if (!p) 2267 if (!p)
2268 return NULL; 2268 return NULL;
2269 return &p->vfs_inode; 2269 return &p->vfs_inode;
@@ -2319,7 +2319,7 @@ static const struct address_space_operations shmem_aops = {
2319 .migratepage = migrate_page, 2319 .migratepage = migrate_page,
2320}; 2320};
2321 2321
2322static struct file_operations shmem_file_operations = { 2322static const struct file_operations shmem_file_operations = {
2323 .mmap = shmem_mmap, 2323 .mmap = shmem_mmap,
2324#ifdef CONFIG_TMPFS 2324#ifdef CONFIG_TMPFS
2325 .llseek = generic_file_llseek, 2325 .llseek = generic_file_llseek,
diff --git a/mm/slab.c b/mm/slab.c
index 5de81473df34..068cb4503c15 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -103,12 +103,12 @@
103#include <linux/module.h> 103#include <linux/module.h>
104#include <linux/rcupdate.h> 104#include <linux/rcupdate.h>
105#include <linux/string.h> 105#include <linux/string.h>
106#include <linux/uaccess.h>
106#include <linux/nodemask.h> 107#include <linux/nodemask.h>
107#include <linux/mempolicy.h> 108#include <linux/mempolicy.h>
108#include <linux/mutex.h> 109#include <linux/mutex.h>
109#include <linux/rtmutex.h> 110#include <linux/rtmutex.h>
110 111
111#include <asm/uaccess.h>
112#include <asm/cacheflush.h> 112#include <asm/cacheflush.h>
113#include <asm/tlbflush.h> 113#include <asm/tlbflush.h>
114#include <asm/page.h> 114#include <asm/page.h>
@@ -730,7 +730,10 @@ static inline void init_lock_keys(void)
730} 730}
731#endif 731#endif
732 732
733/* Guard access to the cache-chain. */ 733/*
734 * 1. Guard access to the cache-chain.
735 * 2. Protect sanity of cpu_online_map against cpu hotplug events
736 */
734static DEFINE_MUTEX(cache_chain_mutex); 737static DEFINE_MUTEX(cache_chain_mutex);
735static struct list_head cache_chain; 738static struct list_head cache_chain;
736 739
@@ -866,6 +869,22 @@ static void __slab_error(const char *function, struct kmem_cache *cachep,
866 dump_stack(); 869 dump_stack();
867} 870}
868 871
872/*
873 * By default on NUMA we use alien caches to stage the freeing of
874 * objects allocated from other nodes. This causes massive memory
875 * inefficiencies when using fake NUMA setup to split memory into a
876 * large number of small nodes, so it can be disabled on the command
877 * line
878 */
879
880static int use_alien_caches __read_mostly = 1;
881static int __init noaliencache_setup(char *s)
882{
883 use_alien_caches = 0;
884 return 1;
885}
886__setup("noaliencache", noaliencache_setup);
887
869#ifdef CONFIG_NUMA 888#ifdef CONFIG_NUMA
870/* 889/*
871 * Special reaping functions for NUMA systems called from cache_reap(). 890 * Special reaping functions for NUMA systems called from cache_reap().
@@ -996,7 +1015,7 @@ static inline void *alternate_node_alloc(struct kmem_cache *cachep,
996 return NULL; 1015 return NULL;
997} 1016}
998 1017
999static inline void *__cache_alloc_node(struct kmem_cache *cachep, 1018static inline void *____cache_alloc_node(struct kmem_cache *cachep,
1000 gfp_t flags, int nodeid) 1019 gfp_t flags, int nodeid)
1001{ 1020{
1002 return NULL; 1021 return NULL;
@@ -1004,7 +1023,7 @@ static inline void *__cache_alloc_node(struct kmem_cache *cachep,
1004 1023
1005#else /* CONFIG_NUMA */ 1024#else /* CONFIG_NUMA */
1006 1025
1007static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int); 1026static void *____cache_alloc_node(struct kmem_cache *, gfp_t, int);
1008static void *alternate_node_alloc(struct kmem_cache *, gfp_t); 1027static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
1009 1028
1010static struct array_cache **alloc_alien_cache(int node, int limit) 1029static struct array_cache **alloc_alien_cache(int node, int limit)
@@ -1114,7 +1133,7 @@ static inline int cache_free_alien(struct kmem_cache *cachep, void *objp)
1114 * Make sure we are not freeing a object from another node to the array 1133 * Make sure we are not freeing a object from another node to the array
1115 * cache on this cpu. 1134 * cache on this cpu.
1116 */ 1135 */
1117 if (likely(slabp->nodeid == node)) 1136 if (likely(slabp->nodeid == node) || unlikely(!use_alien_caches))
1118 return 0; 1137 return 0;
1119 1138
1120 l3 = cachep->nodelists[node]; 1139 l3 = cachep->nodelists[node];
@@ -1192,7 +1211,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1192 list_for_each_entry(cachep, &cache_chain, next) { 1211 list_for_each_entry(cachep, &cache_chain, next) {
1193 struct array_cache *nc; 1212 struct array_cache *nc;
1194 struct array_cache *shared; 1213 struct array_cache *shared;
1195 struct array_cache **alien; 1214 struct array_cache **alien = NULL;
1196 1215
1197 nc = alloc_arraycache(node, cachep->limit, 1216 nc = alloc_arraycache(node, cachep->limit,
1198 cachep->batchcount); 1217 cachep->batchcount);
@@ -1204,9 +1223,11 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1204 if (!shared) 1223 if (!shared)
1205 goto bad; 1224 goto bad;
1206 1225
1207 alien = alloc_alien_cache(node, cachep->limit); 1226 if (use_alien_caches) {
1208 if (!alien) 1227 alien = alloc_alien_cache(node, cachep->limit);
1209 goto bad; 1228 if (!alien)
1229 goto bad;
1230 }
1210 cachep->array[cpu] = nc; 1231 cachep->array[cpu] = nc;
1211 l3 = cachep->nodelists[node]; 1232 l3 = cachep->nodelists[node];
1212 BUG_ON(!l3); 1233 BUG_ON(!l3);
@@ -1230,12 +1251,18 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1230 kfree(shared); 1251 kfree(shared);
1231 free_alien_cache(alien); 1252 free_alien_cache(alien);
1232 } 1253 }
1233 mutex_unlock(&cache_chain_mutex);
1234 break; 1254 break;
1235 case CPU_ONLINE: 1255 case CPU_ONLINE:
1256 mutex_unlock(&cache_chain_mutex);
1236 start_cpu_timer(cpu); 1257 start_cpu_timer(cpu);
1237 break; 1258 break;
1238#ifdef CONFIG_HOTPLUG_CPU 1259#ifdef CONFIG_HOTPLUG_CPU
1260 case CPU_DOWN_PREPARE:
1261 mutex_lock(&cache_chain_mutex);
1262 break;
1263 case CPU_DOWN_FAILED:
1264 mutex_unlock(&cache_chain_mutex);
1265 break;
1239 case CPU_DEAD: 1266 case CPU_DEAD:
1240 /* 1267 /*
1241 * Even if all the cpus of a node are down, we don't free the 1268 * Even if all the cpus of a node are down, we don't free the
@@ -1246,8 +1273,8 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
1246 * gets destroyed at kmem_cache_destroy(). 1273 * gets destroyed at kmem_cache_destroy().
1247 */ 1274 */
1248 /* fall thru */ 1275 /* fall thru */
1276#endif
1249 case CPU_UP_CANCELED: 1277 case CPU_UP_CANCELED:
1250 mutex_lock(&cache_chain_mutex);
1251 list_for_each_entry(cachep, &cache_chain, next) { 1278 list_for_each_entry(cachep, &cache_chain, next) {
1252 struct array_cache *nc; 1279 struct array_cache *nc;
1253 struct array_cache *shared; 1280 struct array_cache *shared;
@@ -1308,11 +1335,9 @@ free_array_cache:
1308 } 1335 }
1309 mutex_unlock(&cache_chain_mutex); 1336 mutex_unlock(&cache_chain_mutex);
1310 break; 1337 break;
1311#endif
1312 } 1338 }
1313 return NOTIFY_OK; 1339 return NOTIFY_OK;
1314bad: 1340bad:
1315 mutex_unlock(&cache_chain_mutex);
1316 return NOTIFY_BAD; 1341 return NOTIFY_BAD;
1317} 1342}
1318 1343
@@ -1580,12 +1605,7 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
1580 flags |= __GFP_COMP; 1605 flags |= __GFP_COMP;
1581#endif 1606#endif
1582 1607
1583 /* 1608 flags |= cachep->gfpflags;
1584 * Under NUMA we want memory on the indicated node. We will handle
1585 * the needed fallback ourselves since we want to serve from our
1586 * per node object lists first for other nodes.
1587 */
1588 flags |= cachep->gfpflags | GFP_THISNODE;
1589 1609
1590 page = alloc_pages_node(nodeid, flags, cachep->gfporder); 1610 page = alloc_pages_node(nodeid, flags, cachep->gfporder);
1591 if (!page) 1611 if (!page)
@@ -2098,15 +2118,12 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2098 } 2118 }
2099 2119
2100 /* 2120 /*
2101 * Prevent CPUs from coming and going. 2121 * We use cache_chain_mutex to ensure a consistent view of
2102 * lock_cpu_hotplug() nests outside cache_chain_mutex 2122 * cpu_online_map as well. Please see cpuup_callback
2103 */ 2123 */
2104 lock_cpu_hotplug();
2105
2106 mutex_lock(&cache_chain_mutex); 2124 mutex_lock(&cache_chain_mutex);
2107 2125
2108 list_for_each_entry(pc, &cache_chain, next) { 2126 list_for_each_entry(pc, &cache_chain, next) {
2109 mm_segment_t old_fs = get_fs();
2110 char tmp; 2127 char tmp;
2111 int res; 2128 int res;
2112 2129
@@ -2115,9 +2132,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2115 * destroy its slab cache and no-one else reuses the vmalloc 2132 * destroy its slab cache and no-one else reuses the vmalloc
2116 * area of the module. Print a warning. 2133 * area of the module. Print a warning.
2117 */ 2134 */
2118 set_fs(KERNEL_DS); 2135 res = probe_kernel_address(pc->name, tmp);
2119 res = __get_user(tmp, pc->name);
2120 set_fs(old_fs);
2121 if (res) { 2136 if (res) {
2122 printk("SLAB: cache with size %d has lost its name\n", 2137 printk("SLAB: cache with size %d has lost its name\n",
2123 pc->buffer_size); 2138 pc->buffer_size);
@@ -2197,25 +2212,24 @@ kmem_cache_create (const char *name, size_t size, size_t align,
2197 if (flags & SLAB_RED_ZONE || flags & SLAB_STORE_USER) 2212 if (flags & SLAB_RED_ZONE || flags & SLAB_STORE_USER)
2198 ralign = BYTES_PER_WORD; 2213 ralign = BYTES_PER_WORD;
2199 2214
2200 /* 2) arch mandated alignment: disables debug if necessary */ 2215 /* 2) arch mandated alignment */
2201 if (ralign < ARCH_SLAB_MINALIGN) { 2216 if (ralign < ARCH_SLAB_MINALIGN) {
2202 ralign = ARCH_SLAB_MINALIGN; 2217 ralign = ARCH_SLAB_MINALIGN;
2203 if (ralign > BYTES_PER_WORD)
2204 flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
2205 } 2218 }
2206 /* 3) caller mandated alignment: disables debug if necessary */ 2219 /* 3) caller mandated alignment */
2207 if (ralign < align) { 2220 if (ralign < align) {
2208 ralign = align; 2221 ralign = align;
2209 if (ralign > BYTES_PER_WORD)
2210 flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
2211 } 2222 }
2223 /* disable debug if necessary */
2224 if (ralign > BYTES_PER_WORD)
2225 flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
2212 /* 2226 /*
2213 * 4) Store it. 2227 * 4) Store it.
2214 */ 2228 */
2215 align = ralign; 2229 align = ralign;
2216 2230
2217 /* Get cache's description obj. */ 2231 /* Get cache's description obj. */
2218 cachep = kmem_cache_zalloc(&cache_cache, SLAB_KERNEL); 2232 cachep = kmem_cache_zalloc(&cache_cache, GFP_KERNEL);
2219 if (!cachep) 2233 if (!cachep)
2220 goto oops; 2234 goto oops;
2221 2235
@@ -2326,7 +2340,6 @@ oops:
2326 panic("kmem_cache_create(): failed to create slab `%s'\n", 2340 panic("kmem_cache_create(): failed to create slab `%s'\n",
2327 name); 2341 name);
2328 mutex_unlock(&cache_chain_mutex); 2342 mutex_unlock(&cache_chain_mutex);
2329 unlock_cpu_hotplug();
2330 return cachep; 2343 return cachep;
2331} 2344}
2332EXPORT_SYMBOL(kmem_cache_create); 2345EXPORT_SYMBOL(kmem_cache_create);
@@ -2444,6 +2457,7 @@ out:
2444 return nr_freed; 2457 return nr_freed;
2445} 2458}
2446 2459
2460/* Called with cache_chain_mutex held to protect against cpu hotplug */
2447static int __cache_shrink(struct kmem_cache *cachep) 2461static int __cache_shrink(struct kmem_cache *cachep)
2448{ 2462{
2449 int ret = 0, i = 0; 2463 int ret = 0, i = 0;
@@ -2474,9 +2488,13 @@ static int __cache_shrink(struct kmem_cache *cachep)
2474 */ 2488 */
2475int kmem_cache_shrink(struct kmem_cache *cachep) 2489int kmem_cache_shrink(struct kmem_cache *cachep)
2476{ 2490{
2491 int ret;
2477 BUG_ON(!cachep || in_interrupt()); 2492 BUG_ON(!cachep || in_interrupt());
2478 2493
2479 return __cache_shrink(cachep); 2494 mutex_lock(&cache_chain_mutex);
2495 ret = __cache_shrink(cachep);
2496 mutex_unlock(&cache_chain_mutex);
2497 return ret;
2480} 2498}
2481EXPORT_SYMBOL(kmem_cache_shrink); 2499EXPORT_SYMBOL(kmem_cache_shrink);
2482 2500
@@ -2500,23 +2518,16 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
2500{ 2518{
2501 BUG_ON(!cachep || in_interrupt()); 2519 BUG_ON(!cachep || in_interrupt());
2502 2520
2503 /* Don't let CPUs to come and go */
2504 lock_cpu_hotplug();
2505
2506 /* Find the cache in the chain of caches. */ 2521 /* Find the cache in the chain of caches. */
2507 mutex_lock(&cache_chain_mutex); 2522 mutex_lock(&cache_chain_mutex);
2508 /* 2523 /*
2509 * the chain is never empty, cache_cache is never destroyed 2524 * the chain is never empty, cache_cache is never destroyed
2510 */ 2525 */
2511 list_del(&cachep->next); 2526 list_del(&cachep->next);
2512 mutex_unlock(&cache_chain_mutex);
2513
2514 if (__cache_shrink(cachep)) { 2527 if (__cache_shrink(cachep)) {
2515 slab_error(cachep, "Can't free all objects"); 2528 slab_error(cachep, "Can't free all objects");
2516 mutex_lock(&cache_chain_mutex);
2517 list_add(&cachep->next, &cache_chain); 2529 list_add(&cachep->next, &cache_chain);
2518 mutex_unlock(&cache_chain_mutex); 2530 mutex_unlock(&cache_chain_mutex);
2519 unlock_cpu_hotplug();
2520 return; 2531 return;
2521 } 2532 }
2522 2533
@@ -2524,7 +2535,7 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
2524 synchronize_rcu(); 2535 synchronize_rcu();
2525 2536
2526 __kmem_cache_destroy(cachep); 2537 __kmem_cache_destroy(cachep);
2527 unlock_cpu_hotplug(); 2538 mutex_unlock(&cache_chain_mutex);
2528} 2539}
2529EXPORT_SYMBOL(kmem_cache_destroy); 2540EXPORT_SYMBOL(kmem_cache_destroy);
2530 2541
@@ -2548,7 +2559,7 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
2548 if (OFF_SLAB(cachep)) { 2559 if (OFF_SLAB(cachep)) {
2549 /* Slab management obj is off-slab. */ 2560 /* Slab management obj is off-slab. */
2550 slabp = kmem_cache_alloc_node(cachep->slabp_cache, 2561 slabp = kmem_cache_alloc_node(cachep->slabp_cache,
2551 local_flags, nodeid); 2562 local_flags & ~GFP_THISNODE, nodeid);
2552 if (!slabp) 2563 if (!slabp)
2553 return NULL; 2564 return NULL;
2554 } else { 2565 } else {
@@ -2618,7 +2629,7 @@ static void cache_init_objs(struct kmem_cache *cachep,
2618 2629
2619static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags) 2630static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
2620{ 2631{
2621 if (flags & SLAB_DMA) 2632 if (flags & GFP_DMA)
2622 BUG_ON(!(cachep->gfpflags & GFP_DMA)); 2633 BUG_ON(!(cachep->gfpflags & GFP_DMA));
2623 else 2634 else
2624 BUG_ON(cachep->gfpflags & GFP_DMA); 2635 BUG_ON(cachep->gfpflags & GFP_DMA);
@@ -2689,10 +2700,10 @@ static void slab_map_pages(struct kmem_cache *cache, struct slab *slab,
2689 * Grow (by 1) the number of slabs within a cache. This is called by 2700 * Grow (by 1) the number of slabs within a cache. This is called by
2690 * kmem_cache_alloc() when there are no active objs left in a cache. 2701 * kmem_cache_alloc() when there are no active objs left in a cache.
2691 */ 2702 */
2692static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid) 2703static int cache_grow(struct kmem_cache *cachep,
2704 gfp_t flags, int nodeid, void *objp)
2693{ 2705{
2694 struct slab *slabp; 2706 struct slab *slabp;
2695 void *objp;
2696 size_t offset; 2707 size_t offset;
2697 gfp_t local_flags; 2708 gfp_t local_flags;
2698 unsigned long ctor_flags; 2709 unsigned long ctor_flags;
@@ -2702,12 +2713,12 @@ static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
2702 * Be lazy and only check for valid flags here, keeping it out of the 2713 * Be lazy and only check for valid flags here, keeping it out of the
2703 * critical path in kmem_cache_alloc(). 2714 * critical path in kmem_cache_alloc().
2704 */ 2715 */
2705 BUG_ON(flags & ~(SLAB_DMA | SLAB_LEVEL_MASK | SLAB_NO_GROW)); 2716 BUG_ON(flags & ~(GFP_DMA | GFP_LEVEL_MASK | __GFP_NO_GROW));
2706 if (flags & SLAB_NO_GROW) 2717 if (flags & __GFP_NO_GROW)
2707 return 0; 2718 return 0;
2708 2719
2709 ctor_flags = SLAB_CTOR_CONSTRUCTOR; 2720 ctor_flags = SLAB_CTOR_CONSTRUCTOR;
2710 local_flags = (flags & SLAB_LEVEL_MASK); 2721 local_flags = (flags & GFP_LEVEL_MASK);
2711 if (!(local_flags & __GFP_WAIT)) 2722 if (!(local_flags & __GFP_WAIT))
2712 /* 2723 /*
2713 * Not allowed to sleep. Need to tell a constructor about 2724 * Not allowed to sleep. Need to tell a constructor about
@@ -2744,12 +2755,14 @@ static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
2744 * Get mem for the objs. Attempt to allocate a physical page from 2755 * Get mem for the objs. Attempt to allocate a physical page from
2745 * 'nodeid'. 2756 * 'nodeid'.
2746 */ 2757 */
2747 objp = kmem_getpages(cachep, flags, nodeid); 2758 if (!objp)
2759 objp = kmem_getpages(cachep, flags, nodeid);
2748 if (!objp) 2760 if (!objp)
2749 goto failed; 2761 goto failed;
2750 2762
2751 /* Get slab management. */ 2763 /* Get slab management. */
2752 slabp = alloc_slabmgmt(cachep, objp, offset, local_flags, nodeid); 2764 slabp = alloc_slabmgmt(cachep, objp, offset,
2765 local_flags & ~GFP_THISNODE, nodeid);
2753 if (!slabp) 2766 if (!slabp)
2754 goto opps1; 2767 goto opps1;
2755 2768
@@ -2987,7 +3000,7 @@ alloc_done:
2987 3000
2988 if (unlikely(!ac->avail)) { 3001 if (unlikely(!ac->avail)) {
2989 int x; 3002 int x;
2990 x = cache_grow(cachep, flags, node); 3003 x = cache_grow(cachep, flags | GFP_THISNODE, node, NULL);
2991 3004
2992 /* cache_grow can reenable interrupts, then ac could change. */ 3005 /* cache_grow can reenable interrupts, then ac could change. */
2993 ac = cpu_cache_get(cachep); 3006 ac = cpu_cache_get(cachep);
@@ -3063,6 +3076,12 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
3063 3076
3064 cachep->ctor(objp, cachep, ctor_flags); 3077 cachep->ctor(objp, cachep, ctor_flags);
3065 } 3078 }
3079#if ARCH_SLAB_MINALIGN
3080 if ((u32)objp & (ARCH_SLAB_MINALIGN-1)) {
3081 printk(KERN_ERR "0x%p: not aligned to ARCH_SLAB_MINALIGN=%d\n",
3082 objp, ARCH_SLAB_MINALIGN);
3083 }
3084#endif
3066 return objp; 3085 return objp;
3067} 3086}
3068#else 3087#else
@@ -3105,10 +3124,10 @@ static __always_inline void *__cache_alloc(struct kmem_cache *cachep,
3105 objp = ____cache_alloc(cachep, flags); 3124 objp = ____cache_alloc(cachep, flags);
3106 /* 3125 /*
3107 * We may just have run out of memory on the local node. 3126 * We may just have run out of memory on the local node.
3108 * __cache_alloc_node() knows how to locate memory on other nodes 3127 * ____cache_alloc_node() knows how to locate memory on other nodes
3109 */ 3128 */
3110 if (NUMA_BUILD && !objp) 3129 if (NUMA_BUILD && !objp)
3111 objp = __cache_alloc_node(cachep, flags, numa_node_id()); 3130 objp = ____cache_alloc_node(cachep, flags, numa_node_id());
3112 local_irq_restore(save_flags); 3131 local_irq_restore(save_flags);
3113 objp = cache_alloc_debugcheck_after(cachep, flags, objp, 3132 objp = cache_alloc_debugcheck_after(cachep, flags, objp,
3114 caller); 3133 caller);
@@ -3135,15 +3154,17 @@ static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
3135 else if (current->mempolicy) 3154 else if (current->mempolicy)
3136 nid_alloc = slab_node(current->mempolicy); 3155 nid_alloc = slab_node(current->mempolicy);
3137 if (nid_alloc != nid_here) 3156 if (nid_alloc != nid_here)
3138 return __cache_alloc_node(cachep, flags, nid_alloc); 3157 return ____cache_alloc_node(cachep, flags, nid_alloc);
3139 return NULL; 3158 return NULL;
3140} 3159}
3141 3160
3142/* 3161/*
3143 * Fallback function if there was no memory available and no objects on a 3162 * Fallback function if there was no memory available and no objects on a
3144 * certain node and we are allowed to fall back. We mimick the behavior of 3163 * certain node and fall back is permitted. First we scan all the
3145 * the page allocator. We fall back according to a zonelist determined by 3164 * available nodelists for available objects. If that fails then we
3146 * the policy layer while obeying cpuset constraints. 3165 * perform an allocation without specifying a node. This allows the page
3166 * allocator to do its reclaim / fallback magic. We then insert the
3167 * slab into the proper nodelist and then allocate from it.
3147 */ 3168 */
3148void *fallback_alloc(struct kmem_cache *cache, gfp_t flags) 3169void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3149{ 3170{
@@ -3151,15 +3172,51 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3151 ->node_zonelists[gfp_zone(flags)]; 3172 ->node_zonelists[gfp_zone(flags)];
3152 struct zone **z; 3173 struct zone **z;
3153 void *obj = NULL; 3174 void *obj = NULL;
3175 int nid;
3154 3176
3177retry:
3178 /*
3179 * Look through allowed nodes for objects available
3180 * from existing per node queues.
3181 */
3155 for (z = zonelist->zones; *z && !obj; z++) { 3182 for (z = zonelist->zones; *z && !obj; z++) {
3156 int nid = zone_to_nid(*z); 3183 nid = zone_to_nid(*z);
3184
3185 if (cpuset_zone_allowed(*z, flags) &&
3186 cache->nodelists[nid] &&
3187 cache->nodelists[nid]->free_objects)
3188 obj = ____cache_alloc_node(cache,
3189 flags | GFP_THISNODE, nid);
3190 }
3157 3191
3158 if (zone_idx(*z) <= ZONE_NORMAL && 3192 if (!obj) {
3159 cpuset_zone_allowed(*z, flags) && 3193 /*
3160 cache->nodelists[nid]) 3194 * This allocation will be performed within the constraints
3161 obj = __cache_alloc_node(cache, 3195 * of the current cpuset / memory policy requirements.
3162 flags | __GFP_THISNODE, nid); 3196 * We may trigger various forms of reclaim on the allowed
3197 * set and go into memory reserves if necessary.
3198 */
3199 obj = kmem_getpages(cache, flags, -1);
3200 if (obj) {
3201 /*
3202 * Insert into the appropriate per node queues
3203 */
3204 nid = page_to_nid(virt_to_page(obj));
3205 if (cache_grow(cache, flags, nid, obj)) {
3206 obj = ____cache_alloc_node(cache,
3207 flags | GFP_THISNODE, nid);
3208 if (!obj)
3209 /*
3210 * Another processor may allocate the
3211 * objects in the slab since we are
3212 * not holding any locks.
3213 */
3214 goto retry;
3215 } else {
3216 kmem_freepages(cache, obj);
3217 obj = NULL;
3218 }
3219 }
3163 } 3220 }
3164 return obj; 3221 return obj;
3165} 3222}
@@ -3167,7 +3224,7 @@ void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3167/* 3224/*
3168 * A interface to enable slab creation on nodeid 3225 * A interface to enable slab creation on nodeid
3169 */ 3226 */
3170static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, 3227static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
3171 int nodeid) 3228 int nodeid)
3172{ 3229{
3173 struct list_head *entry; 3230 struct list_head *entry;
@@ -3216,7 +3273,7 @@ retry:
3216 3273
3217must_grow: 3274must_grow:
3218 spin_unlock(&l3->list_lock); 3275 spin_unlock(&l3->list_lock);
3219 x = cache_grow(cachep, flags, nodeid); 3276 x = cache_grow(cachep, flags | GFP_THISNODE, nodeid, NULL);
3220 if (x) 3277 if (x)
3221 goto retry; 3278 goto retry;
3222 3279
@@ -3434,35 +3491,59 @@ out:
3434 * @flags: See kmalloc(). 3491 * @flags: See kmalloc().
3435 * @nodeid: node number of the target node. 3492 * @nodeid: node number of the target node.
3436 * 3493 *
3437 * Identical to kmem_cache_alloc, except that this function is slow 3494 * Identical to kmem_cache_alloc but it will allocate memory on the given
3438 * and can sleep. And it will allocate memory on the given node, which 3495 * node, which can improve the performance for cpu bound structures.
3439 * can improve the performance for cpu bound structures. 3496 *
3440 * New and improved: it will now make sure that the object gets 3497 * Fallback to other node is possible if __GFP_THISNODE is not set.
3441 * put on the correct node list so that there is no false sharing.
3442 */ 3498 */
3443void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid) 3499static __always_inline void *
3500__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
3501 int nodeid, void *caller)
3444{ 3502{
3445 unsigned long save_flags; 3503 unsigned long save_flags;
3446 void *ptr; 3504 void *ptr = NULL;
3447 3505
3448 cache_alloc_debugcheck_before(cachep, flags); 3506 cache_alloc_debugcheck_before(cachep, flags);
3449 local_irq_save(save_flags); 3507 local_irq_save(save_flags);
3450 3508
3451 if (nodeid == -1 || nodeid == numa_node_id() || 3509 if (unlikely(nodeid == -1))
3452 !cachep->nodelists[nodeid]) 3510 nodeid = numa_node_id();
3453 ptr = ____cache_alloc(cachep, flags); 3511
3454 else 3512 if (likely(cachep->nodelists[nodeid])) {
3455 ptr = __cache_alloc_node(cachep, flags, nodeid); 3513 if (nodeid == numa_node_id()) {
3456 local_irq_restore(save_flags); 3514 /*
3515 * Use the locally cached objects if possible.
3516 * However ____cache_alloc does not allow fallback
3517 * to other nodes. It may fail while we still have
3518 * objects on other nodes available.
3519 */
3520 ptr = ____cache_alloc(cachep, flags);
3521 }
3522 if (!ptr) {
3523 /* ___cache_alloc_node can fall back to other nodes */
3524 ptr = ____cache_alloc_node(cachep, flags, nodeid);
3525 }
3526 } else {
3527 /* Node not bootstrapped yet */
3528 if (!(flags & __GFP_THISNODE))
3529 ptr = fallback_alloc(cachep, flags);
3530 }
3457 3531
3458 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, 3532 local_irq_restore(save_flags);
3459 __builtin_return_address(0)); 3533 ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, caller);
3460 3534
3461 return ptr; 3535 return ptr;
3462} 3536}
3537
3538void *kmem_cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, int nodeid)
3539{
3540 return __cache_alloc_node(cachep, flags, nodeid,
3541 __builtin_return_address(0));
3542}
3463EXPORT_SYMBOL(kmem_cache_alloc_node); 3543EXPORT_SYMBOL(kmem_cache_alloc_node);
3464 3544
3465void *__kmalloc_node(size_t size, gfp_t flags, int node) 3545static __always_inline void *
3546__do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
3466{ 3547{
3467 struct kmem_cache *cachep; 3548 struct kmem_cache *cachep;
3468 3549
@@ -3471,8 +3552,29 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
3471 return NULL; 3552 return NULL;
3472 return kmem_cache_alloc_node(cachep, flags, node); 3553 return kmem_cache_alloc_node(cachep, flags, node);
3473} 3554}
3555
3556#ifdef CONFIG_DEBUG_SLAB
3557void *__kmalloc_node(size_t size, gfp_t flags, int node)
3558{
3559 return __do_kmalloc_node(size, flags, node,
3560 __builtin_return_address(0));
3561}
3474EXPORT_SYMBOL(__kmalloc_node); 3562EXPORT_SYMBOL(__kmalloc_node);
3475#endif 3563
3564void *__kmalloc_node_track_caller(size_t size, gfp_t flags,
3565 int node, void *caller)
3566{
3567 return __do_kmalloc_node(size, flags, node, caller);
3568}
3569EXPORT_SYMBOL(__kmalloc_node_track_caller);
3570#else
3571void *__kmalloc_node(size_t size, gfp_t flags, int node)
3572{
3573 return __do_kmalloc_node(size, flags, node, NULL);
3574}
3575EXPORT_SYMBOL(__kmalloc_node);
3576#endif /* CONFIG_DEBUG_SLAB */
3577#endif /* CONFIG_NUMA */
3476 3578
3477/** 3579/**
3478 * __do_kmalloc - allocate memory 3580 * __do_kmalloc - allocate memory
@@ -3583,13 +3685,15 @@ static int alloc_kmemlist(struct kmem_cache *cachep)
3583 int node; 3685 int node;
3584 struct kmem_list3 *l3; 3686 struct kmem_list3 *l3;
3585 struct array_cache *new_shared; 3687 struct array_cache *new_shared;
3586 struct array_cache **new_alien; 3688 struct array_cache **new_alien = NULL;
3587 3689
3588 for_each_online_node(node) { 3690 for_each_online_node(node) {
3589 3691
3590 new_alien = alloc_alien_cache(node, cachep->limit); 3692 if (use_alien_caches) {
3591 if (!new_alien) 3693 new_alien = alloc_alien_cache(node, cachep->limit);
3592 goto fail; 3694 if (!new_alien)
3695 goto fail;
3696 }
3593 3697
3594 new_shared = alloc_arraycache(node, 3698 new_shared = alloc_arraycache(node,
3595 cachep->shared*cachep->batchcount, 3699 cachep->shared*cachep->batchcount,
@@ -4038,7 +4142,7 @@ static int s_show(struct seq_file *m, void *p)
4038 * + further values on SMP and with statistics enabled 4142 * + further values on SMP and with statistics enabled
4039 */ 4143 */
4040 4144
4041struct seq_operations slabinfo_op = { 4145const struct seq_operations slabinfo_op = {
4042 .start = s_start, 4146 .start = s_start,
4043 .next = s_next, 4147 .next = s_next,
4044 .stop = s_stop, 4148 .stop = s_stop,
@@ -4236,7 +4340,7 @@ static int leaks_show(struct seq_file *m, void *p)
4236 return 0; 4340 return 0;
4237} 4341}
4238 4342
4239struct seq_operations slabstats_op = { 4343const struct seq_operations slabstats_op = {
4240 .start = leaks_start, 4344 .start = leaks_start,
4241 .next = s_next, 4345 .next = s_next,
4242 .stop = s_stop, 4346 .stop = s_stop,
diff --git a/mm/sparse.c b/mm/sparse.c
index b3c82ba30012..ac26eb0d73cd 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -24,6 +24,25 @@ struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]
24#endif 24#endif
25EXPORT_SYMBOL(mem_section); 25EXPORT_SYMBOL(mem_section);
26 26
27#ifdef NODE_NOT_IN_PAGE_FLAGS
28/*
29 * If we did not store the node number in the page then we have to
30 * do a lookup in the section_to_node_table in order to find which
31 * node the page belongs to.
32 */
33#if MAX_NUMNODES <= 256
34static u8 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
35#else
36static u16 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
37#endif
38
39int page_to_nid(struct page *page)
40{
41 return section_to_node_table[page_to_section(page)];
42}
43EXPORT_SYMBOL(page_to_nid);
44#endif
45
27#ifdef CONFIG_SPARSEMEM_EXTREME 46#ifdef CONFIG_SPARSEMEM_EXTREME
28static struct mem_section *sparse_index_alloc(int nid) 47static struct mem_section *sparse_index_alloc(int nid)
29{ 48{
@@ -49,6 +68,10 @@ static int sparse_index_init(unsigned long section_nr, int nid)
49 struct mem_section *section; 68 struct mem_section *section;
50 int ret = 0; 69 int ret = 0;
51 70
71#ifdef NODE_NOT_IN_PAGE_FLAGS
72 section_to_node_table[section_nr] = nid;
73#endif
74
52 if (mem_section[root]) 75 if (mem_section[root])
53 return -EEXIST; 76 return -EEXIST;
54 77
diff --git a/mm/swap.c b/mm/swap.c
index d9a3770d8f3c..2ed7be39795e 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -57,9 +57,9 @@ static void put_compound_page(struct page *page)
57{ 57{
58 page = (struct page *)page_private(page); 58 page = (struct page *)page_private(page);
59 if (put_page_testzero(page)) { 59 if (put_page_testzero(page)) {
60 void (*dtor)(struct page *page); 60 compound_page_dtor *dtor;
61 61
62 dtor = (void (*)(struct page *))page[1].lru.next; 62 dtor = get_compound_page_dtor(page);
63 (*dtor)(page); 63 (*dtor)(page);
64 } 64 }
65} 65}
@@ -514,5 +514,7 @@ void __init swap_setup(void)
514 * Right now other parts of the system means that we 514 * Right now other parts of the system means that we
515 * _really_ don't want to cluster much more 515 * _really_ don't want to cluster much more
516 */ 516 */
517#ifdef CONFIG_HOTPLUG_CPU
517 hotcpu_notifier(cpu_swap_callback, 0); 518 hotcpu_notifier(cpu_swap_callback, 0);
519#endif
518} 520}
diff --git a/mm/swapfile.c b/mm/swapfile.c
index a15def63f28f..c5431072f422 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -427,34 +427,48 @@ void free_swap_and_cache(swp_entry_t entry)
427 427
428#ifdef CONFIG_SOFTWARE_SUSPEND 428#ifdef CONFIG_SOFTWARE_SUSPEND
429/* 429/*
430 * Find the swap type that corresponds to given device (if any) 430 * Find the swap type that corresponds to given device (if any).
431 * 431 *
432 * This is needed for software suspend and is done in such a way that inode 432 * @offset - number of the PAGE_SIZE-sized block of the device, starting
433 * aliasing is allowed. 433 * from 0, in which the swap header is expected to be located.
434 *
435 * This is needed for the suspend to disk (aka swsusp).
434 */ 436 */
435int swap_type_of(dev_t device) 437int swap_type_of(dev_t device, sector_t offset)
436{ 438{
439 struct block_device *bdev = NULL;
437 int i; 440 int i;
438 441
442 if (device)
443 bdev = bdget(device);
444
439 spin_lock(&swap_lock); 445 spin_lock(&swap_lock);
440 for (i = 0; i < nr_swapfiles; i++) { 446 for (i = 0; i < nr_swapfiles; i++) {
441 struct inode *inode; 447 struct swap_info_struct *sis = swap_info + i;
442 448
443 if (!(swap_info[i].flags & SWP_WRITEOK)) 449 if (!(sis->flags & SWP_WRITEOK))
444 continue; 450 continue;
445 451
446 if (!device) { 452 if (!bdev) {
447 spin_unlock(&swap_lock); 453 spin_unlock(&swap_lock);
448 return i; 454 return i;
449 } 455 }
450 inode = swap_info[i].swap_file->f_dentry->d_inode; 456 if (bdev == sis->bdev) {
451 if (S_ISBLK(inode->i_mode) && 457 struct swap_extent *se;
452 device == MKDEV(imajor(inode), iminor(inode))) { 458
453 spin_unlock(&swap_lock); 459 se = list_entry(sis->extent_list.next,
454 return i; 460 struct swap_extent, list);
461 if (se->start_block == offset) {
462 spin_unlock(&swap_lock);
463 bdput(bdev);
464 return i;
465 }
455 } 466 }
456 } 467 }
457 spin_unlock(&swap_lock); 468 spin_unlock(&swap_lock);
469 if (bdev)
470 bdput(bdev);
471
458 return -ENODEV; 472 return -ENODEV;
459} 473}
460 474
@@ -931,6 +945,23 @@ sector_t map_swap_page(struct swap_info_struct *sis, pgoff_t offset)
931 } 945 }
932} 946}
933 947
948#ifdef CONFIG_SOFTWARE_SUSPEND
949/*
950 * Get the (PAGE_SIZE) block corresponding to given offset on the swapdev
951 * corresponding to given index in swap_info (swap type).
952 */
953sector_t swapdev_block(int swap_type, pgoff_t offset)
954{
955 struct swap_info_struct *sis;
956
957 if (swap_type >= nr_swapfiles)
958 return 0;
959
960 sis = swap_info + swap_type;
961 return (sis->flags & SWP_WRITEOK) ? map_swap_page(sis, offset) : 0;
962}
963#endif /* CONFIG_SOFTWARE_SUSPEND */
964
934/* 965/*
935 * Free all of a swapdev's extent information 966 * Free all of a swapdev's extent information
936 */ 967 */
@@ -1274,10 +1305,13 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
1274 1305
1275 mutex_lock(&swapon_mutex); 1306 mutex_lock(&swapon_mutex);
1276 1307
1308 if (!l)
1309 return SEQ_START_TOKEN;
1310
1277 for (i = 0; i < nr_swapfiles; i++, ptr++) { 1311 for (i = 0; i < nr_swapfiles; i++, ptr++) {
1278 if (!(ptr->flags & SWP_USED) || !ptr->swap_map) 1312 if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
1279 continue; 1313 continue;
1280 if (!l--) 1314 if (!--l)
1281 return ptr; 1315 return ptr;
1282 } 1316 }
1283 1317
@@ -1286,10 +1320,17 @@ static void *swap_start(struct seq_file *swap, loff_t *pos)
1286 1320
1287static void *swap_next(struct seq_file *swap, void *v, loff_t *pos) 1321static void *swap_next(struct seq_file *swap, void *v, loff_t *pos)
1288{ 1322{
1289 struct swap_info_struct *ptr = v; 1323 struct swap_info_struct *ptr;
1290 struct swap_info_struct *endptr = swap_info + nr_swapfiles; 1324 struct swap_info_struct *endptr = swap_info + nr_swapfiles;
1291 1325
1292 for (++ptr; ptr < endptr; ptr++) { 1326 if (v == SEQ_START_TOKEN)
1327 ptr = swap_info;
1328 else {
1329 ptr = v;
1330 ptr++;
1331 }
1332
1333 for (; ptr < endptr; ptr++) {
1293 if (!(ptr->flags & SWP_USED) || !ptr->swap_map) 1334 if (!(ptr->flags & SWP_USED) || !ptr->swap_map)
1294 continue; 1335 continue;
1295 ++*pos; 1336 ++*pos;
@@ -1310,8 +1351,10 @@ static int swap_show(struct seq_file *swap, void *v)
1310 struct file *file; 1351 struct file *file;
1311 int len; 1352 int len;
1312 1353
1313 if (v == swap_info) 1354 if (ptr == SEQ_START_TOKEN) {
1314 seq_puts(swap, "Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n"); 1355 seq_puts(swap,"Filename\t\t\t\tType\t\tSize\tUsed\tPriority\n");
1356 return 0;
1357 }
1315 1358
1316 file = ptr->swap_file; 1359 file = ptr->swap_file;
1317 len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\"); 1360 len = seq_path(swap, file->f_vfsmnt, file->f_dentry, " \t\n\\");
@@ -1325,7 +1368,7 @@ static int swap_show(struct seq_file *swap, void *v)
1325 return 0; 1368 return 0;
1326} 1369}
1327 1370
1328static struct seq_operations swaps_op = { 1371static const struct seq_operations swaps_op = {
1329 .start = swap_start, 1372 .start = swap_start,
1330 .next = swap_next, 1373 .next = swap_next,
1331 .stop = swap_stop, 1374 .stop = swap_stop,
@@ -1337,7 +1380,7 @@ static int swaps_open(struct inode *inode, struct file *file)
1337 return seq_open(file, &swaps_op); 1380 return seq_open(file, &swaps_op);
1338} 1381}
1339 1382
1340static struct file_operations proc_swaps_operations = { 1383static const struct file_operations proc_swaps_operations = {
1341 .open = swaps_open, 1384 .open = swaps_open,
1342 .read = seq_read, 1385 .read = seq_read,
1343 .llseek = seq_lseek, 1386 .llseek = seq_lseek,
@@ -1540,6 +1583,11 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
1540 error = -EINVAL; 1583 error = -EINVAL;
1541 if (!maxpages) 1584 if (!maxpages)
1542 goto bad_swap; 1585 goto bad_swap;
1586 if (swapfilesize && maxpages > swapfilesize) {
1587 printk(KERN_WARNING
1588 "Swap area shorter than signature indicates\n");
1589 goto bad_swap;
1590 }
1543 if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode)) 1591 if (swap_header->info.nr_badpages && S_ISREG(inode->i_mode))
1544 goto bad_swap; 1592 goto bad_swap;
1545 if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES) 1593 if (swap_header->info.nr_badpages > MAX_SWAP_BADPAGES)
@@ -1567,12 +1615,6 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags)
1567 goto bad_swap; 1615 goto bad_swap;
1568 } 1616 }
1569 1617
1570 if (swapfilesize && maxpages > swapfilesize) {
1571 printk(KERN_WARNING
1572 "Swap area shorter than signature indicates\n");
1573 error = -EINVAL;
1574 goto bad_swap;
1575 }
1576 if (nr_good_pages) { 1618 if (nr_good_pages) {
1577 p->swap_map[0] = SWAP_MAP_BAD; 1619 p->swap_map[0] = SWAP_MAP_BAD;
1578 p->max = maxpages; 1620 p->max = maxpages;
diff --git a/mm/thrash.c b/mm/thrash.c
index f4c560b4a2b7..9ef9071f99bc 100644
--- a/mm/thrash.c
+++ b/mm/thrash.c
@@ -7,100 +7,74 @@
7 * 7 *
8 * Simple token based thrashing protection, using the algorithm 8 * Simple token based thrashing protection, using the algorithm
9 * described in: http://www.cs.wm.edu/~sjiang/token.pdf 9 * described in: http://www.cs.wm.edu/~sjiang/token.pdf
10 *
11 * Sep 2006, Ashwin Chaugule <ashwin.chaugule@celunite.com>
12 * Improved algorithm to pass token:
13 * Each task has a priority which is incremented if it contended
14 * for the token in an interval less than its previous attempt.
15 * If the token is acquired, that task's priority is boosted to prevent
16 * the token from bouncing around too often and to let the task make
17 * some progress in its execution.
10 */ 18 */
19
11#include <linux/jiffies.h> 20#include <linux/jiffies.h>
12#include <linux/mm.h> 21#include <linux/mm.h>
13#include <linux/sched.h> 22#include <linux/sched.h>
14#include <linux/swap.h> 23#include <linux/swap.h>
15 24
16static DEFINE_SPINLOCK(swap_token_lock); 25static DEFINE_SPINLOCK(swap_token_lock);
17static unsigned long swap_token_timeout; 26struct mm_struct *swap_token_mm;
18static unsigned long swap_token_check; 27static unsigned int global_faults;
19struct mm_struct * swap_token_mm = &init_mm;
20
21#define SWAP_TOKEN_CHECK_INTERVAL (HZ * 2)
22#define SWAP_TOKEN_TIMEOUT (300 * HZ)
23/*
24 * Currently disabled; Needs further code to work at HZ * 300.
25 */
26unsigned long swap_token_default_timeout = SWAP_TOKEN_TIMEOUT;
27
28/*
29 * Take the token away if the process had no page faults
30 * in the last interval, or if it has held the token for
31 * too long.
32 */
33#define SWAP_TOKEN_ENOUGH_RSS 1
34#define SWAP_TOKEN_TIMED_OUT 2
35static int should_release_swap_token(struct mm_struct *mm)
36{
37 int ret = 0;
38 if (!mm->recent_pagein)
39 ret = SWAP_TOKEN_ENOUGH_RSS;
40 else if (time_after(jiffies, swap_token_timeout))
41 ret = SWAP_TOKEN_TIMED_OUT;
42 mm->recent_pagein = 0;
43 return ret;
44}
45 28
46/*
47 * Try to grab the swapout protection token. We only try to
48 * grab it once every TOKEN_CHECK_INTERVAL, both to prevent
49 * SMP lock contention and to check that the process that held
50 * the token before is no longer thrashing.
51 */
52void grab_swap_token(void) 29void grab_swap_token(void)
53{ 30{
54 struct mm_struct *mm; 31 int current_interval;
55 int reason;
56 32
57 /* We have the token. Let others know we still need it. */ 33 global_faults++;
58 if (has_swap_token(current->mm)) {
59 current->mm->recent_pagein = 1;
60 if (unlikely(!swap_token_default_timeout))
61 disable_swap_token();
62 return;
63 }
64
65 if (time_after(jiffies, swap_token_check)) {
66 34
67 if (!swap_token_default_timeout) { 35 current_interval = global_faults - current->mm->faultstamp;
68 swap_token_check = jiffies + SWAP_TOKEN_CHECK_INTERVAL;
69 return;
70 }
71
72 /* ... or if we recently held the token. */
73 if (time_before(jiffies, current->mm->swap_token_time))
74 return;
75 36
76 if (!spin_trylock(&swap_token_lock)) 37 if (!spin_trylock(&swap_token_lock))
77 return; 38 return;
78 39
79 swap_token_check = jiffies + SWAP_TOKEN_CHECK_INTERVAL; 40 /* First come first served */
41 if (swap_token_mm == NULL) {
42 current->mm->token_priority = current->mm->token_priority + 2;
43 swap_token_mm = current->mm;
44 goto out;
45 }
80 46
81 mm = swap_token_mm; 47 if (current->mm != swap_token_mm) {
82 if ((reason = should_release_swap_token(mm))) { 48 if (current_interval < current->mm->last_interval)
83 unsigned long eligible = jiffies; 49 current->mm->token_priority++;
84 if (reason == SWAP_TOKEN_TIMED_OUT) { 50 else {
85 eligible += swap_token_default_timeout; 51 current->mm->token_priority--;
86 } 52 if (unlikely(current->mm->token_priority < 0))
87 mm->swap_token_time = eligible; 53 current->mm->token_priority = 0;
88 swap_token_timeout = jiffies + swap_token_default_timeout; 54 }
55 /* Check if we deserve the token */
56 if (current->mm->token_priority >
57 swap_token_mm->token_priority) {
58 current->mm->token_priority += 2;
89 swap_token_mm = current->mm; 59 swap_token_mm = current->mm;
90 } 60 }
91 spin_unlock(&swap_token_lock); 61 } else {
62 /* Token holder came in again! */
63 current->mm->token_priority += 2;
92 } 64 }
93 return; 65
66out:
67 current->mm->faultstamp = global_faults;
68 current->mm->last_interval = current_interval;
69 spin_unlock(&swap_token_lock);
70return;
94} 71}
95 72
96/* Called on process exit. */ 73/* Called on process exit. */
97void __put_swap_token(struct mm_struct *mm) 74void __put_swap_token(struct mm_struct *mm)
98{ 75{
99 spin_lock(&swap_token_lock); 76 spin_lock(&swap_token_lock);
100 if (likely(mm == swap_token_mm)) { 77 if (likely(mm == swap_token_mm))
101 mm->swap_token_time = jiffies + SWAP_TOKEN_CHECK_INTERVAL; 78 swap_token_mm = NULL;
102 swap_token_mm = &init_mm;
103 swap_token_check = jiffies;
104 }
105 spin_unlock(&swap_token_lock); 79 spin_unlock(&swap_token_lock);
106} 80}
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 518540a4a2a6..093f5fe6dd77 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -36,6 +36,7 @@
36#include <linux/rwsem.h> 36#include <linux/rwsem.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/kthread.h> 38#include <linux/kthread.h>
39#include <linux/freezer.h>
39 40
40#include <asm/tlbflush.h> 41#include <asm/tlbflush.h>
41#include <asm/div64.h> 42#include <asm/div64.h>
@@ -1172,11 +1173,12 @@ loop_again:
1172 if (!zone_watermark_ok(zone, order, zone->pages_high, 1173 if (!zone_watermark_ok(zone, order, zone->pages_high,
1173 0, 0)) { 1174 0, 0)) {
1174 end_zone = i; 1175 end_zone = i;
1175 goto scan; 1176 break;
1176 } 1177 }
1177 } 1178 }
1178 goto out; 1179 if (i < 0)
1179scan: 1180 goto out;
1181
1180 for (i = 0; i <= end_zone; i++) { 1182 for (i = 0; i <= end_zone; i++) {
1181 struct zone *zone = pgdat->node_zones + i; 1183 struct zone *zone = pgdat->node_zones + i;
1182 1184
@@ -1259,6 +1261,9 @@ out:
1259 } 1261 }
1260 if (!all_zones_ok) { 1262 if (!all_zones_ok) {
1261 cond_resched(); 1263 cond_resched();
1264
1265 try_to_freeze();
1266
1262 goto loop_again; 1267 goto loop_again;
1263 } 1268 }
1264 1269
@@ -1508,7 +1513,6 @@ out:
1508} 1513}
1509#endif 1514#endif
1510 1515
1511#ifdef CONFIG_HOTPLUG_CPU
1512/* It's optimal to keep kswapds on the same CPUs as their memory, but 1516/* It's optimal to keep kswapds on the same CPUs as their memory, but
1513 not required for correctness. So if the last cpu in a node goes 1517 not required for correctness. So if the last cpu in a node goes
1514 away, we get changed to run anywhere: as the first one comes back, 1518 away, we get changed to run anywhere: as the first one comes back,
@@ -1529,7 +1533,6 @@ static int __devinit cpu_callback(struct notifier_block *nfb,
1529 } 1533 }
1530 return NOTIFY_OK; 1534 return NOTIFY_OK;
1531} 1535}
1532#endif /* CONFIG_HOTPLUG_CPU */
1533 1536
1534/* 1537/*
1535 * This kswapd start function will be called by init and node-hot-add. 1538 * This kswapd start function will be called by init and node-hot-add.
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 8614e8f6743b..dc005a0c96ae 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -430,7 +430,7 @@ static int frag_show(struct seq_file *m, void *arg)
430 return 0; 430 return 0;
431} 431}
432 432
433struct seq_operations fragmentation_op = { 433const struct seq_operations fragmentation_op = {
434 .start = frag_start, 434 .start = frag_start,
435 .next = frag_next, 435 .next = frag_next,
436 .stop = frag_stop, 436 .stop = frag_stop,
@@ -452,7 +452,7 @@ struct seq_operations fragmentation_op = {
452#define TEXTS_FOR_ZONES(xx) xx "_dma", TEXT_FOR_DMA32(xx) xx "_normal", \ 452#define TEXTS_FOR_ZONES(xx) xx "_dma", TEXT_FOR_DMA32(xx) xx "_normal", \
453 TEXT_FOR_HIGHMEM(xx) 453 TEXT_FOR_HIGHMEM(xx)
454 454
455static char *vmstat_text[] = { 455static const char * const vmstat_text[] = {
456 /* Zoned VM counters */ 456 /* Zoned VM counters */
457 "nr_anon_pages", 457 "nr_anon_pages",
458 "nr_mapped", 458 "nr_mapped",
@@ -597,7 +597,7 @@ static int zoneinfo_show(struct seq_file *m, void *arg)
597 return 0; 597 return 0;
598} 598}
599 599
600struct seq_operations zoneinfo_op = { 600const struct seq_operations zoneinfo_op = {
601 .start = frag_start, /* iterate over all zones. The same as in 601 .start = frag_start, /* iterate over all zones. The same as in
602 * fragmentation. */ 602 * fragmentation. */
603 .next = frag_next, 603 .next = frag_next,
@@ -660,7 +660,7 @@ static void vmstat_stop(struct seq_file *m, void *arg)
660 m->private = NULL; 660 m->private = NULL;
661} 661}
662 662
663struct seq_operations vmstat_op = { 663const struct seq_operations vmstat_op = {
664 .start = vmstat_start, 664 .start = vmstat_start,
665 .next = vmstat_next, 665 .next = vmstat_next,
666 .stop = vmstat_stop, 666 .stop = vmstat_stop,
@@ -679,13 +679,13 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
679 void *hcpu) 679 void *hcpu)
680{ 680{
681 switch (action) { 681 switch (action) {
682 case CPU_UP_PREPARE: 682 case CPU_UP_PREPARE:
683 case CPU_UP_CANCELED: 683 case CPU_UP_CANCELED:
684 case CPU_DEAD: 684 case CPU_DEAD:
685 refresh_zone_stat_thresholds(); 685 refresh_zone_stat_thresholds();
686 break; 686 break;
687 default: 687 default:
688 break; 688 break;
689 } 689 }
690 return NOTIFY_OK; 690 return NOTIFY_OK;
691} 691}
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index d9f04864d15d..8ca448db7a0d 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -23,7 +23,7 @@
23#include <asm/atomic.h> 23#include <asm/atomic.h>
24#include "br_private.h" 24#include "br_private.h"
25 25
26static kmem_cache_t *br_fdb_cache __read_mostly; 26static struct kmem_cache *br_fdb_cache __read_mostly;
27static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source, 27static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
28 const unsigned char *addr); 28 const unsigned char *addr);
29 29
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index ac47ba2ba028..bd221ad52eaf 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -34,6 +34,7 @@
34#include <linux/netfilter_ipv6.h> 34#include <linux/netfilter_ipv6.h>
35#include <linux/netfilter_arp.h> 35#include <linux/netfilter_arp.h>
36#include <linux/in_route.h> 36#include <linux/in_route.h>
37#include <linux/inetdevice.h>
37 38
38#include <net/ip.h> 39#include <net/ip.h>
39#include <net/ipv6.h> 40#include <net/ipv6.h>
@@ -221,10 +222,14 @@ static void __br_dnat_complain(void)
221 * 222 *
222 * Otherwise, the packet is considered to be routed and we just 223 * Otherwise, the packet is considered to be routed and we just
223 * change the destination MAC address so that the packet will 224 * change the destination MAC address so that the packet will
224 * later be passed up to the IP stack to be routed. 225 * later be passed up to the IP stack to be routed. For a redirected
226 * packet, ip_route_input() will give back the localhost as output device,
227 * which differs from the bridge device.
225 * 228 *
226 * Let us now consider the case that ip_route_input() fails: 229 * Let us now consider the case that ip_route_input() fails:
227 * 230 *
231 * This can be because the destination address is martian, in which case
232 * the packet will be dropped.
228 * After a "echo '0' > /proc/sys/net/ipv4/ip_forward" ip_route_input() 233 * After a "echo '0' > /proc/sys/net/ipv4/ip_forward" ip_route_input()
229 * will fail, while __ip_route_output_key() will return success. The source 234 * will fail, while __ip_route_output_key() will return success. The source
230 * address for __ip_route_output_key() is set to zero, so __ip_route_output_key 235 * address for __ip_route_output_key() is set to zero, so __ip_route_output_key
@@ -237,7 +242,8 @@ static void __br_dnat_complain(void)
237 * 242 *
238 * --Lennert, 20020411 243 * --Lennert, 20020411
239 * --Bart, 20020416 (updated) 244 * --Bart, 20020416 (updated)
240 * --Bart, 20021007 (updated) */ 245 * --Bart, 20021007 (updated)
246 * --Bart, 20062711 (updated) */
241static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb) 247static int br_nf_pre_routing_finish_bridge(struct sk_buff *skb)
242{ 248{
243 if (skb->pkt_type == PACKET_OTHERHOST) { 249 if (skb->pkt_type == PACKET_OTHERHOST) {
@@ -264,15 +270,15 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
264 struct net_device *dev = skb->dev; 270 struct net_device *dev = skb->dev;
265 struct iphdr *iph = skb->nh.iph; 271 struct iphdr *iph = skb->nh.iph;
266 struct nf_bridge_info *nf_bridge = skb->nf_bridge; 272 struct nf_bridge_info *nf_bridge = skb->nf_bridge;
273 int err;
267 274
268 if (nf_bridge->mask & BRNF_PKT_TYPE) { 275 if (nf_bridge->mask & BRNF_PKT_TYPE) {
269 skb->pkt_type = PACKET_OTHERHOST; 276 skb->pkt_type = PACKET_OTHERHOST;
270 nf_bridge->mask ^= BRNF_PKT_TYPE; 277 nf_bridge->mask ^= BRNF_PKT_TYPE;
271 } 278 }
272 nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING; 279 nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;
273
274 if (dnat_took_place(skb)) { 280 if (dnat_took_place(skb)) {
275 if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev)) { 281 if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) {
276 struct rtable *rt; 282 struct rtable *rt;
277 struct flowi fl = { 283 struct flowi fl = {
278 .nl_u = { 284 .nl_u = {
@@ -283,19 +289,33 @@ static int br_nf_pre_routing_finish(struct sk_buff *skb)
283 }, 289 },
284 .proto = 0, 290 .proto = 0,
285 }; 291 };
292 struct in_device *in_dev = in_dev_get(dev);
293
294 /* If err equals -EHOSTUNREACH the error is due to a
295 * martian destination or due to the fact that
296 * forwarding is disabled. For most martian packets,
297 * ip_route_output_key() will fail. It won't fail for 2 types of
298 * martian destinations: loopback destinations and destination
299 * 0.0.0.0. In both cases the packet will be dropped because the
300 * destination is the loopback device and not the bridge. */
301 if (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev))
302 goto free_skb;
286 303
287 if (!ip_route_output_key(&rt, &fl)) { 304 if (!ip_route_output_key(&rt, &fl)) {
288 /* - Bridged-and-DNAT'ed traffic doesn't 305 /* - Bridged-and-DNAT'ed traffic doesn't
289 * require ip_forwarding. 306 * require ip_forwarding. */
290 * - Deal with redirected traffic. */ 307 if (((struct dst_entry *)rt)->dev == dev) {
291 if (((struct dst_entry *)rt)->dev == dev ||
292 rt->rt_type == RTN_LOCAL) {
293 skb->dst = (struct dst_entry *)rt; 308 skb->dst = (struct dst_entry *)rt;
294 goto bridged_dnat; 309 goto bridged_dnat;
295 } 310 }
311 /* we are sure that forwarding is disabled, so printing
312 * this message is no problem. Note that the packet could
313 * still have a martian destination address, in which case
314 * the packet could be dropped even if forwarding were enabled */
296 __br_dnat_complain(); 315 __br_dnat_complain();
297 dst_release((struct dst_entry *)rt); 316 dst_release((struct dst_entry *)rt);
298 } 317 }
318free_skb:
299 kfree_skb(skb); 319 kfree_skb(skb);
300 return 0; 320 return 0;
301 } else { 321 } else {
diff --git a/net/core/dev.c b/net/core/dev.c
index 59d058a3b504..e660cb57e42a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3340,7 +3340,6 @@ void unregister_netdev(struct net_device *dev)
3340 3340
3341EXPORT_SYMBOL(unregister_netdev); 3341EXPORT_SYMBOL(unregister_netdev);
3342 3342
3343#ifdef CONFIG_HOTPLUG_CPU
3344static int dev_cpu_callback(struct notifier_block *nfb, 3343static int dev_cpu_callback(struct notifier_block *nfb,
3345 unsigned long action, 3344 unsigned long action,
3346 void *ocpu) 3345 void *ocpu)
@@ -3384,7 +3383,6 @@ static int dev_cpu_callback(struct notifier_block *nfb,
3384 3383
3385 return NOTIFY_OK; 3384 return NOTIFY_OK;
3386} 3385}
3387#endif /* CONFIG_HOTPLUG_CPU */
3388 3386
3389#ifdef CONFIG_NET_DMA 3387#ifdef CONFIG_NET_DMA
3390/** 3388/**
diff --git a/net/core/dst.c b/net/core/dst.c
index 1a5e49da0e77..836ec6606925 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -125,7 +125,7 @@ void * dst_alloc(struct dst_ops * ops)
125 if (ops->gc()) 125 if (ops->gc())
126 return NULL; 126 return NULL;
127 } 127 }
128 dst = kmem_cache_alloc(ops->kmem_cachep, SLAB_ATOMIC); 128 dst = kmem_cache_alloc(ops->kmem_cachep, GFP_ATOMIC);
129 if (!dst) 129 if (!dst)
130 return NULL; 130 return NULL;
131 memset(dst, 0, ops->entry_size); 131 memset(dst, 0, ops->entry_size);
diff --git a/net/core/flow.c b/net/core/flow.c
index b16d31ae5e54..d137f971f97d 100644
--- a/net/core/flow.c
+++ b/net/core/flow.c
@@ -44,7 +44,7 @@ static DEFINE_PER_CPU(struct flow_cache_entry **, flow_tables) = { NULL };
44 44
45#define flow_table(cpu) (per_cpu(flow_tables, cpu)) 45#define flow_table(cpu) (per_cpu(flow_tables, cpu))
46 46
47static kmem_cache_t *flow_cachep __read_mostly; 47static struct kmem_cache *flow_cachep __read_mostly;
48 48
49static int flow_lwm, flow_hwm; 49static int flow_lwm, flow_hwm;
50 50
@@ -211,7 +211,7 @@ void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir,
211 if (flow_count(cpu) > flow_hwm) 211 if (flow_count(cpu) > flow_hwm)
212 flow_cache_shrink(cpu); 212 flow_cache_shrink(cpu);
213 213
214 fle = kmem_cache_alloc(flow_cachep, SLAB_ATOMIC); 214 fle = kmem_cache_alloc(flow_cachep, GFP_ATOMIC);
215 if (fle) { 215 if (fle) {
216 fle->next = *head; 216 fle->next = *head;
217 *head = fle; 217 *head = fle;
@@ -340,7 +340,6 @@ static void __devinit flow_cache_cpu_prepare(int cpu)
340 tasklet_init(tasklet, flow_cache_flush_tasklet, 0); 340 tasklet_init(tasklet, flow_cache_flush_tasklet, 0);
341} 341}
342 342
343#ifdef CONFIG_HOTPLUG_CPU
344static int flow_cache_cpu(struct notifier_block *nfb, 343static int flow_cache_cpu(struct notifier_block *nfb,
345 unsigned long action, 344 unsigned long action,
346 void *hcpu) 345 void *hcpu)
@@ -349,7 +348,6 @@ static int flow_cache_cpu(struct notifier_block *nfb,
349 __flow_cache_shrink((unsigned long)hcpu, 0); 348 __flow_cache_shrink((unsigned long)hcpu, 0);
350 return NOTIFY_OK; 349 return NOTIFY_OK;
351} 350}
352#endif /* CONFIG_HOTPLUG_CPU */
353 351
354static int __init flow_cache_init(void) 352static int __init flow_cache_init(void)
355{ 353{
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index ba509a4a8e92..0ab1987b9348 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -251,7 +251,7 @@ static struct neighbour *neigh_alloc(struct neigh_table *tbl)
251 goto out_entries; 251 goto out_entries;
252 } 252 }
253 253
254 n = kmem_cache_alloc(tbl->kmem_cachep, SLAB_ATOMIC); 254 n = kmem_cache_alloc(tbl->kmem_cachep, GFP_ATOMIC);
255 if (!n) 255 if (!n)
256 goto out_entries; 256 goto out_entries;
257 257
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 8e1c385e5ba9..de7801d589e7 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -68,8 +68,8 @@
68 68
69#include "kmap_skb.h" 69#include "kmap_skb.h"
70 70
71static kmem_cache_t *skbuff_head_cache __read_mostly; 71static struct kmem_cache *skbuff_head_cache __read_mostly;
72static kmem_cache_t *skbuff_fclone_cache __read_mostly; 72static struct kmem_cache *skbuff_fclone_cache __read_mostly;
73 73
74/* 74/*
75 * Keep out-of-line to prevent kernel bloat. 75 * Keep out-of-line to prevent kernel bloat.
@@ -132,6 +132,7 @@ EXPORT_SYMBOL(skb_truesize_bug);
132 * @gfp_mask: allocation mask 132 * @gfp_mask: allocation mask
133 * @fclone: allocate from fclone cache instead of head cache 133 * @fclone: allocate from fclone cache instead of head cache
134 * and allocate a cloned (child) skb 134 * and allocate a cloned (child) skb
135 * @node: numa node to allocate memory on
135 * 136 *
136 * Allocate a new &sk_buff. The returned buffer has no headroom and a 137 * Allocate a new &sk_buff. The returned buffer has no headroom and a
137 * tail room of size bytes. The object has a reference count of one. 138 * tail room of size bytes. The object has a reference count of one.
@@ -141,9 +142,9 @@ EXPORT_SYMBOL(skb_truesize_bug);
141 * %GFP_ATOMIC. 142 * %GFP_ATOMIC.
142 */ 143 */
143struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, 144struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
144 int fclone) 145 int fclone, int node)
145{ 146{
146 kmem_cache_t *cache; 147 struct kmem_cache *cache;
147 struct skb_shared_info *shinfo; 148 struct skb_shared_info *shinfo;
148 struct sk_buff *skb; 149 struct sk_buff *skb;
149 u8 *data; 150 u8 *data;
@@ -151,14 +152,14 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
151 cache = fclone ? skbuff_fclone_cache : skbuff_head_cache; 152 cache = fclone ? skbuff_fclone_cache : skbuff_head_cache;
152 153
153 /* Get the HEAD */ 154 /* Get the HEAD */
154 skb = kmem_cache_alloc(cache, gfp_mask & ~__GFP_DMA); 155 skb = kmem_cache_alloc_node(cache, gfp_mask & ~__GFP_DMA, node);
155 if (!skb) 156 if (!skb)
156 goto out; 157 goto out;
157 158
158 /* Get the DATA. Size must match skb_add_mtu(). */ 159 /* Get the DATA. Size must match skb_add_mtu(). */
159 size = SKB_DATA_ALIGN(size); 160 size = SKB_DATA_ALIGN(size);
160 data = kmalloc_track_caller(size + sizeof(struct skb_shared_info), 161 data = kmalloc_node_track_caller(size + sizeof(struct skb_shared_info),
161 gfp_mask); 162 gfp_mask, node);
162 if (!data) 163 if (!data)
163 goto nodata; 164 goto nodata;
164 165
@@ -210,7 +211,7 @@ nodata:
210 * Buffers may only be allocated from interrupts using a @gfp_mask of 211 * Buffers may only be allocated from interrupts using a @gfp_mask of
211 * %GFP_ATOMIC. 212 * %GFP_ATOMIC.
212 */ 213 */
213struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, 214struct sk_buff *alloc_skb_from_cache(struct kmem_cache *cp,
214 unsigned int size, 215 unsigned int size,
215 gfp_t gfp_mask) 216 gfp_t gfp_mask)
216{ 217{
@@ -267,9 +268,10 @@ nodata:
267struct sk_buff *__netdev_alloc_skb(struct net_device *dev, 268struct sk_buff *__netdev_alloc_skb(struct net_device *dev,
268 unsigned int length, gfp_t gfp_mask) 269 unsigned int length, gfp_t gfp_mask)
269{ 270{
271 int node = dev->class_dev.dev ? dev_to_node(dev->class_dev.dev) : -1;
270 struct sk_buff *skb; 272 struct sk_buff *skb;
271 273
272 skb = alloc_skb(length + NET_SKB_PAD, gfp_mask); 274 skb = __alloc_skb(length + NET_SKB_PAD, gfp_mask, 0, node);
273 if (likely(skb)) { 275 if (likely(skb)) {
274 skb_reserve(skb, NET_SKB_PAD); 276 skb_reserve(skb, NET_SKB_PAD);
275 skb->dev = dev; 277 skb->dev = dev;
diff --git a/net/core/sock.c b/net/core/sock.c
index 419c7d3289c7..0ed5b4f0bc40 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -810,24 +810,11 @@ lenout:
810 */ 810 */
811static void inline sock_lock_init(struct sock *sk) 811static void inline sock_lock_init(struct sock *sk)
812{ 812{
813 spin_lock_init(&sk->sk_lock.slock); 813 sock_lock_init_class_and_name(sk,
814 sk->sk_lock.owner = NULL; 814 af_family_slock_key_strings[sk->sk_family],
815 init_waitqueue_head(&sk->sk_lock.wq); 815 af_family_slock_keys + sk->sk_family,
816 /* 816 af_family_key_strings[sk->sk_family],
817 * Make sure we are not reinitializing a held lock: 817 af_family_keys + sk->sk_family);
818 */
819 debug_check_no_locks_freed((void *)&sk->sk_lock, sizeof(sk->sk_lock));
820
821 /*
822 * Mark both the sk_lock and the sk_lock.slock as a
823 * per-address-family lock class:
824 */
825 lockdep_set_class_and_name(&sk->sk_lock.slock,
826 af_family_slock_keys + sk->sk_family,
827 af_family_slock_key_strings[sk->sk_family]);
828 lockdep_init_map(&sk->sk_lock.dep_map,
829 af_family_key_strings[sk->sk_family],
830 af_family_keys + sk->sk_family, 0);
831} 818}
832 819
833/** 820/**
@@ -841,7 +828,7 @@ struct sock *sk_alloc(int family, gfp_t priority,
841 struct proto *prot, int zero_it) 828 struct proto *prot, int zero_it)
842{ 829{
843 struct sock *sk = NULL; 830 struct sock *sk = NULL;
844 kmem_cache_t *slab = prot->slab; 831 struct kmem_cache *slab = prot->slab;
845 832
846 if (slab != NULL) 833 if (slab != NULL)
847 sk = kmem_cache_alloc(slab, priority); 834 sk = kmem_cache_alloc(slab, priority);
diff --git a/net/core/wireless.c b/net/core/wireless.c
index cb1b8728d7ee..f69ab7b4408e 100644
--- a/net/core/wireless.c
+++ b/net/core/wireless.c
@@ -2130,7 +2130,7 @@ int iw_handler_set_spy(struct net_device * dev,
2130 * The rtnl_lock() make sure we don't race with the other iw_handlers. 2130 * The rtnl_lock() make sure we don't race with the other iw_handlers.
2131 * This make sure wireless_spy_update() "see" that the spy list 2131 * This make sure wireless_spy_update() "see" that the spy list
2132 * is temporarily disabled. */ 2132 * is temporarily disabled. */
2133 wmb(); 2133 smp_wmb();
2134 2134
2135 /* Are there are addresses to copy? */ 2135 /* Are there are addresses to copy? */
2136 if(wrqu->data.length > 0) { 2136 if(wrqu->data.length > 0) {
@@ -2159,7 +2159,7 @@ int iw_handler_set_spy(struct net_device * dev,
2159 } 2159 }
2160 2160
2161 /* Make sure above is updated before re-enabling */ 2161 /* Make sure above is updated before re-enabling */
2162 wmb(); 2162 smp_wmb();
2163 2163
2164 /* Enable addresses */ 2164 /* Enable addresses */
2165 spydata->spy_number = wrqu->data.length; 2165 spydata->spy_number = wrqu->data.length;
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
index bdf1bb7a82c0..1f4727ddbdbf 100644
--- a/net/dccp/ackvec.c
+++ b/net/dccp/ackvec.c
@@ -21,8 +21,8 @@
21 21
22#include <net/sock.h> 22#include <net/sock.h>
23 23
24static kmem_cache_t *dccp_ackvec_slab; 24static struct kmem_cache *dccp_ackvec_slab;
25static kmem_cache_t *dccp_ackvec_record_slab; 25static struct kmem_cache *dccp_ackvec_record_slab;
26 26
27static struct dccp_ackvec_record *dccp_ackvec_record_new(void) 27static struct dccp_ackvec_record *dccp_ackvec_record_new(void)
28{ 28{
diff --git a/net/dccp/ccid.c b/net/dccp/ccid.c
index ff05e59043cd..d8cf92f09e68 100644
--- a/net/dccp/ccid.c
+++ b/net/dccp/ccid.c
@@ -55,9 +55,9 @@ static inline void ccids_read_unlock(void)
55#define ccids_read_unlock() do { } while(0) 55#define ccids_read_unlock() do { } while(0)
56#endif 56#endif
57 57
58static kmem_cache_t *ccid_kmem_cache_create(int obj_size, const char *fmt,...) 58static struct kmem_cache *ccid_kmem_cache_create(int obj_size, const char *fmt,...)
59{ 59{
60 kmem_cache_t *slab; 60 struct kmem_cache *slab;
61 char slab_name_fmt[32], *slab_name; 61 char slab_name_fmt[32], *slab_name;
62 va_list args; 62 va_list args;
63 63
@@ -75,7 +75,7 @@ static kmem_cache_t *ccid_kmem_cache_create(int obj_size, const char *fmt,...)
75 return slab; 75 return slab;
76} 76}
77 77
78static void ccid_kmem_cache_destroy(kmem_cache_t *slab) 78static void ccid_kmem_cache_destroy(struct kmem_cache *slab)
79{ 79{
80 if (slab != NULL) { 80 if (slab != NULL) {
81 const char *name = kmem_cache_name(slab); 81 const char *name = kmem_cache_name(slab);
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h
index c7c29514dce8..bcc2d12ae81c 100644
--- a/net/dccp/ccid.h
+++ b/net/dccp/ccid.h
@@ -27,9 +27,9 @@ struct ccid_operations {
27 unsigned char ccid_id; 27 unsigned char ccid_id;
28 const char *ccid_name; 28 const char *ccid_name;
29 struct module *ccid_owner; 29 struct module *ccid_owner;
30 kmem_cache_t *ccid_hc_rx_slab; 30 struct kmem_cache *ccid_hc_rx_slab;
31 __u32 ccid_hc_rx_obj_size; 31 __u32 ccid_hc_rx_obj_size;
32 kmem_cache_t *ccid_hc_tx_slab; 32 struct kmem_cache *ccid_hc_tx_slab;
33 __u32 ccid_hc_tx_obj_size; 33 __u32 ccid_hc_tx_obj_size;
34 int (*ccid_hc_rx_init)(struct ccid *ccid, struct sock *sk); 34 int (*ccid_hc_rx_init)(struct ccid *ccid, struct sock *sk);
35 int (*ccid_hc_tx_init)(struct ccid *ccid, struct sock *sk); 35 int (*ccid_hc_tx_init)(struct ccid *ccid, struct sock *sk);
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index cf8c07b2704f..66a27b9688ca 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -295,7 +295,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
295 new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist); 295 new_packet = dccp_tx_hist_head(&hctx->ccid3hctx_hist);
296 if (new_packet == NULL || new_packet->dccphtx_sent) { 296 if (new_packet == NULL || new_packet->dccphtx_sent) {
297 new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist, 297 new_packet = dccp_tx_hist_entry_new(ccid3_tx_hist,
298 SLAB_ATOMIC); 298 GFP_ATOMIC);
299 299
300 if (unlikely(new_packet == NULL)) { 300 if (unlikely(new_packet == NULL)) {
301 DCCP_WARN("%s, sk=%p, not enough mem to add to history," 301 DCCP_WARN("%s, sk=%p, not enough mem to add to history,"
@@ -889,7 +889,7 @@ static void ccid3_hc_rx_update_li(struct sock *sk, u64 seq_loss, u8 win_loss)
889 /* new loss event detected */ 889 /* new loss event detected */
890 /* calculate last interval length */ 890 /* calculate last interval length */
891 seq_temp = dccp_delta_seqno(head->dccplih_seqno, seq_loss); 891 seq_temp = dccp_delta_seqno(head->dccplih_seqno, seq_loss);
892 entry = dccp_li_hist_entry_new(ccid3_li_hist, SLAB_ATOMIC); 892 entry = dccp_li_hist_entry_new(ccid3_li_hist, GFP_ATOMIC);
893 893
894 if (entry == NULL) { 894 if (entry == NULL) {
895 DCCP_BUG("out of memory - can not allocate entry"); 895 DCCP_BUG("out of memory - can not allocate entry");
@@ -1011,7 +1011,7 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb)
1011 } 1011 }
1012 1012
1013 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp, 1013 packet = dccp_rx_hist_entry_new(ccid3_rx_hist, sk, opt_recv->dccpor_ndp,
1014 skb, SLAB_ATOMIC); 1014 skb, GFP_ATOMIC);
1015 if (unlikely(packet == NULL)) { 1015 if (unlikely(packet == NULL)) {
1016 DCCP_WARN("%s, sk=%p, Not enough mem to add rx packet " 1016 DCCP_WARN("%s, sk=%p, Not enough mem to add rx packet "
1017 "to history, consider it lost!\n", dccp_role(sk), sk); 1017 "to history, consider it lost!\n", dccp_role(sk), sk);
diff --git a/net/dccp/ccids/lib/loss_interval.c b/net/dccp/ccids/lib/loss_interval.c
index 48b9b93f8acb..0a0baef16b3e 100644
--- a/net/dccp/ccids/lib/loss_interval.c
+++ b/net/dccp/ccids/lib/loss_interval.c
@@ -125,7 +125,7 @@ int dccp_li_hist_interval_new(struct dccp_li_hist *hist,
125 int i; 125 int i;
126 126
127 for (i = 0; i < DCCP_LI_HIST_IVAL_F_LENGTH; i++) { 127 for (i = 0; i < DCCP_LI_HIST_IVAL_F_LENGTH; i++) {
128 entry = dccp_li_hist_entry_new(hist, SLAB_ATOMIC); 128 entry = dccp_li_hist_entry_new(hist, GFP_ATOMIC);
129 if (entry == NULL) { 129 if (entry == NULL) {
130 dccp_li_hist_purge(hist, list); 130 dccp_li_hist_purge(hist, list);
131 DCCP_BUG("loss interval list entry is NULL"); 131 DCCP_BUG("loss interval list entry is NULL");
diff --git a/net/dccp/ccids/lib/loss_interval.h b/net/dccp/ccids/lib/loss_interval.h
index 0ae85f0340b2..eb257014dd74 100644
--- a/net/dccp/ccids/lib/loss_interval.h
+++ b/net/dccp/ccids/lib/loss_interval.h
@@ -20,7 +20,7 @@
20#define DCCP_LI_HIST_IVAL_F_LENGTH 8 20#define DCCP_LI_HIST_IVAL_F_LENGTH 8
21 21
22struct dccp_li_hist { 22struct dccp_li_hist {
23 kmem_cache_t *dccplih_slab; 23 struct kmem_cache *dccplih_slab;
24}; 24};
25 25
26extern struct dccp_li_hist *dccp_li_hist_new(const char *name); 26extern struct dccp_li_hist *dccp_li_hist_new(const char *name);
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h
index 067cf1c85a37..9a8bcf224aa7 100644
--- a/net/dccp/ccids/lib/packet_history.h
+++ b/net/dccp/ccids/lib/packet_history.h
@@ -68,14 +68,14 @@ struct dccp_rx_hist_entry {
68}; 68};
69 69
70struct dccp_tx_hist { 70struct dccp_tx_hist {
71 kmem_cache_t *dccptxh_slab; 71 struct kmem_cache *dccptxh_slab;
72}; 72};
73 73
74extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name); 74extern struct dccp_tx_hist *dccp_tx_hist_new(const char *name);
75extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist); 75extern void dccp_tx_hist_delete(struct dccp_tx_hist *hist);
76 76
77struct dccp_rx_hist { 77struct dccp_rx_hist {
78 kmem_cache_t *dccprxh_slab; 78 struct kmem_cache *dccprxh_slab;
79}; 79};
80 80
81extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name); 81extern struct dccp_rx_hist *dccp_rx_hist_new(const char *name);
diff --git a/net/decnet/dn_table.c b/net/decnet/dn_table.c
index bdbc3f431668..13b2421991ba 100644
--- a/net/decnet/dn_table.c
+++ b/net/decnet/dn_table.c
@@ -79,7 +79,7 @@ for( ; ((f) = *(fp)) != NULL && dn_key_eq((f)->fn_key, (key)); (fp) = &(f)->fn_n
79static struct hlist_head dn_fib_table_hash[DN_FIB_TABLE_HASHSZ]; 79static struct hlist_head dn_fib_table_hash[DN_FIB_TABLE_HASHSZ];
80static DEFINE_RWLOCK(dn_fib_tables_lock); 80static DEFINE_RWLOCK(dn_fib_tables_lock);
81 81
82static kmem_cache_t *dn_hash_kmem __read_mostly; 82static struct kmem_cache *dn_hash_kmem __read_mostly;
83static int dn_fib_hash_zombies; 83static int dn_fib_hash_zombies;
84 84
85static inline dn_fib_idx_t dn_hash(dn_fib_key_t key, struct dn_zone *dz) 85static inline dn_fib_idx_t dn_hash(dn_fib_key_t key, struct dn_zone *dz)
@@ -590,7 +590,7 @@ create:
590 590
591replace: 591replace:
592 err = -ENOBUFS; 592 err = -ENOBUFS;
593 new_f = kmem_cache_alloc(dn_hash_kmem, SLAB_KERNEL); 593 new_f = kmem_cache_alloc(dn_hash_kmem, GFP_KERNEL);
594 if (new_f == NULL) 594 if (new_f == NULL)
595 goto out; 595 goto out;
596 596
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
index 08386c102954..eec1a1dd91da 100644
--- a/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -431,6 +431,17 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev,
431 return 0; 431 return 0;
432} 432}
433 433
434void
435ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac)
436{
437 unsigned long flags;
438
439 spin_lock_irqsave(&mac->lock, flags);
440 mac->associnfo.associating = 1;
441 schedule_work(&mac->associnfo.work);
442 spin_unlock_irqrestore(&mac->lock, flags);
443}
444
434int 445int
435ieee80211softmac_handle_disassoc(struct net_device * dev, 446ieee80211softmac_handle_disassoc(struct net_device * dev,
436 struct ieee80211_disassoc *disassoc) 447 struct ieee80211_disassoc *disassoc)
@@ -449,8 +460,7 @@ ieee80211softmac_handle_disassoc(struct net_device * dev,
449 dprintk(KERN_INFO PFX "got disassoc frame\n"); 460 dprintk(KERN_INFO PFX "got disassoc frame\n");
450 ieee80211softmac_disassoc(mac); 461 ieee80211softmac_disassoc(mac);
451 462
452 /* try to reassociate */ 463 ieee80211softmac_try_reassoc(mac);
453 schedule_delayed_work(&mac->associnfo.work, 0);
454 464
455 return 0; 465 return 0;
456} 466}
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c
index 6012705aa4f8..8ed3e59b8024 100644
--- a/net/ieee80211/softmac/ieee80211softmac_auth.c
+++ b/net/ieee80211/softmac/ieee80211softmac_auth.c
@@ -337,6 +337,8 @@ ieee80211softmac_deauth_from_net(struct ieee80211softmac_device *mac,
337 /* can't transmit data right now... */ 337 /* can't transmit data right now... */
338 netif_carrier_off(mac->dev); 338 netif_carrier_off(mac->dev);
339 spin_unlock_irqrestore(&mac->lock, flags); 339 spin_unlock_irqrestore(&mac->lock, flags);
340
341 ieee80211softmac_try_reassoc(mac);
340} 342}
341 343
342/* 344/*
diff --git a/net/ieee80211/softmac/ieee80211softmac_priv.h b/net/ieee80211/softmac/ieee80211softmac_priv.h
index c0dbe070e548..4c2bba34d328 100644
--- a/net/ieee80211/softmac/ieee80211softmac_priv.h
+++ b/net/ieee80211/softmac/ieee80211softmac_priv.h
@@ -239,4 +239,6 @@ void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, in
239int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac, 239int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
240 int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask); 240 int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask);
241 241
242void ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac);
243
242#endif /* IEEE80211SOFTMAC_PRIV_H_ */ 244#endif /* IEEE80211SOFTMAC_PRIV_H_ */
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index 2ffaebd21c53..480d72c7a42c 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -495,7 +495,8 @@ ieee80211softmac_wx_set_mlme(struct net_device *dev,
495 printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n"); 495 printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n");
496 goto out; 496 goto out;
497 } 497 }
498 return ieee80211softmac_deauth_req(mac, net, reason); 498 err = ieee80211softmac_deauth_req(mac, net, reason);
499 goto out;
499 case IW_MLME_DISASSOC: 500 case IW_MLME_DISASSOC:
500 ieee80211softmac_send_disassoc_req(mac, reason); 501 ieee80211softmac_send_disassoc_req(mac, reason);
501 mac->associnfo.associated = 0; 502 mac->associnfo.associated = 0;
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 107bb6cbb0b3..648f47c1c399 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -45,8 +45,8 @@
45 45
46#include "fib_lookup.h" 46#include "fib_lookup.h"
47 47
48static kmem_cache_t *fn_hash_kmem __read_mostly; 48static struct kmem_cache *fn_hash_kmem __read_mostly;
49static kmem_cache_t *fn_alias_kmem __read_mostly; 49static struct kmem_cache *fn_alias_kmem __read_mostly;
50 50
51struct fib_node { 51struct fib_node {
52 struct hlist_node fn_hash; 52 struct hlist_node fn_hash;
@@ -485,13 +485,13 @@ static int fn_hash_insert(struct fib_table *tb, struct fib_config *cfg)
485 goto out; 485 goto out;
486 486
487 err = -ENOBUFS; 487 err = -ENOBUFS;
488 new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL); 488 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
489 if (new_fa == NULL) 489 if (new_fa == NULL)
490 goto out; 490 goto out;
491 491
492 new_f = NULL; 492 new_f = NULL;
493 if (!f) { 493 if (!f) {
494 new_f = kmem_cache_alloc(fn_hash_kmem, SLAB_KERNEL); 494 new_f = kmem_cache_alloc(fn_hash_kmem, GFP_KERNEL);
495 if (new_f == NULL) 495 if (new_f == NULL)
496 goto out_free_new_fa; 496 goto out_free_new_fa;
497 497
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index d17990ec724f..cfb249cc0a58 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -172,7 +172,7 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn);
172static struct tnode *halve(struct trie *t, struct tnode *tn); 172static struct tnode *halve(struct trie *t, struct tnode *tn);
173static void tnode_free(struct tnode *tn); 173static void tnode_free(struct tnode *tn);
174 174
175static kmem_cache_t *fn_alias_kmem __read_mostly; 175static struct kmem_cache *fn_alias_kmem __read_mostly;
176static struct trie *trie_local = NULL, *trie_main = NULL; 176static struct trie *trie_local = NULL, *trie_main = NULL;
177 177
178 178
@@ -1187,7 +1187,7 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1187 u8 state; 1187 u8 state;
1188 1188
1189 err = -ENOBUFS; 1189 err = -ENOBUFS;
1190 new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL); 1190 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
1191 if (new_fa == NULL) 1191 if (new_fa == NULL)
1192 goto out; 1192 goto out;
1193 1193
@@ -1232,7 +1232,7 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1232 goto out; 1232 goto out;
1233 1233
1234 err = -ENOBUFS; 1234 err = -ENOBUFS;
1235 new_fa = kmem_cache_alloc(fn_alias_kmem, SLAB_KERNEL); 1235 new_fa = kmem_cache_alloc(fn_alias_kmem, GFP_KERNEL);
1236 if (new_fa == NULL) 1236 if (new_fa == NULL)
1237 goto out; 1237 goto out;
1238 1238
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 244c4f445c7d..8c79c8a4ea5c 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -27,11 +27,11 @@
27 * Allocate and initialize a new local port bind bucket. 27 * Allocate and initialize a new local port bind bucket.
28 * The bindhash mutex for snum's hash chain must be held here. 28 * The bindhash mutex for snum's hash chain must be held here.
29 */ 29 */
30struct inet_bind_bucket *inet_bind_bucket_create(kmem_cache_t *cachep, 30struct inet_bind_bucket *inet_bind_bucket_create(struct kmem_cache *cachep,
31 struct inet_bind_hashbucket *head, 31 struct inet_bind_hashbucket *head,
32 const unsigned short snum) 32 const unsigned short snum)
33{ 33{
34 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, SLAB_ATOMIC); 34 struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC);
35 35
36 if (tb != NULL) { 36 if (tb != NULL) {
37 tb->port = snum; 37 tb->port = snum;
@@ -45,7 +45,7 @@ struct inet_bind_bucket *inet_bind_bucket_create(kmem_cache_t *cachep,
45/* 45/*
46 * Caller must hold hashbucket lock for this tb with local BH disabled 46 * Caller must hold hashbucket lock for this tb with local BH disabled
47 */ 47 */
48void inet_bind_bucket_destroy(kmem_cache_t *cachep, struct inet_bind_bucket *tb) 48void inet_bind_bucket_destroy(struct kmem_cache *cachep, struct inet_bind_bucket *tb)
49{ 49{
50 if (hlist_empty(&tb->owners)) { 50 if (hlist_empty(&tb->owners)) {
51 __hlist_del(&tb->node); 51 __hlist_del(&tb->node);
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 8c74f9168b7d..9f414e35c488 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -91,7 +91,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat
91{ 91{
92 struct inet_timewait_sock *tw = 92 struct inet_timewait_sock *tw =
93 kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab, 93 kmem_cache_alloc(sk->sk_prot_creator->twsk_prot->twsk_slab,
94 SLAB_ATOMIC); 94 GFP_ATOMIC);
95 if (tw != NULL) { 95 if (tw != NULL) {
96 const struct inet_sock *inet = inet_sk(sk); 96 const struct inet_sock *inet = inet_sk(sk);
97 97
@@ -178,7 +178,6 @@ void inet_twdr_hangman(unsigned long data)
178 need_timer = 0; 178 need_timer = 0;
179 if (inet_twdr_do_twkill_work(twdr, twdr->slot)) { 179 if (inet_twdr_do_twkill_work(twdr, twdr->slot)) {
180 twdr->thread_slots |= (1 << twdr->slot); 180 twdr->thread_slots |= (1 << twdr->slot);
181 mb();
182 schedule_work(&twdr->twkill_work); 181 schedule_work(&twdr->twkill_work);
183 need_timer = 1; 182 need_timer = 1;
184 } else { 183 } else {
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index f072f3875af8..711eb6d0285a 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -73,7 +73,7 @@
73/* Exported for inet_getid inline function. */ 73/* Exported for inet_getid inline function. */
74DEFINE_SPINLOCK(inet_peer_idlock); 74DEFINE_SPINLOCK(inet_peer_idlock);
75 75
76static kmem_cache_t *peer_cachep __read_mostly; 76static struct kmem_cache *peer_cachep __read_mostly;
77 77
78#define node_height(x) x->avl_height 78#define node_height(x) x->avl_height
79static struct inet_peer peer_fake_node = { 79static struct inet_peer peer_fake_node = {
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index efcf45ecc818..ecb5422ea237 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -105,7 +105,7 @@ static DEFINE_SPINLOCK(mfc_unres_lock);
105 In this case data path is free of exclusive locks at all. 105 In this case data path is free of exclusive locks at all.
106 */ 106 */
107 107
108static kmem_cache_t *mrt_cachep __read_mostly; 108static struct kmem_cache *mrt_cachep __read_mostly;
109 109
110static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local); 110static int ip_mr_forward(struct sk_buff *skb, struct mfc_cache *cache, int local);
111static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert); 111static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert);
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
index 8832eb517d52..8086787a2c51 100644
--- a/net/ipv4/ipvs/ip_vs_conn.c
+++ b/net/ipv4/ipvs/ip_vs_conn.c
@@ -44,7 +44,7 @@
44static struct list_head *ip_vs_conn_tab; 44static struct list_head *ip_vs_conn_tab;
45 45
46/* SLAB cache for IPVS connections */ 46/* SLAB cache for IPVS connections */
47static kmem_cache_t *ip_vs_conn_cachep __read_mostly; 47static struct kmem_cache *ip_vs_conn_cachep __read_mostly;
48 48
49/* counter for current IPVS connections */ 49/* counter for current IPVS connections */
50static atomic_t ip_vs_conn_count = ATOMIC_INIT(0); 50static atomic_t ip_vs_conn_count = ATOMIC_INIT(0);
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 413c2d0a1f3d..71b76ade00e1 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -375,6 +375,13 @@ static int mark_source_chains(struct xt_table_info *newinfo,
375 && unconditional(&e->arp)) { 375 && unconditional(&e->arp)) {
376 unsigned int oldpos, size; 376 unsigned int oldpos, size;
377 377
378 if (t->verdict < -NF_MAX_VERDICT - 1) {
379 duprintf("mark_source_chains: bad "
380 "negative verdict (%i)\n",
381 t->verdict);
382 return 0;
383 }
384
378 /* Return: backtrack through the last 385 /* Return: backtrack through the last
379 * big jump. 386 * big jump.
380 */ 387 */
@@ -404,6 +411,14 @@ static int mark_source_chains(struct xt_table_info *newinfo,
404 if (strcmp(t->target.u.user.name, 411 if (strcmp(t->target.u.user.name,
405 ARPT_STANDARD_TARGET) == 0 412 ARPT_STANDARD_TARGET) == 0
406 && newpos >= 0) { 413 && newpos >= 0) {
414 if (newpos > newinfo->size -
415 sizeof(struct arpt_entry)) {
416 duprintf("mark_source_chains: "
417 "bad verdict (%i)\n",
418 newpos);
419 return 0;
420 }
421
407 /* This a jump; chase it. */ 422 /* This a jump; chase it. */
408 duprintf("Jump rule %u -> %u\n", 423 duprintf("Jump rule %u -> %u\n",
409 pos, newpos); 424 pos, newpos);
@@ -426,8 +441,6 @@ static int mark_source_chains(struct xt_table_info *newinfo,
426static inline int standard_check(const struct arpt_entry_target *t, 441static inline int standard_check(const struct arpt_entry_target *t,
427 unsigned int max_offset) 442 unsigned int max_offset)
428{ 443{
429 struct arpt_standard_target *targ = (void *)t;
430
431 /* Check standard info. */ 444 /* Check standard info. */
432 if (t->u.target_size 445 if (t->u.target_size
433 != ARPT_ALIGN(sizeof(struct arpt_standard_target))) { 446 != ARPT_ALIGN(sizeof(struct arpt_standard_target))) {
@@ -437,18 +450,6 @@ static inline int standard_check(const struct arpt_entry_target *t,
437 return 0; 450 return 0;
438 } 451 }
439 452
440 if (targ->verdict >= 0
441 && targ->verdict > max_offset - sizeof(struct arpt_entry)) {
442 duprintf("arpt_standard_check: bad verdict (%i)\n",
443 targ->verdict);
444 return 0;
445 }
446
447 if (targ->verdict < -NF_MAX_VERDICT - 1) {
448 duprintf("arpt_standard_check: bad negative verdict (%i)\n",
449 targ->verdict);
450 return 0;
451 }
452 return 1; 453 return 1;
453} 454}
454 455
@@ -627,18 +628,20 @@ static int translate_table(const char *name,
627 } 628 }
628 } 629 }
629 630
631 if (!mark_source_chains(newinfo, valid_hooks, entry0)) {
632 duprintf("Looping hook\n");
633 return -ELOOP;
634 }
635
630 /* Finally, each sanity check must pass */ 636 /* Finally, each sanity check must pass */
631 i = 0; 637 i = 0;
632 ret = ARPT_ENTRY_ITERATE(entry0, newinfo->size, 638 ret = ARPT_ENTRY_ITERATE(entry0, newinfo->size,
633 check_entry, name, size, &i); 639 check_entry, name, size, &i);
634 640
635 if (ret != 0) 641 if (ret != 0) {
636 goto cleanup; 642 ARPT_ENTRY_ITERATE(entry0, newinfo->size,
637 643 cleanup_entry, &i);
638 ret = -ELOOP; 644 return ret;
639 if (!mark_source_chains(newinfo, valid_hooks, entry0)) {
640 duprintf("Looping hook\n");
641 goto cleanup;
642 } 645 }
643 646
644 /* And one copy for every other CPU */ 647 /* And one copy for every other CPU */
@@ -647,9 +650,6 @@ static int translate_table(const char *name,
647 memcpy(newinfo->entries[i], entry0, newinfo->size); 650 memcpy(newinfo->entries[i], entry0, newinfo->size);
648 } 651 }
649 652
650 return 0;
651cleanup:
652 ARPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
653 return ret; 653 return ret;
654} 654}
655 655
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index f4b0e68a16d2..8556a4f4f60a 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -65,8 +65,8 @@ static LIST_HEAD(helpers);
65unsigned int ip_conntrack_htable_size __read_mostly = 0; 65unsigned int ip_conntrack_htable_size __read_mostly = 0;
66int ip_conntrack_max __read_mostly; 66int ip_conntrack_max __read_mostly;
67struct list_head *ip_conntrack_hash __read_mostly; 67struct list_head *ip_conntrack_hash __read_mostly;
68static kmem_cache_t *ip_conntrack_cachep __read_mostly; 68static struct kmem_cache *ip_conntrack_cachep __read_mostly;
69static kmem_cache_t *ip_conntrack_expect_cachep __read_mostly; 69static struct kmem_cache *ip_conntrack_expect_cachep __read_mostly;
70struct ip_conntrack ip_conntrack_untracked; 70struct ip_conntrack ip_conntrack_untracked;
71unsigned int ip_ct_log_invalid __read_mostly; 71unsigned int ip_ct_log_invalid __read_mostly;
72static LIST_HEAD(unconfirmed); 72static LIST_HEAD(unconfirmed);
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 8a455439b128..0ff2956d35e5 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -401,6 +401,13 @@ mark_source_chains(struct xt_table_info *newinfo,
401 && unconditional(&e->ip)) { 401 && unconditional(&e->ip)) {
402 unsigned int oldpos, size; 402 unsigned int oldpos, size;
403 403
404 if (t->verdict < -NF_MAX_VERDICT - 1) {
405 duprintf("mark_source_chains: bad "
406 "negative verdict (%i)\n",
407 t->verdict);
408 return 0;
409 }
410
404 /* Return: backtrack through the last 411 /* Return: backtrack through the last
405 big jump. */ 412 big jump. */
406 do { 413 do {
@@ -438,6 +445,13 @@ mark_source_chains(struct xt_table_info *newinfo,
438 if (strcmp(t->target.u.user.name, 445 if (strcmp(t->target.u.user.name,
439 IPT_STANDARD_TARGET) == 0 446 IPT_STANDARD_TARGET) == 0
440 && newpos >= 0) { 447 && newpos >= 0) {
448 if (newpos > newinfo->size -
449 sizeof(struct ipt_entry)) {
450 duprintf("mark_source_chains: "
451 "bad verdict (%i)\n",
452 newpos);
453 return 0;
454 }
441 /* This a jump; chase it. */ 455 /* This a jump; chase it. */
442 duprintf("Jump rule %u -> %u\n", 456 duprintf("Jump rule %u -> %u\n",
443 pos, newpos); 457 pos, newpos);
@@ -470,27 +484,6 @@ cleanup_match(struct ipt_entry_match *m, unsigned int *i)
470} 484}
471 485
472static inline int 486static inline int
473standard_check(const struct ipt_entry_target *t,
474 unsigned int max_offset)
475{
476 struct ipt_standard_target *targ = (void *)t;
477
478 /* Check standard info. */
479 if (targ->verdict >= 0
480 && targ->verdict > max_offset - sizeof(struct ipt_entry)) {
481 duprintf("ipt_standard_check: bad verdict (%i)\n",
482 targ->verdict);
483 return 0;
484 }
485 if (targ->verdict < -NF_MAX_VERDICT - 1) {
486 duprintf("ipt_standard_check: bad negative verdict (%i)\n",
487 targ->verdict);
488 return 0;
489 }
490 return 1;
491}
492
493static inline int
494check_match(struct ipt_entry_match *m, 487check_match(struct ipt_entry_match *m,
495 const char *name, 488 const char *name,
496 const struct ipt_ip *ip, 489 const struct ipt_ip *ip,
@@ -576,12 +569,7 @@ check_entry(struct ipt_entry *e, const char *name, unsigned int size,
576 if (ret) 569 if (ret)
577 goto err; 570 goto err;
578 571
579 if (t->u.kernel.target == &ipt_standard_target) { 572 if (t->u.kernel.target->checkentry
580 if (!standard_check(t, size)) {
581 ret = -EINVAL;
582 goto err;
583 }
584 } else if (t->u.kernel.target->checkentry
585 && !t->u.kernel.target->checkentry(name, e, target, t->data, 573 && !t->u.kernel.target->checkentry(name, e, target, t->data,
586 e->comefrom)) { 574 e->comefrom)) {
587 duprintf("ip_tables: check failed for `%s'.\n", 575 duprintf("ip_tables: check failed for `%s'.\n",
@@ -718,17 +706,19 @@ translate_table(const char *name,
718 } 706 }
719 } 707 }
720 708
709 if (!mark_source_chains(newinfo, valid_hooks, entry0))
710 return -ELOOP;
711
721 /* Finally, each sanity check must pass */ 712 /* Finally, each sanity check must pass */
722 i = 0; 713 i = 0;
723 ret = IPT_ENTRY_ITERATE(entry0, newinfo->size, 714 ret = IPT_ENTRY_ITERATE(entry0, newinfo->size,
724 check_entry, name, size, &i); 715 check_entry, name, size, &i);
725 716
726 if (ret != 0) 717 if (ret != 0) {
727 goto cleanup; 718 IPT_ENTRY_ITERATE(entry0, newinfo->size,
728 719 cleanup_entry, &i);
729 ret = -ELOOP; 720 return ret;
730 if (!mark_source_chains(newinfo, valid_hooks, entry0)) 721 }
731 goto cleanup;
732 722
733 /* And one copy for every other CPU */ 723 /* And one copy for every other CPU */
734 for_each_possible_cpu(i) { 724 for_each_possible_cpu(i) {
@@ -736,9 +726,6 @@ translate_table(const char *name,
736 memcpy(newinfo->entries[i], entry0, newinfo->size); 726 memcpy(newinfo->entries[i], entry0, newinfo->size);
737 } 727 }
738 728
739 return 0;
740cleanup:
741 IPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
742 return ret; 729 return ret;
743} 730}
744 731
@@ -1529,25 +1516,8 @@ static inline int compat_copy_match_from_user(struct ipt_entry_match *m,
1529 void **dstptr, compat_uint_t *size, const char *name, 1516 void **dstptr, compat_uint_t *size, const char *name,
1530 const struct ipt_ip *ip, unsigned int hookmask) 1517 const struct ipt_ip *ip, unsigned int hookmask)
1531{ 1518{
1532 struct ipt_entry_match *dm;
1533 struct ipt_match *match;
1534 int ret;
1535
1536 dm = (struct ipt_entry_match *)*dstptr;
1537 match = m->u.kernel.match;
1538 xt_compat_match_from_user(m, dstptr, size); 1519 xt_compat_match_from_user(m, dstptr, size);
1539 1520 return 0;
1540 ret = xt_check_match(match, AF_INET, dm->u.match_size - sizeof(*dm),
1541 name, hookmask, ip->proto,
1542 ip->invflags & IPT_INV_PROTO);
1543 if (!ret && m->u.kernel.match->checkentry
1544 && !m->u.kernel.match->checkentry(name, ip, match, dm->data,
1545 hookmask)) {
1546 duprintf("ip_tables: check failed for `%s'.\n",
1547 m->u.kernel.match->name);
1548 ret = -EINVAL;
1549 }
1550 return ret;
1551} 1521}
1552 1522
1553static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr, 1523static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
@@ -1569,7 +1539,7 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
1569 ret = IPT_MATCH_ITERATE(e, compat_copy_match_from_user, dstptr, size, 1539 ret = IPT_MATCH_ITERATE(e, compat_copy_match_from_user, dstptr, size,
1570 name, &de->ip, de->comefrom); 1540 name, &de->ip, de->comefrom);
1571 if (ret) 1541 if (ret)
1572 goto err; 1542 return ret;
1573 de->target_offset = e->target_offset - (origsize - *size); 1543 de->target_offset = e->target_offset - (origsize - *size);
1574 t = ipt_get_target(e); 1544 t = ipt_get_target(e);
1575 target = t->u.kernel.target; 1545 target = t->u.kernel.target;
@@ -1582,31 +1552,62 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
1582 if ((unsigned char *)de - base < newinfo->underflow[h]) 1552 if ((unsigned char *)de - base < newinfo->underflow[h])
1583 newinfo->underflow[h] -= origsize - *size; 1553 newinfo->underflow[h] -= origsize - *size;
1584 } 1554 }
1555 return ret;
1556}
1557
1558static inline int compat_check_match(struct ipt_entry_match *m, const char *name,
1559 const struct ipt_ip *ip, unsigned int hookmask)
1560{
1561 struct ipt_match *match;
1562 int ret;
1563
1564 match = m->u.kernel.match;
1565 ret = xt_check_match(match, AF_INET, m->u.match_size - sizeof(*m),
1566 name, hookmask, ip->proto,
1567 ip->invflags & IPT_INV_PROTO);
1568 if (!ret && m->u.kernel.match->checkentry
1569 && !m->u.kernel.match->checkentry(name, ip, match, m->data,
1570 hookmask)) {
1571 duprintf("ip_tables: compat: check failed for `%s'.\n",
1572 m->u.kernel.match->name);
1573 ret = -EINVAL;
1574 }
1575 return ret;
1576}
1577
1578static inline int compat_check_target(struct ipt_entry *e, const char *name)
1579{
1580 struct ipt_entry_target *t;
1581 struct ipt_target *target;
1582 int ret;
1585 1583
1586 t = ipt_get_target(de); 1584 t = ipt_get_target(e);
1587 target = t->u.kernel.target; 1585 target = t->u.kernel.target;
1588 ret = xt_check_target(target, AF_INET, t->u.target_size - sizeof(*t), 1586 ret = xt_check_target(target, AF_INET, t->u.target_size - sizeof(*t),
1589 name, e->comefrom, e->ip.proto, 1587 name, e->comefrom, e->ip.proto,
1590 e->ip.invflags & IPT_INV_PROTO); 1588 e->ip.invflags & IPT_INV_PROTO);
1591 if (ret) 1589 if (!ret && t->u.kernel.target->checkentry
1592 goto err; 1590 && !t->u.kernel.target->checkentry(name, e, target,
1593 1591 t->data, e->comefrom)) {
1594 ret = -EINVAL;
1595 if (t->u.kernel.target == &ipt_standard_target) {
1596 if (!standard_check(t, *size))
1597 goto err;
1598 } else if (t->u.kernel.target->checkentry
1599 && !t->u.kernel.target->checkentry(name, de, target,
1600 t->data, de->comefrom)) {
1601 duprintf("ip_tables: compat: check failed for `%s'.\n", 1592 duprintf("ip_tables: compat: check failed for `%s'.\n",
1602 t->u.kernel.target->name); 1593 t->u.kernel.target->name);
1603 goto err; 1594 ret = -EINVAL;
1604 } 1595 }
1605 ret = 0;
1606err:
1607 return ret; 1596 return ret;
1608} 1597}
1609 1598
1599static inline int compat_check_entry(struct ipt_entry *e, const char *name)
1600{
1601 int ret;
1602
1603 ret = IPT_MATCH_ITERATE(e, compat_check_match, name, &e->ip,
1604 e->comefrom);
1605 if (ret)
1606 return ret;
1607
1608 return compat_check_target(e, name);
1609}
1610
1610static int 1611static int
1611translate_compat_table(const char *name, 1612translate_compat_table(const char *name,
1612 unsigned int valid_hooks, 1613 unsigned int valid_hooks,
@@ -1695,6 +1696,11 @@ translate_compat_table(const char *name,
1695 if (!mark_source_chains(newinfo, valid_hooks, entry1)) 1696 if (!mark_source_chains(newinfo, valid_hooks, entry1))
1696 goto free_newinfo; 1697 goto free_newinfo;
1697 1698
1699 ret = IPT_ENTRY_ITERATE(entry1, newinfo->size, compat_check_entry,
1700 name);
1701 if (ret)
1702 goto free_newinfo;
1703
1698 /* And one copy for every other CPU */ 1704 /* And one copy for every other CPU */
1699 for_each_possible_cpu(i) 1705 for_each_possible_cpu(i)
1700 if (newinfo->entries[i] && newinfo->entries[i] != entry1) 1706 if (newinfo->entries[i] && newinfo->entries[i] != entry1)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9f3924c4905e..11c167118e87 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1780,7 +1780,7 @@ static inline int __mkroute_input(struct sk_buff *skb,
1780#endif 1780#endif
1781 if (in_dev->cnf.no_policy) 1781 if (in_dev->cnf.no_policy)
1782 rth->u.dst.flags |= DST_NOPOLICY; 1782 rth->u.dst.flags |= DST_NOPOLICY;
1783 if (in_dev->cnf.no_xfrm) 1783 if (out_dev->cnf.no_xfrm)
1784 rth->u.dst.flags |= DST_NOXFRM; 1784 rth->u.dst.flags |= DST_NOXFRM;
1785 rth->fl.fl4_dst = daddr; 1785 rth->fl.fl4_dst = daddr;
1786 rth->rt_dst = daddr; 1786 rth->rt_dst = daddr;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 9304034c0c47..c701f6abbfc1 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4235,7 +4235,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,
4235 * Change state from SYN-SENT only after copied_seq 4235 * Change state from SYN-SENT only after copied_seq
4236 * is initialized. */ 4236 * is initialized. */
4237 tp->copied_seq = tp->rcv_nxt; 4237 tp->copied_seq = tp->rcv_nxt;
4238 mb(); 4238 smp_mb();
4239 tcp_set_state(sk, TCP_ESTABLISHED); 4239 tcp_set_state(sk, TCP_ESTABLISHED);
4240 4240
4241 security_inet_conn_established(sk, skb); 4241 security_inet_conn_established(sk, skb);
@@ -4483,7 +4483,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
4483 case TCP_SYN_RECV: 4483 case TCP_SYN_RECV:
4484 if (acceptable) { 4484 if (acceptable) {
4485 tp->copied_seq = tp->rcv_nxt; 4485 tp->copied_seq = tp->rcv_nxt;
4486 mb(); 4486 smp_mb();
4487 tcp_set_state(sk, TCP_ESTABLISHED); 4487 tcp_set_state(sk, TCP_ESTABLISHED);
4488 sk->sk_state_change(sk); 4488 sk->sk_state_change(sk);
4489 4489
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index d4107bb701b5..fb9f69c616f5 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -274,6 +274,8 @@ static void xfrm4_dst_destroy(struct dst_entry *dst)
274 274
275 if (likely(xdst->u.rt.idev)) 275 if (likely(xdst->u.rt.idev))
276 in_dev_put(xdst->u.rt.idev); 276 in_dev_put(xdst->u.rt.idev);
277 if (likely(xdst->u.rt.peer))
278 inet_putpeer(xdst->u.rt.peer);
277 xfrm_dst_destroy(xdst); 279 xfrm_dst_destroy(xdst);
278} 280}
279 281
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 87c8f54872b7..e5cd83b2205d 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -720,10 +720,8 @@ snmp6_mib_free(void *ptr[2])
720{ 720{
721 if (ptr == NULL) 721 if (ptr == NULL)
722 return; 722 return;
723 if (ptr[0]) 723 free_percpu(ptr[0]);
724 free_percpu(ptr[0]); 724 free_percpu(ptr[1]);
725 if (ptr[1])
726 free_percpu(ptr[1]);
727 ptr[0] = ptr[1] = NULL; 725 ptr[0] = ptr[1] = NULL;
728} 726}
729 727
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index bf526115e518..96d8310ae9c8 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -50,7 +50,7 @@
50 50
51struct rt6_statistics rt6_stats; 51struct rt6_statistics rt6_stats;
52 52
53static kmem_cache_t * fib6_node_kmem __read_mostly; 53static struct kmem_cache * fib6_node_kmem __read_mostly;
54 54
55enum fib_walk_state_t 55enum fib_walk_state_t
56{ 56{
@@ -150,7 +150,7 @@ static __inline__ struct fib6_node * node_alloc(void)
150{ 150{
151 struct fib6_node *fn; 151 struct fib6_node *fn;
152 152
153 if ((fn = kmem_cache_alloc(fib6_node_kmem, SLAB_ATOMIC)) != NULL) 153 if ((fn = kmem_cache_alloc(fib6_node_kmem, GFP_ATOMIC)) != NULL)
154 memset(fn, 0, sizeof(struct fib6_node)); 154 memset(fn, 0, sizeof(struct fib6_node));
155 155
156 return fn; 156 return fn;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index e05ecbb1412d..e9212c7ff5cf 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -624,13 +624,13 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
624 skb_shinfo(skb)->frag_list = NULL; 624 skb_shinfo(skb)->frag_list = NULL;
625 /* BUILD HEADER */ 625 /* BUILD HEADER */
626 626
627 *prevhdr = NEXTHDR_FRAGMENT;
627 tmp_hdr = kmemdup(skb->nh.raw, hlen, GFP_ATOMIC); 628 tmp_hdr = kmemdup(skb->nh.raw, hlen, GFP_ATOMIC);
628 if (!tmp_hdr) { 629 if (!tmp_hdr) {
629 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS); 630 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS);
630 return -ENOMEM; 631 return -ENOMEM;
631 } 632 }
632 633
633 *prevhdr = NEXTHDR_FRAGMENT;
634 __skb_pull(skb, hlen); 634 __skb_pull(skb, hlen);
635 fh = (struct frag_hdr*)__skb_push(skb, sizeof(struct frag_hdr)); 635 fh = (struct frag_hdr*)__skb_push(skb, sizeof(struct frag_hdr));
636 skb->nh.raw = __skb_push(skb, hlen); 636 skb->nh.raw = __skb_push(skb, hlen);
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index f63fb86d7c7b..4eec4b3988b8 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -440,6 +440,13 @@ mark_source_chains(struct xt_table_info *newinfo,
440 && unconditional(&e->ipv6)) { 440 && unconditional(&e->ipv6)) {
441 unsigned int oldpos, size; 441 unsigned int oldpos, size;
442 442
443 if (t->verdict < -NF_MAX_VERDICT - 1) {
444 duprintf("mark_source_chains: bad "
445 "negative verdict (%i)\n",
446 t->verdict);
447 return 0;
448 }
449
443 /* Return: backtrack through the last 450 /* Return: backtrack through the last
444 big jump. */ 451 big jump. */
445 do { 452 do {
@@ -477,6 +484,13 @@ mark_source_chains(struct xt_table_info *newinfo,
477 if (strcmp(t->target.u.user.name, 484 if (strcmp(t->target.u.user.name,
478 IP6T_STANDARD_TARGET) == 0 485 IP6T_STANDARD_TARGET) == 0
479 && newpos >= 0) { 486 && newpos >= 0) {
487 if (newpos > newinfo->size -
488 sizeof(struct ip6t_entry)) {
489 duprintf("mark_source_chains: "
490 "bad verdict (%i)\n",
491 newpos);
492 return 0;
493 }
480 /* This a jump; chase it. */ 494 /* This a jump; chase it. */
481 duprintf("Jump rule %u -> %u\n", 495 duprintf("Jump rule %u -> %u\n",
482 pos, newpos); 496 pos, newpos);
@@ -509,27 +523,6 @@ cleanup_match(struct ip6t_entry_match *m, unsigned int *i)
509} 523}
510 524
511static inline int 525static inline int
512standard_check(const struct ip6t_entry_target *t,
513 unsigned int max_offset)
514{
515 struct ip6t_standard_target *targ = (void *)t;
516
517 /* Check standard info. */
518 if (targ->verdict >= 0
519 && targ->verdict > max_offset - sizeof(struct ip6t_entry)) {
520 duprintf("ip6t_standard_check: bad verdict (%i)\n",
521 targ->verdict);
522 return 0;
523 }
524 if (targ->verdict < -NF_MAX_VERDICT - 1) {
525 duprintf("ip6t_standard_check: bad negative verdict (%i)\n",
526 targ->verdict);
527 return 0;
528 }
529 return 1;
530}
531
532static inline int
533check_match(struct ip6t_entry_match *m, 526check_match(struct ip6t_entry_match *m,
534 const char *name, 527 const char *name,
535 const struct ip6t_ip6 *ipv6, 528 const struct ip6t_ip6 *ipv6,
@@ -616,12 +609,7 @@ check_entry(struct ip6t_entry *e, const char *name, unsigned int size,
616 if (ret) 609 if (ret)
617 goto err; 610 goto err;
618 611
619 if (t->u.kernel.target == &ip6t_standard_target) { 612 if (t->u.kernel.target->checkentry
620 if (!standard_check(t, size)) {
621 ret = -EINVAL;
622 goto err;
623 }
624 } else if (t->u.kernel.target->checkentry
625 && !t->u.kernel.target->checkentry(name, e, target, t->data, 613 && !t->u.kernel.target->checkentry(name, e, target, t->data,
626 e->comefrom)) { 614 e->comefrom)) {
627 duprintf("ip_tables: check failed for `%s'.\n", 615 duprintf("ip_tables: check failed for `%s'.\n",
@@ -758,17 +746,19 @@ translate_table(const char *name,
758 } 746 }
759 } 747 }
760 748
749 if (!mark_source_chains(newinfo, valid_hooks, entry0))
750 return -ELOOP;
751
761 /* Finally, each sanity check must pass */ 752 /* Finally, each sanity check must pass */
762 i = 0; 753 i = 0;
763 ret = IP6T_ENTRY_ITERATE(entry0, newinfo->size, 754 ret = IP6T_ENTRY_ITERATE(entry0, newinfo->size,
764 check_entry, name, size, &i); 755 check_entry, name, size, &i);
765 756
766 if (ret != 0) 757 if (ret != 0) {
767 goto cleanup; 758 IP6T_ENTRY_ITERATE(entry0, newinfo->size,
768 759 cleanup_entry, &i);
769 ret = -ELOOP; 760 return ret;
770 if (!mark_source_chains(newinfo, valid_hooks, entry0)) 761 }
771 goto cleanup;
772 762
773 /* And one copy for every other CPU */ 763 /* And one copy for every other CPU */
774 for_each_possible_cpu(i) { 764 for_each_possible_cpu(i) {
@@ -777,9 +767,6 @@ translate_table(const char *name,
777 } 767 }
778 768
779 return 0; 769 return 0;
780cleanup:
781 IP6T_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
782 return ret;
783} 770}
784 771
785/* Gets counters. */ 772/* Gets counters. */
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index c2e629d6aea4..4ae1b19ada5d 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -854,7 +854,8 @@ back_from_confirm:
854 } 854 }
855done: 855done:
856 dst_release(dst); 856 dst_release(dst);
857 release_sock(sk); 857 if (!inet->hdrincl)
858 release_sock(sk);
858out: 859out:
859 fl6_sock_release(flowlabel); 860 fl6_sock_release(flowlabel);
860 return err<0?err:len; 861 return err<0?err:len;
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 01a5c52a2be3..12e426b9aacd 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -50,7 +50,7 @@ static u32 xfrm6_tunnel_spi;
50#define XFRM6_TUNNEL_SPI_MIN 1 50#define XFRM6_TUNNEL_SPI_MIN 1
51#define XFRM6_TUNNEL_SPI_MAX 0xffffffff 51#define XFRM6_TUNNEL_SPI_MAX 0xffffffff
52 52
53static kmem_cache_t *xfrm6_tunnel_spi_kmem __read_mostly; 53static struct kmem_cache *xfrm6_tunnel_spi_kmem __read_mostly;
54 54
55#define XFRM6_TUNNEL_SPI_BYADDR_HSIZE 256 55#define XFRM6_TUNNEL_SPI_BYADDR_HSIZE 256
56#define XFRM6_TUNNEL_SPI_BYSPI_HSIZE 256 56#define XFRM6_TUNNEL_SPI_BYSPI_HSIZE 256
@@ -180,7 +180,7 @@ try_next_2:;
180 spi = 0; 180 spi = 0;
181 goto out; 181 goto out;
182alloc_spi: 182alloc_spi:
183 x6spi = kmem_cache_alloc(xfrm6_tunnel_spi_kmem, SLAB_ATOMIC); 183 x6spi = kmem_cache_alloc(xfrm6_tunnel_spi_kmem, GFP_ATOMIC);
184 if (!x6spi) 184 if (!x6spi)
185 goto out; 185 goto out;
186 186
diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index 252f11012566..03504f3e4990 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -1100,7 +1100,7 @@ int irttp_connect_request(struct tsap_cb *self, __u8 dtsap_sel,
1100 return -ENOMEM; 1100 return -ENOMEM;
1101 1101
1102 /* Reserve space for MUX_CONTROL and LAP header */ 1102 /* Reserve space for MUX_CONTROL and LAP header */
1103 skb_reserve(tx_skb, TTP_MAX_HEADER); 1103 skb_reserve(tx_skb, TTP_MAX_HEADER + TTP_SAR_HEADER);
1104 } else { 1104 } else {
1105 tx_skb = userdata; 1105 tx_skb = userdata;
1106 /* 1106 /*
@@ -1349,7 +1349,7 @@ int irttp_connect_response(struct tsap_cb *self, __u32 max_sdu_size,
1349 return -ENOMEM; 1349 return -ENOMEM;
1350 1350
1351 /* Reserve space for MUX_CONTROL and LAP header */ 1351 /* Reserve space for MUX_CONTROL and LAP header */
1352 skb_reserve(tx_skb, TTP_MAX_HEADER); 1352 skb_reserve(tx_skb, TTP_MAX_HEADER + TTP_SAR_HEADER);
1353 } else { 1353 } else {
1354 tx_skb = userdata; 1354 tx_skb = userdata;
1355 /* 1355 /*
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 0e1dbfbb9b10..5dd5094659a1 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -27,6 +27,7 @@
27#include <linux/proc_fs.h> 27#include <linux/proc_fs.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <net/xfrm.h> 29#include <net/xfrm.h>
30#include <linux/audit.h>
30 31
31#include <net/sock.h> 32#include <net/sock.h>
32 33
@@ -1420,6 +1421,9 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
1420 else 1421 else
1421 err = xfrm_state_update(x); 1422 err = xfrm_state_update(x);
1422 1423
1424 xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
1425 AUDIT_MAC_IPSEC_ADDSA, err ? 0 : 1, NULL, x);
1426
1423 if (err < 0) { 1427 if (err < 0) {
1424 x->km.state = XFRM_STATE_DEAD; 1428 x->km.state = XFRM_STATE_DEAD;
1425 __xfrm_state_put(x); 1429 __xfrm_state_put(x);
@@ -1460,8 +1464,12 @@ static int pfkey_delete(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
1460 err = -EPERM; 1464 err = -EPERM;
1461 goto out; 1465 goto out;
1462 } 1466 }
1463 1467
1464 err = xfrm_state_delete(x); 1468 err = xfrm_state_delete(x);
1469
1470 xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
1471 AUDIT_MAC_IPSEC_DELSA, err ? 0 : 1, NULL, x);
1472
1465 if (err < 0) 1473 if (err < 0)
1466 goto out; 1474 goto out;
1467 1475
@@ -1637,12 +1645,15 @@ static int pfkey_flush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hd
1637{ 1645{
1638 unsigned proto; 1646 unsigned proto;
1639 struct km_event c; 1647 struct km_event c;
1648 struct xfrm_audit audit_info;
1640 1649
1641 proto = pfkey_satype2proto(hdr->sadb_msg_satype); 1650 proto = pfkey_satype2proto(hdr->sadb_msg_satype);
1642 if (proto == 0) 1651 if (proto == 0)
1643 return -EINVAL; 1652 return -EINVAL;
1644 1653
1645 xfrm_state_flush(proto); 1654 audit_info.loginuid = audit_get_loginuid(current->audit_context);
1655 audit_info.secid = 0;
1656 xfrm_state_flush(proto, &audit_info);
1646 c.data.proto = proto; 1657 c.data.proto = proto;
1647 c.seq = hdr->sadb_msg_seq; 1658 c.seq = hdr->sadb_msg_seq;
1648 c.pid = hdr->sadb_msg_pid; 1659 c.pid = hdr->sadb_msg_pid;
@@ -2205,6 +2216,9 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
2205 err = xfrm_policy_insert(pol->sadb_x_policy_dir-1, xp, 2216 err = xfrm_policy_insert(pol->sadb_x_policy_dir-1, xp,
2206 hdr->sadb_msg_type != SADB_X_SPDUPDATE); 2217 hdr->sadb_msg_type != SADB_X_SPDUPDATE);
2207 2218
2219 xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
2220 AUDIT_MAC_IPSEC_ADDSPD, err ? 0 : 1, xp, NULL);
2221
2208 if (err) 2222 if (err)
2209 goto out; 2223 goto out;
2210 2224
@@ -2282,6 +2296,10 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg
2282 xp = xfrm_policy_bysel_ctx(XFRM_POLICY_TYPE_MAIN, pol->sadb_x_policy_dir-1, 2296 xp = xfrm_policy_bysel_ctx(XFRM_POLICY_TYPE_MAIN, pol->sadb_x_policy_dir-1,
2283 &sel, tmp.security, 1); 2297 &sel, tmp.security, 1);
2284 security_xfrm_policy_free(&tmp); 2298 security_xfrm_policy_free(&tmp);
2299
2300 xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
2301 AUDIT_MAC_IPSEC_DELSPD, (xp) ? 1 : 0, xp, NULL);
2302
2285 if (xp == NULL) 2303 if (xp == NULL)
2286 return -ENOENT; 2304 return -ENOENT;
2287 2305
@@ -2416,8 +2434,11 @@ static int key_notify_policy_flush(struct km_event *c)
2416static int pfkey_spdflush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs) 2434static int pfkey_spdflush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs)
2417{ 2435{
2418 struct km_event c; 2436 struct km_event c;
2437 struct xfrm_audit audit_info;
2419 2438
2420 xfrm_policy_flush(XFRM_POLICY_TYPE_MAIN); 2439 audit_info.loginuid = audit_get_loginuid(current->audit_context);
2440 audit_info.secid = 0;
2441 xfrm_policy_flush(XFRM_POLICY_TYPE_MAIN, &audit_info);
2421 c.data.type = XFRM_POLICY_TYPE_MAIN; 2442 c.data.type = XFRM_POLICY_TYPE_MAIN;
2422 c.event = XFRM_MSG_FLUSHPOLICY; 2443 c.event = XFRM_MSG_FLUSHPOLICY;
2423 c.pid = hdr->sadb_msg_pid; 2444 c.pid = hdr->sadb_msg_pid;
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index eaa0f8a1adb6..9b02ec4012fb 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -108,7 +108,7 @@ static struct {
108 size_t size; 108 size_t size;
109 109
110 /* slab cache pointer */ 110 /* slab cache pointer */
111 kmem_cache_t *cachep; 111 struct kmem_cache *cachep;
112 112
113 /* allocated slab cache + modules which uses this slab cache */ 113 /* allocated slab cache + modules which uses this slab cache */
114 int use; 114 int use;
@@ -147,7 +147,7 @@ int nf_conntrack_register_cache(u_int32_t features, const char *name,
147{ 147{
148 int ret = 0; 148 int ret = 0;
149 char *cache_name; 149 char *cache_name;
150 kmem_cache_t *cachep; 150 struct kmem_cache *cachep;
151 151
152 DEBUGP("nf_conntrack_register_cache: features=0x%x, name=%s, size=%d\n", 152 DEBUGP("nf_conntrack_register_cache: features=0x%x, name=%s, size=%d\n",
153 features, name, size); 153 features, name, size);
@@ -226,7 +226,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_register_cache);
226/* FIXME: In the current, only nf_conntrack_cleanup() can call this function. */ 226/* FIXME: In the current, only nf_conntrack_cleanup() can call this function. */
227void nf_conntrack_unregister_cache(u_int32_t features) 227void nf_conntrack_unregister_cache(u_int32_t features)
228{ 228{
229 kmem_cache_t *cachep; 229 struct kmem_cache *cachep;
230 char *name; 230 char *name;
231 231
232 /* 232 /*
@@ -1093,7 +1093,7 @@ static void free_conntrack_hash(struct list_head *hash, int vmalloced, int size)
1093 get_order(sizeof(struct list_head) * size)); 1093 get_order(sizeof(struct list_head) * size));
1094} 1094}
1095 1095
1096void nf_conntrack_flush() 1096void nf_conntrack_flush(void)
1097{ 1097{
1098 nf_ct_iterate_cleanup(kill_all, NULL); 1098 nf_ct_iterate_cleanup(kill_all, NULL);
1099} 1099}
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index 588d37937046..9cbf926cdd14 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -29,7 +29,7 @@
29LIST_HEAD(nf_conntrack_expect_list); 29LIST_HEAD(nf_conntrack_expect_list);
30EXPORT_SYMBOL_GPL(nf_conntrack_expect_list); 30EXPORT_SYMBOL_GPL(nf_conntrack_expect_list);
31 31
32kmem_cache_t *nf_conntrack_expect_cachep __read_mostly; 32struct kmem_cache *nf_conntrack_expect_cachep __read_mostly;
33static unsigned int nf_conntrack_expect_next_id; 33static unsigned int nf_conntrack_expect_next_id;
34 34
35/* nf_conntrack_expect helper functions */ 35/* nf_conntrack_expect helper functions */
@@ -91,25 +91,28 @@ EXPORT_SYMBOL_GPL(nf_conntrack_expect_find_get);
91struct nf_conntrack_expect * 91struct nf_conntrack_expect *
92find_expectation(const struct nf_conntrack_tuple *tuple) 92find_expectation(const struct nf_conntrack_tuple *tuple)
93{ 93{
94 struct nf_conntrack_expect *i; 94 struct nf_conntrack_expect *exp;
95
96 exp = __nf_conntrack_expect_find(tuple);
97 if (!exp)
98 return NULL;
95 99
96 list_for_each_entry(i, &nf_conntrack_expect_list, list) {
97 /* If master is not in hash table yet (ie. packet hasn't left 100 /* If master is not in hash table yet (ie. packet hasn't left
98 this machine yet), how can other end know about expected? 101 this machine yet), how can other end know about expected?
99 Hence these are not the droids you are looking for (if 102 Hence these are not the droids you are looking for (if
100 master ct never got confirmed, we'd hold a reference to it 103 master ct never got confirmed, we'd hold a reference to it
101 and weird things would happen to future packets). */ 104 and weird things would happen to future packets). */
102 if (nf_ct_tuple_mask_cmp(tuple, &i->tuple, &i->mask) 105 if (!nf_ct_is_confirmed(exp->master))
103 && nf_ct_is_confirmed(i->master)) { 106 return NULL;
104 if (i->flags & NF_CT_EXPECT_PERMANENT) { 107
105 atomic_inc(&i->use); 108 if (exp->flags & NF_CT_EXPECT_PERMANENT) {
106 return i; 109 atomic_inc(&exp->use);
107 } else if (del_timer(&i->timeout)) { 110 return exp;
108 nf_ct_unlink_expect(i); 111 } else if (del_timer(&exp->timeout)) {
109 return i; 112 nf_ct_unlink_expect(exp);
110 } 113 return exp;
111 }
112 } 114 }
115
113 return NULL; 116 return NULL;
114} 117}
115 118
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index a98de0b54d65..a5a6e192ac2d 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -92,7 +92,7 @@ struct xt_hashlimit_htable {
92static DEFINE_SPINLOCK(hashlimit_lock); /* protects htables list */ 92static DEFINE_SPINLOCK(hashlimit_lock); /* protects htables list */
93static DEFINE_MUTEX(hlimit_mutex); /* additional checkentry protection */ 93static DEFINE_MUTEX(hlimit_mutex); /* additional checkentry protection */
94static HLIST_HEAD(hashlimit_htables); 94static HLIST_HEAD(hashlimit_htables);
95static kmem_cache_t *hashlimit_cachep __read_mostly; 95static struct kmem_cache *hashlimit_cachep __read_mostly;
96 96
97static inline int dst_cmp(const struct dsthash_ent *ent, struct dsthash_dst *b) 97static inline int dst_cmp(const struct dsthash_ent *ent, struct dsthash_dst *b)
98{ 98{
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index b9b03747c1f3..548e4e6e698f 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -143,6 +143,13 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
143 goto errout; 143 goto errout;
144 } 144 }
145 145
146 if (ops->dumpit)
147 ops->flags |= GENL_CMD_CAP_DUMP;
148 if (ops->doit)
149 ops->flags |= GENL_CMD_CAP_DO;
150 if (ops->policy)
151 ops->flags |= GENL_CMD_CAP_HASPOL;
152
146 genl_lock(); 153 genl_lock();
147 list_add_tail(&ops->ops_list, &family->ops_list); 154 list_add_tail(&ops->ops_list, &family->ops_list);
148 genl_unlock(); 155 genl_unlock();
@@ -387,7 +394,7 @@ static void genl_rcv(struct sock *sk, int len)
387static struct genl_family genl_ctrl = { 394static struct genl_family genl_ctrl = {
388 .id = GENL_ID_CTRL, 395 .id = GENL_ID_CTRL,
389 .name = "nlctrl", 396 .name = "nlctrl",
390 .version = 0x1, 397 .version = 0x2,
391 .maxattr = CTRL_ATTR_MAX, 398 .maxattr = CTRL_ATTR_MAX,
392}; 399};
393 400
@@ -425,15 +432,6 @@ static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq,
425 NLA_PUT_U32(skb, CTRL_ATTR_OP_ID, ops->cmd); 432 NLA_PUT_U32(skb, CTRL_ATTR_OP_ID, ops->cmd);
426 NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags); 433 NLA_PUT_U32(skb, CTRL_ATTR_OP_FLAGS, ops->flags);
427 434
428 if (ops->policy)
429 NLA_PUT_FLAG(skb, CTRL_ATTR_OP_POLICY);
430
431 if (ops->doit)
432 NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DOIT);
433
434 if (ops->dumpit)
435 NLA_PUT_FLAG(skb, CTRL_ATTR_OP_DUMPIT);
436
437 nla_nest_end(skb, nest); 435 nla_nest_end(skb, nest);
438 } 436 }
439 437
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 08e68b67bbf6..da73e8a8c18d 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -660,7 +660,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
660 sll->sll_ifindex = dev->ifindex; 660 sll->sll_ifindex = dev->ifindex;
661 661
662 h->tp_status = status; 662 h->tp_status = status;
663 mb(); 663 smp_mb();
664 664
665 { 665 {
666 struct page *p_start, *p_end; 666 struct page *p_start, *p_end;
diff --git a/net/rxrpc/krxiod.c b/net/rxrpc/krxiod.c
index dada34a77b21..49effd92144e 100644
--- a/net/rxrpc/krxiod.c
+++ b/net/rxrpc/krxiod.c
@@ -13,6 +13,7 @@
13#include <linux/completion.h> 13#include <linux/completion.h>
14#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/freezer.h>
16#include <rxrpc/krxiod.h> 17#include <rxrpc/krxiod.h>
17#include <rxrpc/transport.h> 18#include <rxrpc/transport.h>
18#include <rxrpc/peer.h> 19#include <rxrpc/peer.h>
diff --git a/net/rxrpc/krxsecd.c b/net/rxrpc/krxsecd.c
index cea4eb5e2497..3ab0f77409f4 100644
--- a/net/rxrpc/krxsecd.c
+++ b/net/rxrpc/krxsecd.c
@@ -27,6 +27,7 @@
27#include <rxrpc/call.h> 27#include <rxrpc/call.h>
28#include <linux/udp.h> 28#include <linux/udp.h>
29#include <linux/ip.h> 29#include <linux/ip.h>
30#include <linux/freezer.h>
30#include <net/sock.h> 31#include <net/sock.h>
31#include "internal.h" 32#include "internal.h"
32 33
diff --git a/net/rxrpc/krxtimod.c b/net/rxrpc/krxtimod.c
index 3e7466900bd4..9a9b6132dba4 100644
--- a/net/rxrpc/krxtimod.c
+++ b/net/rxrpc/krxtimod.c
@@ -13,6 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/completion.h> 15#include <linux/completion.h>
16#include <linux/freezer.h>
16#include <rxrpc/rxrpc.h> 17#include <rxrpc/rxrpc.h>
17#include <rxrpc/krxtimod.h> 18#include <rxrpc/krxtimod.h>
18#include <asm/errno.h> 19#include <asm/errno.h>
diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c
index f59a2c4aa039..c797d6ada7de 100644
--- a/net/sched/cls_fw.c
+++ b/net/sched/cls_fw.c
@@ -101,9 +101,10 @@ static int fw_classify(struct sk_buff *skb, struct tcf_proto *tp,
101 struct fw_head *head = (struct fw_head*)tp->root; 101 struct fw_head *head = (struct fw_head*)tp->root;
102 struct fw_filter *f; 102 struct fw_filter *f;
103 int r; 103 int r;
104 u32 id = skb->mark & head->mask; 104 u32 id = skb->mark;
105 105
106 if (head != NULL) { 106 if (head != NULL) {
107 id &= head->mask;
107 for (f=head->ht[fw_hash(id)]; f; f=f->next) { 108 for (f=head->ht[fw_hash(id)]; f; f=f->next) {
108 if (f->id == id) { 109 if (f->id == id) {
109 *res = f->res; 110 *res = f->res;
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 11f3b549f4a4..f2ba8615895b 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -79,8 +79,8 @@ static struct sctp_pf *sctp_pf_inet_specific;
79static struct sctp_af *sctp_af_v4_specific; 79static struct sctp_af *sctp_af_v4_specific;
80static struct sctp_af *sctp_af_v6_specific; 80static struct sctp_af *sctp_af_v6_specific;
81 81
82kmem_cache_t *sctp_chunk_cachep __read_mostly; 82struct kmem_cache *sctp_chunk_cachep __read_mostly;
83kmem_cache_t *sctp_bucket_cachep __read_mostly; 83struct kmem_cache *sctp_bucket_cachep __read_mostly;
84 84
85/* Return the address of the control sock. */ 85/* Return the address of the control sock. */
86struct sock *sctp_get_ctl_sock(void) 86struct sock *sctp_get_ctl_sock(void)
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 04954e5f6846..30927d3a597f 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -65,7 +65,7 @@
65#include <net/sctp/sctp.h> 65#include <net/sctp/sctp.h>
66#include <net/sctp/sm.h> 66#include <net/sctp/sm.h>
67 67
68extern kmem_cache_t *sctp_chunk_cachep; 68extern struct kmem_cache *sctp_chunk_cachep;
69 69
70SCTP_STATIC 70SCTP_STATIC
71struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc, 71struct sctp_chunk *sctp_make_chunk(const struct sctp_association *asoc,
@@ -979,7 +979,7 @@ struct sctp_chunk *sctp_chunkify(struct sk_buff *skb,
979{ 979{
980 struct sctp_chunk *retval; 980 struct sctp_chunk *retval;
981 981
982 retval = kmem_cache_alloc(sctp_chunk_cachep, SLAB_ATOMIC); 982 retval = kmem_cache_alloc(sctp_chunk_cachep, GFP_ATOMIC);
983 983
984 if (!retval) 984 if (!retval)
985 goto nodata; 985 goto nodata;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 02b27145b279..1e8132b8c4d9 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -107,7 +107,7 @@ static void sctp_sock_migrate(struct sock *, struct sock *,
107 struct sctp_association *, sctp_socket_type_t); 107 struct sctp_association *, sctp_socket_type_t);
108static char *sctp_hmac_alg = SCTP_COOKIE_HMAC_ALG; 108static char *sctp_hmac_alg = SCTP_COOKIE_HMAC_ALG;
109 109
110extern kmem_cache_t *sctp_bucket_cachep; 110extern struct kmem_cache *sctp_bucket_cachep;
111 111
112/* Get the sndbuf space available at the time on the association. */ 112/* Get the sndbuf space available at the time on the association. */
113static inline int sctp_wspace(struct sctp_association *asoc) 113static inline int sctp_wspace(struct sctp_association *asoc)
@@ -4989,7 +4989,7 @@ static struct sctp_bind_bucket *sctp_bucket_create(
4989{ 4989{
4990 struct sctp_bind_bucket *pp; 4990 struct sctp_bind_bucket *pp;
4991 4991
4992 pp = kmem_cache_alloc(sctp_bucket_cachep, SLAB_ATOMIC); 4992 pp = kmem_cache_alloc(sctp_bucket_cachep, GFP_ATOMIC);
4993 SCTP_DBG_OBJCNT_INC(bind_bucket); 4993 SCTP_DBG_OBJCNT_INC(bind_bucket);
4994 if (pp) { 4994 if (pp) {
4995 pp->port = snum; 4995 pp->port = snum;
diff --git a/net/socket.c b/net/socket.c
index e8db54702a69..29ea1de43ecb 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -230,13 +230,13 @@ int move_addr_to_user(void *kaddr, int klen, void __user *uaddr,
230 230
231#define SOCKFS_MAGIC 0x534F434B 231#define SOCKFS_MAGIC 0x534F434B
232 232
233static kmem_cache_t *sock_inode_cachep __read_mostly; 233static struct kmem_cache *sock_inode_cachep __read_mostly;
234 234
235static struct inode *sock_alloc_inode(struct super_block *sb) 235static struct inode *sock_alloc_inode(struct super_block *sb)
236{ 236{
237 struct socket_alloc *ei; 237 struct socket_alloc *ei;
238 238
239 ei = kmem_cache_alloc(sock_inode_cachep, SLAB_KERNEL); 239 ei = kmem_cache_alloc(sock_inode_cachep, GFP_KERNEL);
240 if (!ei) 240 if (!ei)
241 return NULL; 241 return NULL;
242 init_waitqueue_head(&ei->socket.wait); 242 init_waitqueue_head(&ei->socket.wait);
@@ -257,7 +257,7 @@ static void sock_destroy_inode(struct inode *inode)
257 container_of(inode, struct socket_alloc, vfs_inode)); 257 container_of(inode, struct socket_alloc, vfs_inode));
258} 258}
259 259
260static void init_once(void *foo, kmem_cache_t *cachep, unsigned long flags) 260static void init_once(void *foo, struct kmem_cache *cachep, unsigned long flags)
261{ 261{
262 struct socket_alloc *ei = (struct socket_alloc *)foo; 262 struct socket_alloc *ei = (struct socket_alloc *)foo;
263 263
@@ -305,7 +305,14 @@ static struct file_system_type sock_fs_type = {
305 305
306static int sockfs_delete_dentry(struct dentry *dentry) 306static int sockfs_delete_dentry(struct dentry *dentry)
307{ 307{
308 return 1; 308 /*
309 * At creation time, we pretended this dentry was hashed
310 * (by clearing DCACHE_UNHASHED bit in d_flags)
311 * At delete time, we restore the truth : not hashed.
312 * (so that dput() can proceed correctly)
313 */
314 dentry->d_flags |= DCACHE_UNHASHED;
315 return 0;
309} 316}
310static struct dentry_operations sockfs_dentry_operations = { 317static struct dentry_operations sockfs_dentry_operations = {
311 .d_delete = sockfs_delete_dentry, 318 .d_delete = sockfs_delete_dentry,
@@ -353,14 +360,20 @@ static int sock_attach_fd(struct socket *sock, struct file *file)
353 360
354 this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino); 361 this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
355 this.name = name; 362 this.name = name;
356 this.hash = SOCK_INODE(sock)->i_ino; 363 this.hash = 0;
357 364
358 file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this); 365 file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
359 if (unlikely(!file->f_dentry)) 366 if (unlikely(!file->f_dentry))
360 return -ENOMEM; 367 return -ENOMEM;
361 368
362 file->f_dentry->d_op = &sockfs_dentry_operations; 369 file->f_dentry->d_op = &sockfs_dentry_operations;
363 d_add(file->f_dentry, SOCK_INODE(sock)); 370 /*
371 * We dont want to push this dentry into global dentry hash table.
372 * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
373 * This permits a working /proc/$pid/fd/XXX on sockets
374 */
375 file->f_dentry->d_flags &= ~DCACHE_UNHASHED;
376 d_instantiate(file->f_dentry, SOCK_INODE(sock));
364 file->f_vfsmnt = mntget(sock_mnt); 377 file->f_vfsmnt = mntget(sock_mnt);
365 file->f_mapping = file->f_dentry->d_inode->i_mapping; 378 file->f_mapping = file->f_dentry->d_inode->i_mapping;
366 379
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 49dba5febbbd..19703aa9659e 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -33,7 +33,7 @@ static int rpc_mount_count;
33static struct file_system_type rpc_pipe_fs_type; 33static struct file_system_type rpc_pipe_fs_type;
34 34
35 35
36static kmem_cache_t *rpc_inode_cachep __read_mostly; 36static struct kmem_cache *rpc_inode_cachep __read_mostly;
37 37
38#define RPC_UPCALL_TIMEOUT (30*HZ) 38#define RPC_UPCALL_TIMEOUT (30*HZ)
39 39
@@ -143,7 +143,7 @@ static struct inode *
143rpc_alloc_inode(struct super_block *sb) 143rpc_alloc_inode(struct super_block *sb)
144{ 144{
145 struct rpc_inode *rpci; 145 struct rpc_inode *rpci;
146 rpci = (struct rpc_inode *)kmem_cache_alloc(rpc_inode_cachep, SLAB_KERNEL); 146 rpci = (struct rpc_inode *)kmem_cache_alloc(rpc_inode_cachep, GFP_KERNEL);
147 if (!rpci) 147 if (!rpci)
148 return NULL; 148 return NULL;
149 return &rpci->vfs_inode; 149 return &rpci->vfs_inode;
@@ -824,7 +824,7 @@ static struct file_system_type rpc_pipe_fs_type = {
824}; 824};
825 825
826static void 826static void
827init_once(void * foo, kmem_cache_t * cachep, unsigned long flags) 827init_once(void * foo, struct kmem_cache * cachep, unsigned long flags)
828{ 828{
829 struct rpc_inode *rpci = (struct rpc_inode *) foo; 829 struct rpc_inode *rpci = (struct rpc_inode *) foo;
830 830
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 18a33d327012..79bc4cdf5d48 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -34,8 +34,8 @@ static int rpc_task_id;
34#define RPC_BUFFER_MAXSIZE (2048) 34#define RPC_BUFFER_MAXSIZE (2048)
35#define RPC_BUFFER_POOLSIZE (8) 35#define RPC_BUFFER_POOLSIZE (8)
36#define RPC_TASK_POOLSIZE (8) 36#define RPC_TASK_POOLSIZE (8)
37static kmem_cache_t *rpc_task_slabp __read_mostly; 37static struct kmem_cache *rpc_task_slabp __read_mostly;
38static kmem_cache_t *rpc_buffer_slabp __read_mostly; 38static struct kmem_cache *rpc_buffer_slabp __read_mostly;
39static mempool_t *rpc_task_mempool __read_mostly; 39static mempool_t *rpc_task_mempool __read_mostly;
40static mempool_t *rpc_buffer_mempool __read_mostly; 40static mempool_t *rpc_buffer_mempool __read_mostly;
41 41
diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c
index ee9bb1522d5e..c7bb5f7f21a5 100644
--- a/net/sunrpc/svcauth.c
+++ b/net/sunrpc/svcauth.c
@@ -119,7 +119,8 @@ EXPORT_SYMBOL(svc_auth_unregister);
119#define DN_HASHMASK (DN_HASHMAX-1) 119#define DN_HASHMASK (DN_HASHMAX-1)
120 120
121static struct hlist_head auth_domain_table[DN_HASHMAX]; 121static struct hlist_head auth_domain_table[DN_HASHMAX];
122static spinlock_t auth_domain_lock = SPIN_LOCK_UNLOCKED; 122static spinlock_t auth_domain_lock =
123 __SPIN_LOCK_UNLOCKED(auth_domain_lock);
123 124
124void auth_domain_put(struct auth_domain *dom) 125void auth_domain_put(struct auth_domain *dom)
125{ 126{
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 64ca1f61dd94..99f54fb6d669 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -32,6 +32,7 @@
32#include <linux/netdevice.h> 32#include <linux/netdevice.h>
33#include <linux/skbuff.h> 33#include <linux/skbuff.h>
34#include <linux/file.h> 34#include <linux/file.h>
35#include <linux/freezer.h>
35#include <net/sock.h> 36#include <net/sock.h>
36#include <net/checksum.h> 37#include <net/checksum.h>
37#include <net/ip.h> 38#include <net/ip.h>
@@ -84,6 +85,35 @@ static struct cache_deferred_req *svc_defer(struct cache_req *req);
84 */ 85 */
85static int svc_conn_age_period = 6*60; 86static int svc_conn_age_period = 6*60;
86 87
88#ifdef CONFIG_DEBUG_LOCK_ALLOC
89static struct lock_class_key svc_key[2];
90static struct lock_class_key svc_slock_key[2];
91
92static inline void svc_reclassify_socket(struct socket *sock)
93{
94 struct sock *sk = sock->sk;
95 BUG_ON(sk->sk_lock.owner != NULL);
96 switch (sk->sk_family) {
97 case AF_INET:
98 sock_lock_init_class_and_name(sk, "slock-AF_INET-NFSD",
99 &svc_slock_key[0], "sk_lock-AF_INET-NFSD", &svc_key[0]);
100 break;
101
102 case AF_INET6:
103 sock_lock_init_class_and_name(sk, "slock-AF_INET6-NFSD",
104 &svc_slock_key[1], "sk_lock-AF_INET6-NFSD", &svc_key[1]);
105 break;
106
107 default:
108 BUG();
109 }
110}
111#else
112static inline void svc_reclassify_socket(struct socket *sock)
113{
114}
115#endif
116
87/* 117/*
88 * Queue up an idle server thread. Must have pool->sp_lock held. 118 * Queue up an idle server thread. Must have pool->sp_lock held.
89 * Note: this is really a stack rather than a queue, so that we only 119 * Note: this is really a stack rather than a queue, so that we only
@@ -1556,6 +1586,8 @@ svc_create_socket(struct svc_serv *serv, int protocol, struct sockaddr_in *sin)
1556 if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0) 1586 if ((error = sock_create_kern(PF_INET, type, protocol, &sock)) < 0)
1557 return error; 1587 return error;
1558 1588
1589 svc_reclassify_socket(sock);
1590
1559 if (type == SOCK_STREAM) 1591 if (type == SOCK_STREAM)
1560 sock->sk->sk_reuse = 1; /* allow address reuse */ 1592 sock->sk->sk_reuse = 1; /* allow address reuse */
1561 error = kernel_bind(sock, (struct sockaddr *) sin, 1593 error = kernel_bind(sock, (struct sockaddr *) sin,
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 3bb232eb5d90..49cabffd7fdb 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1173,6 +1173,35 @@ static int xs_bindresvport(struct sock_xprt *transport, struct socket *sock)
1173 return err; 1173 return err;
1174} 1174}
1175 1175
1176#ifdef CONFIG_DEBUG_LOCK_ALLOC
1177static struct lock_class_key xs_key[2];
1178static struct lock_class_key xs_slock_key[2];
1179
1180static inline void xs_reclassify_socket(struct socket *sock)
1181{
1182 struct sock *sk = sock->sk;
1183 BUG_ON(sk->sk_lock.owner != NULL);
1184 switch (sk->sk_family) {
1185 case AF_INET:
1186 sock_lock_init_class_and_name(sk, "slock-AF_INET-NFS",
1187 &xs_slock_key[0], "sk_lock-AF_INET-NFS", &xs_key[0]);
1188 break;
1189
1190 case AF_INET6:
1191 sock_lock_init_class_and_name(sk, "slock-AF_INET6-NFS",
1192 &xs_slock_key[1], "sk_lock-AF_INET6-NFS", &xs_key[1]);
1193 break;
1194
1195 default:
1196 BUG();
1197 }
1198}
1199#else
1200static inline void xs_reclassify_socket(struct socket *sock)
1201{
1202}
1203#endif
1204
1176/** 1205/**
1177 * xs_udp_connect_worker - set up a UDP socket 1206 * xs_udp_connect_worker - set up a UDP socket
1178 * @work: RPC transport to connect 1207 * @work: RPC transport to connect
@@ -1197,6 +1226,7 @@ static void xs_udp_connect_worker(struct work_struct *work)
1197 dprintk("RPC: can't create UDP transport socket (%d).\n", -err); 1226 dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
1198 goto out; 1227 goto out;
1199 } 1228 }
1229 xs_reclassify_socket(sock);
1200 1230
1201 if (xprt->resvport && xs_bindresvport(transport, sock) < 0) { 1231 if (xprt->resvport && xs_bindresvport(transport, sock) < 0) {
1202 sock_release(sock); 1232 sock_release(sock);
@@ -1282,6 +1312,7 @@ static void xs_tcp_connect_worker(struct work_struct *work)
1282 dprintk("RPC: can't create TCP transport socket (%d).\n", -err); 1312 dprintk("RPC: can't create TCP transport socket (%d).\n", -err);
1283 goto out; 1313 goto out;
1284 } 1314 }
1315 xs_reclassify_socket(sock);
1285 1316
1286 if (xprt->resvport && xs_bindresvport(transport, sock) < 0) { 1317 if (xprt->resvport && xs_bindresvport(transport, sock) < 0) {
1287 sock_release(sock); 1318 sock_release(sock);
diff --git a/net/tipc/handler.c b/net/tipc/handler.c
index ae6ddf00a1aa..eb80778d6d9c 100644
--- a/net/tipc/handler.c
+++ b/net/tipc/handler.c
@@ -42,7 +42,7 @@ struct queue_item {
42 unsigned long data; 42 unsigned long data;
43}; 43};
44 44
45static kmem_cache_t *tipc_queue_item_cache; 45static struct kmem_cache *tipc_queue_item_cache;
46static struct list_head signal_queue_head; 46static struct list_head signal_queue_head;
47static DEFINE_SPINLOCK(qitem_lock); 47static DEFINE_SPINLOCK(qitem_lock);
48static int handler_enabled = 0; 48static int handler_enabled = 0;
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
index 316211d9f17d..769cdd62c1bb 100644
--- a/net/wanrouter/wanmain.c
+++ b/net/wanrouter/wanmain.c
@@ -62,63 +62,6 @@
62 62
63#define KMEM_SAFETYZONE 8 63#define KMEM_SAFETYZONE 8
64 64
65/***********FOR DEBUGGING PURPOSES*********************************************
66static void * dbg_kmalloc(unsigned int size, int prio, int line) {
67 int i = 0;
68 void * v = kmalloc(size+sizeof(unsigned int)+2*KMEM_SAFETYZONE*8,prio);
69 char * c1 = v;
70 c1 += sizeof(unsigned int);
71 *((unsigned int *)v) = size;
72
73 for (i = 0; i < KMEM_SAFETYZONE; i++) {
74 c1[0] = 'D'; c1[1] = 'E'; c1[2] = 'A'; c1[3] = 'D';
75 c1[4] = 'B'; c1[5] = 'E'; c1[6] = 'E'; c1[7] = 'F';
76 c1 += 8;
77 }
78 c1 += size;
79 for (i = 0; i < KMEM_SAFETYZONE; i++) {
80 c1[0] = 'M'; c1[1] = 'U'; c1[2] = 'N'; c1[3] = 'G';
81 c1[4] = 'W'; c1[5] = 'A'; c1[6] = 'L'; c1[7] = 'L';
82 c1 += 8;
83 }
84 v = ((char *)v) + sizeof(unsigned int) + KMEM_SAFETYZONE*8;
85 printk(KERN_INFO "line %d kmalloc(%d,%d) = %p\n",line,size,prio,v);
86 return v;
87}
88static void dbg_kfree(void * v, int line) {
89 unsigned int * sp = (unsigned int *)(((char *)v) - (sizeof(unsigned int) + KMEM_SAFETYZONE*8));
90 unsigned int size = *sp;
91 char * c1 = ((char *)v) - KMEM_SAFETYZONE*8;
92 int i = 0;
93 for (i = 0; i < KMEM_SAFETYZONE; i++) {
94 if ( c1[0] != 'D' || c1[1] != 'E' || c1[2] != 'A' || c1[3] != 'D'
95 || c1[4] != 'B' || c1[5] != 'E' || c1[6] != 'E' || c1[7] != 'F') {
96 printk(KERN_INFO "kmalloced block at %p has been corrupted (underrun)!\n",v);
97 printk(KERN_INFO " %4x: %2x %2x %2x %2x %2x %2x %2x %2x\n", i*8,
98 c1[0],c1[1],c1[2],c1[3],c1[4],c1[5],c1[6],c1[7] );
99 }
100 c1 += 8;
101 }
102 c1 += size;
103 for (i = 0; i < KMEM_SAFETYZONE; i++) {
104 if ( c1[0] != 'M' || c1[1] != 'U' || c1[2] != 'N' || c1[3] != 'G'
105 || c1[4] != 'W' || c1[5] != 'A' || c1[6] != 'L' || c1[7] != 'L'
106 ) {
107 printk(KERN_INFO "kmalloced block at %p has been corrupted (overrun):\n",v);
108 printk(KERN_INFO " %4x: %2x %2x %2x %2x %2x %2x %2x %2x\n", i*8,
109 c1[0],c1[1],c1[2],c1[3],c1[4],c1[5],c1[6],c1[7] );
110 }
111 c1 += 8;
112 }
113 printk(KERN_INFO "line %d kfree(%p)\n",line,v);
114 v = ((char *)v) - (sizeof(unsigned int) + KMEM_SAFETYZONE*8);
115 kfree(v);
116}
117
118#define kmalloc(x,y) dbg_kmalloc(x,y,__LINE__)
119#define kfree(x) dbg_kfree(x,__LINE__)
120*****************************************************************************/
121
122/* 65/*
123 * Function Prototypes 66 * Function Prototypes
124 */ 67 */
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index 5a0dbeb6bbe8..6b381fc0383d 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -119,6 +119,23 @@ static struct xfrm_algo_desc aalg_list[] = {
119 .sadb_alg_maxbits = 160 119 .sadb_alg_maxbits = 160
120 } 120 }
121}, 121},
122{
123 .name = "xcbc(aes)",
124
125 .uinfo = {
126 .auth = {
127 .icv_truncbits = 96,
128 .icv_fullbits = 128,
129 }
130 },
131
132 .desc = {
133 .sadb_alg_id = SADB_X_AALG_AES_XCBC_MAC,
134 .sadb_alg_ivlen = 0,
135 .sadb_alg_minbits = 128,
136 .sadb_alg_maxbits = 128
137 }
138},
122}; 139};
123 140
124static struct xfrm_algo_desc ealg_list[] = { 141static struct xfrm_algo_desc ealg_list[] = {
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index e8198a2c785d..414f89070380 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -12,7 +12,7 @@
12#include <net/ip.h> 12#include <net/ip.h>
13#include <net/xfrm.h> 13#include <net/xfrm.h>
14 14
15static kmem_cache_t *secpath_cachep __read_mostly; 15static struct kmem_cache *secpath_cachep __read_mostly;
16 16
17void __secpath_destroy(struct sec_path *sp) 17void __secpath_destroy(struct sec_path *sp)
18{ 18{
@@ -27,7 +27,7 @@ struct sec_path *secpath_dup(struct sec_path *src)
27{ 27{
28 struct sec_path *sp; 28 struct sec_path *sp;
29 29
30 sp = kmem_cache_alloc(secpath_cachep, SLAB_ATOMIC); 30 sp = kmem_cache_alloc(secpath_cachep, GFP_ATOMIC);
31 if (!sp) 31 if (!sp)
32 return NULL; 32 return NULL;
33 33
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index f6c77bd36fdd..bebd40e5a62e 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -25,6 +25,7 @@
25#include <linux/cache.h> 25#include <linux/cache.h>
26#include <net/xfrm.h> 26#include <net/xfrm.h>
27#include <net/ip.h> 27#include <net/ip.h>
28#include <linux/audit.h>
28 29
29#include "xfrm_hash.h" 30#include "xfrm_hash.h"
30 31
@@ -39,7 +40,7 @@ EXPORT_SYMBOL(xfrm_policy_count);
39static DEFINE_RWLOCK(xfrm_policy_afinfo_lock); 40static DEFINE_RWLOCK(xfrm_policy_afinfo_lock);
40static struct xfrm_policy_afinfo *xfrm_policy_afinfo[NPROTO]; 41static struct xfrm_policy_afinfo *xfrm_policy_afinfo[NPROTO];
41 42
42static kmem_cache_t *xfrm_dst_cache __read_mostly; 43static struct kmem_cache *xfrm_dst_cache __read_mostly;
43 44
44static struct work_struct xfrm_policy_gc_work; 45static struct work_struct xfrm_policy_gc_work;
45static HLIST_HEAD(xfrm_policy_gc_list); 46static HLIST_HEAD(xfrm_policy_gc_list);
@@ -804,7 +805,7 @@ struct xfrm_policy *xfrm_policy_byid(u8 type, int dir, u32 id, int delete)
804} 805}
805EXPORT_SYMBOL(xfrm_policy_byid); 806EXPORT_SYMBOL(xfrm_policy_byid);
806 807
807void xfrm_policy_flush(u8 type) 808void xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info)
808{ 809{
809 int dir; 810 int dir;
810 811
@@ -824,6 +825,9 @@ void xfrm_policy_flush(u8 type)
824 hlist_del(&pol->byidx); 825 hlist_del(&pol->byidx);
825 write_unlock_bh(&xfrm_policy_lock); 826 write_unlock_bh(&xfrm_policy_lock);
826 827
828 xfrm_audit_log(audit_info->loginuid, audit_info->secid,
829 AUDIT_MAC_IPSEC_DELSPD, 1, pol, NULL);
830
827 xfrm_policy_kill(pol); 831 xfrm_policy_kill(pol);
828 killed++; 832 killed++;
829 833
@@ -842,6 +846,11 @@ void xfrm_policy_flush(u8 type)
842 hlist_del(&pol->byidx); 846 hlist_del(&pol->byidx);
843 write_unlock_bh(&xfrm_policy_lock); 847 write_unlock_bh(&xfrm_policy_lock);
844 848
849 xfrm_audit_log(audit_info->loginuid,
850 audit_info->secid,
851 AUDIT_MAC_IPSEC_DELSPD, 1,
852 pol, NULL);
853
845 xfrm_policy_kill(pol); 854 xfrm_policy_kill(pol);
846 killed++; 855 killed++;
847 856
@@ -860,33 +869,12 @@ EXPORT_SYMBOL(xfrm_policy_flush);
860int xfrm_policy_walk(u8 type, int (*func)(struct xfrm_policy *, int, int, void*), 869int xfrm_policy_walk(u8 type, int (*func)(struct xfrm_policy *, int, int, void*),
861 void *data) 870 void *data)
862{ 871{
863 struct xfrm_policy *pol; 872 struct xfrm_policy *pol, *last = NULL;
864 struct hlist_node *entry; 873 struct hlist_node *entry;
865 int dir, count, error; 874 int dir, last_dir = 0, count, error;
866 875
867 read_lock_bh(&xfrm_policy_lock); 876 read_lock_bh(&xfrm_policy_lock);
868 count = 0; 877 count = 0;
869 for (dir = 0; dir < 2*XFRM_POLICY_MAX; dir++) {
870 struct hlist_head *table = xfrm_policy_bydst[dir].table;
871 int i;
872
873 hlist_for_each_entry(pol, entry,
874 &xfrm_policy_inexact[dir], bydst) {
875 if (pol->type == type)
876 count++;
877 }
878 for (i = xfrm_policy_bydst[dir].hmask; i >= 0; i--) {
879 hlist_for_each_entry(pol, entry, table + i, bydst) {
880 if (pol->type == type)
881 count++;
882 }
883 }
884 }
885
886 if (count == 0) {
887 error = -ENOENT;
888 goto out;
889 }
890 878
891 for (dir = 0; dir < 2*XFRM_POLICY_MAX; dir++) { 879 for (dir = 0; dir < 2*XFRM_POLICY_MAX; dir++) {
892 struct hlist_head *table = xfrm_policy_bydst[dir].table; 880 struct hlist_head *table = xfrm_policy_bydst[dir].table;
@@ -896,21 +884,37 @@ int xfrm_policy_walk(u8 type, int (*func)(struct xfrm_policy *, int, int, void*)
896 &xfrm_policy_inexact[dir], bydst) { 884 &xfrm_policy_inexact[dir], bydst) {
897 if (pol->type != type) 885 if (pol->type != type)
898 continue; 886 continue;
899 error = func(pol, dir % XFRM_POLICY_MAX, --count, data); 887 if (last) {
900 if (error) 888 error = func(last, last_dir % XFRM_POLICY_MAX,
901 goto out; 889 count, data);
890 if (error)
891 goto out;
892 }
893 last = pol;
894 last_dir = dir;
895 count++;
902 } 896 }
903 for (i = xfrm_policy_bydst[dir].hmask; i >= 0; i--) { 897 for (i = xfrm_policy_bydst[dir].hmask; i >= 0; i--) {
904 hlist_for_each_entry(pol, entry, table + i, bydst) { 898 hlist_for_each_entry(pol, entry, table + i, bydst) {
905 if (pol->type != type) 899 if (pol->type != type)
906 continue; 900 continue;
907 error = func(pol, dir % XFRM_POLICY_MAX, --count, data); 901 if (last) {
908 if (error) 902 error = func(last, last_dir % XFRM_POLICY_MAX,
909 goto out; 903 count, data);
904 if (error)
905 goto out;
906 }
907 last = pol;
908 last_dir = dir;
909 count++;
910 } 910 }
911 } 911 }
912 } 912 }
913 error = 0; 913 if (count == 0) {
914 error = -ENOENT;
915 goto out;
916 }
917 error = func(last, last_dir % XFRM_POLICY_MAX, 0, data);
914out: 918out:
915 read_unlock_bh(&xfrm_policy_lock); 919 read_unlock_bh(&xfrm_policy_lock);
916 return error; 920 return error;
@@ -1982,6 +1986,117 @@ int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *first,
1982 1986
1983EXPORT_SYMBOL(xfrm_bundle_ok); 1987EXPORT_SYMBOL(xfrm_bundle_ok);
1984 1988
1989#ifdef CONFIG_AUDITSYSCALL
1990/* Audit addition and deletion of SAs and ipsec policy */
1991
1992void xfrm_audit_log(uid_t auid, u32 sid, int type, int result,
1993 struct xfrm_policy *xp, struct xfrm_state *x)
1994{
1995
1996 char *secctx;
1997 u32 secctx_len;
1998 struct xfrm_sec_ctx *sctx = NULL;
1999 struct audit_buffer *audit_buf;
2000 int family;
2001 extern int audit_enabled;
2002
2003 if (audit_enabled == 0)
2004 return;
2005
2006 audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, type);
2007 if (audit_buf == NULL)
2008 return;
2009
2010 switch(type) {
2011 case AUDIT_MAC_IPSEC_ADDSA:
2012 audit_log_format(audit_buf, "SAD add: auid=%u", auid);
2013 break;
2014 case AUDIT_MAC_IPSEC_DELSA:
2015 audit_log_format(audit_buf, "SAD delete: auid=%u", auid);
2016 break;
2017 case AUDIT_MAC_IPSEC_ADDSPD:
2018 audit_log_format(audit_buf, "SPD add: auid=%u", auid);
2019 break;
2020 case AUDIT_MAC_IPSEC_DELSPD:
2021 audit_log_format(audit_buf, "SPD delete: auid=%u", auid);
2022 break;
2023 default:
2024 return;
2025 }
2026
2027 if (sid != 0 &&
2028 security_secid_to_secctx(sid, &secctx, &secctx_len) == 0)
2029 audit_log_format(audit_buf, " subj=%s", secctx);
2030 else
2031 audit_log_task_context(audit_buf);
2032
2033 if (xp) {
2034 family = xp->selector.family;
2035 if (xp->security)
2036 sctx = xp->security;
2037 } else {
2038 family = x->props.family;
2039 if (x->security)
2040 sctx = x->security;
2041 }
2042
2043 if (sctx)
2044 audit_log_format(audit_buf,
2045 " sec_alg=%u sec_doi=%u sec_obj=%s",
2046 sctx->ctx_alg, sctx->ctx_doi, sctx->ctx_str);
2047
2048 switch(family) {
2049 case AF_INET:
2050 {
2051 struct in_addr saddr, daddr;
2052 if (xp) {
2053 saddr.s_addr = xp->selector.saddr.a4;
2054 daddr.s_addr = xp->selector.daddr.a4;
2055 } else {
2056 saddr.s_addr = x->props.saddr.a4;
2057 daddr.s_addr = x->id.daddr.a4;
2058 }
2059 audit_log_format(audit_buf,
2060 " src=%u.%u.%u.%u dst=%u.%u.%u.%u",
2061 NIPQUAD(saddr), NIPQUAD(daddr));
2062 }
2063 break;
2064 case AF_INET6:
2065 {
2066 struct in6_addr saddr6, daddr6;
2067 if (xp) {
2068 memcpy(&saddr6, xp->selector.saddr.a6,
2069 sizeof(struct in6_addr));
2070 memcpy(&daddr6, xp->selector.daddr.a6,
2071 sizeof(struct in6_addr));
2072 } else {
2073 memcpy(&saddr6, x->props.saddr.a6,
2074 sizeof(struct in6_addr));
2075 memcpy(&daddr6, x->id.daddr.a6,
2076 sizeof(struct in6_addr));
2077 }
2078 audit_log_format(audit_buf,
2079 " src=" NIP6_FMT "dst=" NIP6_FMT,
2080 NIP6(saddr6), NIP6(daddr6));
2081 }
2082 break;
2083 }
2084
2085 if (x)
2086 audit_log_format(audit_buf, " spi=%lu(0x%lx) protocol=%s",
2087 (unsigned long)ntohl(x->id.spi),
2088 (unsigned long)ntohl(x->id.spi),
2089 x->id.proto == IPPROTO_AH ? "AH" :
2090 (x->id.proto == IPPROTO_ESP ?
2091 "ESP" : "IPCOMP"));
2092
2093 audit_log_format(audit_buf, " res=%u", result);
2094 audit_log_end(audit_buf);
2095}
2096
2097EXPORT_SYMBOL(xfrm_audit_log);
2098#endif /* CONFIG_AUDITSYSCALL */
2099
1985int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) 2100int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
1986{ 2101{
1987 int err = 0; 2102 int err = 0;
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index da54a64ccfa3..fdb08d9f34aa 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -20,6 +20,7 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/cache.h> 21#include <linux/cache.h>
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23#include <linux/audit.h>
23 24
24#include "xfrm_hash.h" 25#include "xfrm_hash.h"
25 26
@@ -238,6 +239,7 @@ static void xfrm_timer_handler(unsigned long data)
238 unsigned long now = (unsigned long)xtime.tv_sec; 239 unsigned long now = (unsigned long)xtime.tv_sec;
239 long next = LONG_MAX; 240 long next = LONG_MAX;
240 int warn = 0; 241 int warn = 0;
242 int err = 0;
241 243
242 spin_lock(&x->lock); 244 spin_lock(&x->lock);
243 if (x->km.state == XFRM_STATE_DEAD) 245 if (x->km.state == XFRM_STATE_DEAD)
@@ -295,9 +297,14 @@ expired:
295 next = 2; 297 next = 2;
296 goto resched; 298 goto resched;
297 } 299 }
298 if (!__xfrm_state_delete(x) && x->id.spi) 300
301 err = __xfrm_state_delete(x);
302 if (!err && x->id.spi)
299 km_state_expired(x, 1, 0); 303 km_state_expired(x, 1, 0);
300 304
305 xfrm_audit_log(audit_get_loginuid(current->audit_context), 0,
306 AUDIT_MAC_IPSEC_DELSA, err ? 0 : 1, NULL, x);
307
301out: 308out:
302 spin_unlock(&x->lock); 309 spin_unlock(&x->lock);
303} 310}
@@ -384,9 +391,10 @@ int xfrm_state_delete(struct xfrm_state *x)
384} 391}
385EXPORT_SYMBOL(xfrm_state_delete); 392EXPORT_SYMBOL(xfrm_state_delete);
386 393
387void xfrm_state_flush(u8 proto) 394void xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info)
388{ 395{
389 int i; 396 int i;
397 int err = 0;
390 398
391 spin_lock_bh(&xfrm_state_lock); 399 spin_lock_bh(&xfrm_state_lock);
392 for (i = 0; i <= xfrm_state_hmask; i++) { 400 for (i = 0; i <= xfrm_state_hmask; i++) {
@@ -399,7 +407,11 @@ restart:
399 xfrm_state_hold(x); 407 xfrm_state_hold(x);
400 spin_unlock_bh(&xfrm_state_lock); 408 spin_unlock_bh(&xfrm_state_lock);
401 409
402 xfrm_state_delete(x); 410 err = xfrm_state_delete(x);
411 xfrm_audit_log(audit_info->loginuid,
412 audit_info->secid,
413 AUDIT_MAC_IPSEC_DELSA,
414 err ? 0 : 1, NULL, x);
403 xfrm_state_put(x); 415 xfrm_state_put(x);
404 416
405 spin_lock_bh(&xfrm_state_lock); 417 spin_lock_bh(&xfrm_state_lock);
@@ -1099,7 +1111,7 @@ int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*),
1099 void *data) 1111 void *data)
1100{ 1112{
1101 int i; 1113 int i;
1102 struct xfrm_state *x; 1114 struct xfrm_state *x, *last = NULL;
1103 struct hlist_node *entry; 1115 struct hlist_node *entry;
1104 int count = 0; 1116 int count = 0;
1105 int err = 0; 1117 int err = 0;
@@ -1107,24 +1119,22 @@ int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*),
1107 spin_lock_bh(&xfrm_state_lock); 1119 spin_lock_bh(&xfrm_state_lock);
1108 for (i = 0; i <= xfrm_state_hmask; i++) { 1120 for (i = 0; i <= xfrm_state_hmask; i++) {
1109 hlist_for_each_entry(x, entry, xfrm_state_bydst+i, bydst) { 1121 hlist_for_each_entry(x, entry, xfrm_state_bydst+i, bydst) {
1110 if (xfrm_id_proto_match(x->id.proto, proto)) 1122 if (!xfrm_id_proto_match(x->id.proto, proto))
1111 count++; 1123 continue;
1124 if (last) {
1125 err = func(last, count, data);
1126 if (err)
1127 goto out;
1128 }
1129 last = x;
1130 count++;
1112 } 1131 }
1113 } 1132 }
1114 if (count == 0) { 1133 if (count == 0) {
1115 err = -ENOENT; 1134 err = -ENOENT;
1116 goto out; 1135 goto out;
1117 } 1136 }
1118 1137 err = func(last, 0, data);
1119 for (i = 0; i <= xfrm_state_hmask; i++) {
1120 hlist_for_each_entry(x, entry, xfrm_state_bydst+i, bydst) {
1121 if (!xfrm_id_proto_match(x->id.proto, proto))
1122 continue;
1123 err = func(x, --count, data);
1124 if (err)
1125 goto out;
1126 }
1127 }
1128out: 1138out:
1129 spin_unlock_bh(&xfrm_state_lock); 1139 spin_unlock_bh(&xfrm_state_lock);
1130 return err; 1140 return err;
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 311205ffa775..e5372b11fc8f 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -31,6 +31,7 @@
31#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 31#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
32#include <linux/in6.h> 32#include <linux/in6.h>
33#endif 33#endif
34#include <linux/audit.h>
34 35
35static int verify_one_alg(struct rtattr **xfrma, enum xfrm_attr_type_t type) 36static int verify_one_alg(struct rtattr **xfrma, enum xfrm_attr_type_t type)
36{ 37{
@@ -454,6 +455,9 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
454 else 455 else
455 err = xfrm_state_update(x); 456 err = xfrm_state_update(x);
456 457
458 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
459 AUDIT_MAC_IPSEC_ADDSA, err ? 0 : 1, NULL, x);
460
457 if (err < 0) { 461 if (err < 0) {
458 x->km.state = XFRM_STATE_DEAD; 462 x->km.state = XFRM_STATE_DEAD;
459 __xfrm_state_put(x); 463 __xfrm_state_put(x);
@@ -523,6 +527,10 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
523 } 527 }
524 528
525 err = xfrm_state_delete(x); 529 err = xfrm_state_delete(x);
530
531 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
532 AUDIT_MAC_IPSEC_DELSA, err ? 0 : 1, NULL, x);
533
526 if (err < 0) 534 if (err < 0)
527 goto out; 535 goto out;
528 536
@@ -1030,6 +1038,9 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
1030 * a type XFRM_MSG_UPDPOLICY - JHS */ 1038 * a type XFRM_MSG_UPDPOLICY - JHS */
1031 excl = nlh->nlmsg_type == XFRM_MSG_NEWPOLICY; 1039 excl = nlh->nlmsg_type == XFRM_MSG_NEWPOLICY;
1032 err = xfrm_policy_insert(p->dir, xp, excl); 1040 err = xfrm_policy_insert(p->dir, xp, excl);
1041 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
1042 AUDIT_MAC_IPSEC_DELSPD, err ? 0 : 1, xp, NULL);
1043
1033 if (err) { 1044 if (err) {
1034 security_xfrm_policy_free(xp); 1045 security_xfrm_policy_free(xp);
1035 kfree(xp); 1046 kfree(xp);
@@ -1257,6 +1268,10 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
1257 xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, tmp.security, delete); 1268 xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, tmp.security, delete);
1258 security_xfrm_policy_free(&tmp); 1269 security_xfrm_policy_free(&tmp);
1259 } 1270 }
1271 if (delete)
1272 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
1273 AUDIT_MAC_IPSEC_DELSPD, (xp) ? 1 : 0, xp, NULL);
1274
1260 if (xp == NULL) 1275 if (xp == NULL)
1261 return -ENOENT; 1276 return -ENOENT;
1262 1277
@@ -1291,8 +1306,11 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma
1291{ 1306{
1292 struct km_event c; 1307 struct km_event c;
1293 struct xfrm_usersa_flush *p = NLMSG_DATA(nlh); 1308 struct xfrm_usersa_flush *p = NLMSG_DATA(nlh);
1309 struct xfrm_audit audit_info;
1294 1310
1295 xfrm_state_flush(p->proto); 1311 audit_info.loginuid = NETLINK_CB(skb).loginuid;
1312 audit_info.secid = NETLINK_CB(skb).sid;
1313 xfrm_state_flush(p->proto, &audit_info);
1296 c.data.proto = p->proto; 1314 c.data.proto = p->proto;
1297 c.event = nlh->nlmsg_type; 1315 c.event = nlh->nlmsg_type;
1298 c.seq = nlh->nlmsg_seq; 1316 c.seq = nlh->nlmsg_seq;
@@ -1442,12 +1460,15 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **x
1442 struct km_event c; 1460 struct km_event c;
1443 u8 type = XFRM_POLICY_TYPE_MAIN; 1461 u8 type = XFRM_POLICY_TYPE_MAIN;
1444 int err; 1462 int err;
1463 struct xfrm_audit audit_info;
1445 1464
1446 err = copy_from_user_policy_type(&type, (struct rtattr **)xfrma); 1465 err = copy_from_user_policy_type(&type, (struct rtattr **)xfrma);
1447 if (err) 1466 if (err)
1448 return err; 1467 return err;
1449 1468
1450 xfrm_policy_flush(type); 1469 audit_info.loginuid = NETLINK_CB(skb).loginuid;
1470 audit_info.secid = NETLINK_CB(skb).sid;
1471 xfrm_policy_flush(type, &audit_info);
1451 c.data.type = type; 1472 c.data.type = type;
1452 c.event = nlh->nlmsg_type; 1473 c.event = nlh->nlmsg_type;
1453 c.seq = nlh->nlmsg_seq; 1474 c.seq = nlh->nlmsg_seq;
@@ -1502,6 +1523,9 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh, void *
1502 err = 0; 1523 err = 0;
1503 if (up->hard) { 1524 if (up->hard) {
1504 xfrm_policy_delete(xp, p->dir); 1525 xfrm_policy_delete(xp, p->dir);
1526 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
1527 AUDIT_MAC_IPSEC_DELSPD, 1, xp, NULL);
1528
1505 } else { 1529 } else {
1506 // reset the timers here? 1530 // reset the timers here?
1507 printk("Dont know what to do with soft policy expire\n"); 1531 printk("Dont know what to do with soft policy expire\n");
@@ -1533,8 +1557,11 @@ static int xfrm_add_sa_expire(struct sk_buff *skb, struct nlmsghdr *nlh, void **
1533 goto out; 1557 goto out;
1534 km_state_expired(x, ue->hard, current->pid); 1558 km_state_expired(x, ue->hard, current->pid);
1535 1559
1536 if (ue->hard) 1560 if (ue->hard) {
1537 __xfrm_state_delete(x); 1561 __xfrm_state_delete(x);
1562 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
1563 AUDIT_MAC_IPSEC_DELSA, 1, NULL, x);
1564 }
1538out: 1565out:
1539 spin_unlock_bh(&x->lock); 1566 spin_unlock_bh(&x->lock);
1540 xfrm_state_put(x); 1567 xfrm_state_put(x);
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 22d281c6ec24..f359b730c2c5 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -43,7 +43,7 @@ struct sym_entry {
43 43
44static struct sym_entry *table; 44static struct sym_entry *table;
45static unsigned int table_size, table_cnt; 45static unsigned int table_size, table_cnt;
46static unsigned long long _stext, _etext, _sinittext, _einittext, _sextratext, _eextratext; 46static unsigned long long _text, _stext, _etext, _sinittext, _einittext, _sextratext, _eextratext;
47static int all_symbols = 0; 47static int all_symbols = 0;
48static char symbol_prefix_char = '\0'; 48static char symbol_prefix_char = '\0';
49 49
@@ -91,7 +91,9 @@ static int read_symbol(FILE *in, struct sym_entry *s)
91 sym++; 91 sym++;
92 92
93 /* Ignore most absolute/undefined (?) symbols. */ 93 /* Ignore most absolute/undefined (?) symbols. */
94 if (strcmp(sym, "_stext") == 0) 94 if (strcmp(sym, "_text") == 0)
95 _text = s->addr;
96 else if (strcmp(sym, "_stext") == 0)
95 _stext = s->addr; 97 _stext = s->addr;
96 else if (strcmp(sym, "_etext") == 0) 98 else if (strcmp(sym, "_etext") == 0)
97 _etext = s->addr; 99 _etext = s->addr;
@@ -265,9 +267,25 @@ static void write_src(void)
265 267
266 printf(".data\n"); 268 printf(".data\n");
267 269
270 /* Provide proper symbols relocatability by their '_text'
271 * relativeness. The symbol names cannot be used to construct
272 * normal symbol references as the list of symbols contains
273 * symbols that are declared static and are private to their
274 * .o files. This prevents .tmp_kallsyms.o or any other
275 * object from referencing them.
276 */
268 output_label("kallsyms_addresses"); 277 output_label("kallsyms_addresses");
269 for (i = 0; i < table_cnt; i++) { 278 for (i = 0; i < table_cnt; i++) {
270 printf("\tPTR\t%#llx\n", table[i].addr); 279 if (toupper(table[i].sym[0]) != 'A') {
280 if (_text <= table[i].addr)
281 printf("\tPTR\t_text + %#llx\n",
282 table[i].addr - _text);
283 else
284 printf("\tPTR\t_text - %#llx\n",
285 _text - table[i].addr);
286 } else {
287 printf("\tPTR\t%#llx\n", table[i].addr);
288 }
271 } 289 }
272 printf("\n"); 290 printf("\n");
273 291
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 338bdea96541..f5628c57640b 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -798,7 +798,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
798 QAction *action; 798 QAction *action;
799 799
800 headerPopup = new QPopupMenu(this); 800 headerPopup = new QPopupMenu(this);
801 action = new QAction("Show Name", 0, this); 801 action = new QAction(NULL, "Show Name", 0, this);
802 action->setToggleAction(TRUE); 802 action->setToggleAction(TRUE);
803 connect(action, SIGNAL(toggled(bool)), 803 connect(action, SIGNAL(toggled(bool)),
804 parent(), SLOT(setShowName(bool))); 804 parent(), SLOT(setShowName(bool)));
@@ -806,7 +806,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
806 action, SLOT(setOn(bool))); 806 action, SLOT(setOn(bool)));
807 action->setOn(showName); 807 action->setOn(showName);
808 action->addTo(headerPopup); 808 action->addTo(headerPopup);
809 action = new QAction("Show Range", 0, this); 809 action = new QAction(NULL, "Show Range", 0, this);
810 action->setToggleAction(TRUE); 810 action->setToggleAction(TRUE);
811 connect(action, SIGNAL(toggled(bool)), 811 connect(action, SIGNAL(toggled(bool)),
812 parent(), SLOT(setShowRange(bool))); 812 parent(), SLOT(setShowRange(bool)));
@@ -814,7 +814,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
814 action, SLOT(setOn(bool))); 814 action, SLOT(setOn(bool)));
815 action->setOn(showRange); 815 action->setOn(showRange);
816 action->addTo(headerPopup); 816 action->addTo(headerPopup);
817 action = new QAction("Show Data", 0, this); 817 action = new QAction(NULL, "Show Data", 0, this);
818 action->setToggleAction(TRUE); 818 action->setToggleAction(TRUE);
819 connect(action, SIGNAL(toggled(bool)), 819 connect(action, SIGNAL(toggled(bool)),
820 parent(), SLOT(setShowData(bool))); 820 parent(), SLOT(setShowData(bool)));
@@ -1161,7 +1161,7 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
1161QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) 1161QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
1162{ 1162{
1163 QPopupMenu* popup = Parent::createPopupMenu(pos); 1163 QPopupMenu* popup = Parent::createPopupMenu(pos);
1164 QAction* action = new QAction("Show Debug Info", 0, popup); 1164 QAction* action = new QAction(NULL,"Show Debug Info", 0, popup);
1165 action->setToggleAction(TRUE); 1165 action->setToggleAction(TRUE);
1166 connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); 1166 connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
1167 connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); 1167 connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 187f5de4612c..df3b272f7ce6 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1430,7 +1430,7 @@ sub create_parameterlist($$$) {
1430 # corresponding data structures "correctly". Catch it later in 1430 # corresponding data structures "correctly". Catch it later in
1431 # output_* subs. 1431 # output_* subs.
1432 push_parameter($arg, "", $file); 1432 push_parameter($arg, "", $file);
1433 } elsif ($arg =~ m/\(/) { 1433 } elsif ($arg =~ m/\(.*\*/) {
1434 # pointer-to-function 1434 # pointer-to-function
1435 $arg =~ tr/#/,/; 1435 $arg =~ tr/#/,/;
1436 $arg =~ m/[^\(]+\(\*([^\)]+)\)/; 1436 $arg =~ m/[^\(]+\(\*([^\)]+)\)/;
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 2e1141623147..ac0a58222992 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -911,6 +911,7 @@ static int init_section_ref_ok(const char *name)
911 ".toc1", /* used by ppc64 */ 911 ".toc1", /* used by ppc64 */
912 ".stab", 912 ".stab",
913 ".rodata", 913 ".rodata",
914 ".parainstructions",
914 ".text.lock", 915 ".text.lock",
915 "__bug_table", /* used by powerpc for BUG() */ 916 "__bug_table", /* used by powerpc for BUG() */
916 ".pci_fixup_header", 917 ".pci_fixup_header",
@@ -931,6 +932,7 @@ static int init_section_ref_ok(const char *name)
931 ".altinstructions", 932 ".altinstructions",
932 ".eh_frame", 933 ".eh_frame",
933 ".debug", 934 ".debug",
935 ".parainstructions",
934 NULL 936 NULL
935 }; 937 };
936 /* part of section name */ 938 /* part of section name */
diff --git a/scripts/ver_linux b/scripts/ver_linux
index 84999f69773d..72876dfadc8a 100755
--- a/scripts/ver_linux
+++ b/scripts/ver_linux
@@ -48,6 +48,8 @@ fsck.reiser4 -V 2>&1 | grep ^fsck.reiser4 | awk \
48xfs_db -V 2>&1 | grep version | awk \ 48xfs_db -V 2>&1 | grep version | awk \
49'NR==1{print "xfsprogs ", $3}' 49'NR==1{print "xfsprogs ", $3}'
50 50
51pccardctl -V 2>&1| grep pcmciautils | awk '{print "pcmciautils ", $2}'
52
51cardmgr -V 2>&1| grep version | awk \ 53cardmgr -V 2>&1| grep version | awk \
52'NR==1{print "pcmcia-cs ", $3}' 54'NR==1{print "pcmcia-cs ", $3}'
53 55
@@ -87,10 +89,16 @@ loadkeys -h 2>&1 | awk \
87loadkeys -V 2>&1 | awk \ 89loadkeys -V 2>&1 | awk \
88'(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools ", $3}' 90'(NR==1 && ($2 ~ /console-tools/)) {print "Console-tools ", $3}'
89 91
92oprofiled --version 2>&1 | awk \
93'(NR==1 && ($2 == "oprofile")) {print "oprofile ", $3}'
94
90expr --v 2>&1 | awk 'NR==1{print "Sh-utils ", $NF}' 95expr --v 2>&1 | awk 'NR==1{print "Sh-utils ", $NF}'
91 96
92udevinfo -V 2>&1 | grep version | awk '{print "udev ", $3}' 97udevinfo -V 2>&1 | grep version | awk '{print "udev ", $3}'
93 98
99iwconfig --version 2>&1 | awk \
100'(NR==1 && ($3 == "version")) {print "wireless-tools ",$4}'
101
94if [ -e /proc/modules ]; then 102if [ -e /proc/modules ]; then
95 X=`cat /proc/modules | sed -e "s/ .*$//"` 103 X=`cat /proc/modules | sed -e "s/ .*$//"`
96 echo "Modules Loaded "$X 104 echo "Modules Loaded "$X
diff --git a/security/keys/key.c b/security/keys/key.c
index 70eacbe5abde..ac9326c5f1da 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -20,7 +20,7 @@
20#include <linux/err.h> 20#include <linux/err.h>
21#include "internal.h" 21#include "internal.h"
22 22
23static kmem_cache_t *key_jar; 23static struct kmem_cache *key_jar;
24struct rb_root key_serial_tree; /* tree of keys indexed by serial */ 24struct rb_root key_serial_tree; /* tree of keys indexed by serial */
25DEFINE_SPINLOCK(key_serial_lock); 25DEFINE_SPINLOCK(key_serial_lock);
26 26
@@ -285,16 +285,14 @@ struct key *key_alloc(struct key_type *type, const char *desc,
285 } 285 }
286 286
287 /* allocate and initialise the key and its description */ 287 /* allocate and initialise the key and its description */
288 key = kmem_cache_alloc(key_jar, SLAB_KERNEL); 288 key = kmem_cache_alloc(key_jar, GFP_KERNEL);
289 if (!key) 289 if (!key)
290 goto no_memory_2; 290 goto no_memory_2;
291 291
292 if (desc) { 292 if (desc) {
293 key->description = kmalloc(desclen, GFP_KERNEL); 293 key->description = kmemdup(desc, desclen, GFP_KERNEL);
294 if (!key->description) 294 if (!key->description)
295 goto no_memory_3; 295 goto no_memory_3;
296
297 memcpy(key->description, desc, desclen);
298 } 296 }
299 297
300 atomic_set(&key->usage, 1); 298 atomic_set(&key->usage, 1);
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index e8d02acc51e7..ad45ce73964b 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -706,12 +706,10 @@ int __key_link(struct key *keyring, struct key *key)
706 BUG_ON(size > PAGE_SIZE); 706 BUG_ON(size > PAGE_SIZE);
707 707
708 ret = -ENOMEM; 708 ret = -ENOMEM;
709 nklist = kmalloc(size, GFP_KERNEL); 709 nklist = kmemdup(klist, size, GFP_KERNEL);
710 if (!nklist) 710 if (!nklist)
711 goto error2; 711 goto error2;
712 712
713 memcpy(nklist, klist, size);
714
715 /* replace matched key */ 713 /* replace matched key */
716 atomic_inc(&key->usage); 714 atomic_inc(&key->usage);
717 nklist->keys[loop] = key; 715 nklist->keys[loop] = key;
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c
index 32150cf7c37f..b6f86808475a 100644
--- a/security/keys/process_keys.c
+++ b/security/keys/process_keys.c
@@ -27,7 +27,7 @@ static DEFINE_MUTEX(key_session_mutex);
27struct key_user root_key_user = { 27struct key_user root_key_user = {
28 .usage = ATOMIC_INIT(3), 28 .usage = ATOMIC_INIT(3),
29 .consq = LIST_HEAD_INIT(root_key_user.consq), 29 .consq = LIST_HEAD_INIT(root_key_user.consq),
30 .lock = SPIN_LOCK_UNLOCKED, 30 .lock = __SPIN_LOCK_UNLOCKED(root_key_user.lock),
31 .nkeys = ATOMIC_INIT(2), 31 .nkeys = ATOMIC_INIT(2),
32 .nikeys = ATOMIC_INIT(2), 32 .nikeys = ATOMIC_INIT(2),
33 .uid = 0, 33 .uid = 0,
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index e73ac1ab7cfd..e7c0b5e2066b 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -124,7 +124,7 @@ DEFINE_PER_CPU(struct avc_cache_stats, avc_cache_stats) = { 0 };
124 124
125static struct avc_cache avc_cache; 125static struct avc_cache avc_cache;
126static struct avc_callback_node *avc_callbacks; 126static struct avc_callback_node *avc_callbacks;
127static kmem_cache_t *avc_node_cachep; 127static struct kmem_cache *avc_node_cachep;
128 128
129static inline int avc_hash(u32 ssid, u32 tsid, u16 tclass) 129static inline int avc_hash(u32 ssid, u32 tsid, u16 tclass)
130{ 130{
@@ -332,7 +332,7 @@ static struct avc_node *avc_alloc_node(void)
332{ 332{
333 struct avc_node *node; 333 struct avc_node *node;
334 334
335 node = kmem_cache_alloc(avc_node_cachep, SLAB_ATOMIC); 335 node = kmem_cache_alloc(avc_node_cachep, GFP_ATOMIC);
336 if (!node) 336 if (!node)
337 goto out; 337 goto out;
338 338
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 78f98fe084eb..44e9cd470543 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -124,7 +124,7 @@ static struct security_operations *secondary_ops = NULL;
124static LIST_HEAD(superblock_security_head); 124static LIST_HEAD(superblock_security_head);
125static DEFINE_SPINLOCK(sb_security_lock); 125static DEFINE_SPINLOCK(sb_security_lock);
126 126
127static kmem_cache_t *sel_inode_cache; 127static struct kmem_cache *sel_inode_cache;
128 128
129/* Return security context for a given sid or just the context 129/* Return security context for a given sid or just the context
130 length if the buffer is null or length is 0 */ 130 length if the buffer is null or length is 0 */
@@ -181,7 +181,7 @@ static int inode_alloc_security(struct inode *inode)
181 struct task_security_struct *tsec = current->security; 181 struct task_security_struct *tsec = current->security;
182 struct inode_security_struct *isec; 182 struct inode_security_struct *isec;
183 183
184 isec = kmem_cache_alloc(sel_inode_cache, SLAB_KERNEL); 184 isec = kmem_cache_alloc(sel_inode_cache, GFP_KERNEL);
185 if (!isec) 185 if (!isec)
186 return -ENOMEM; 186 return -ENOMEM;
187 187
diff --git a/security/selinux/ss/avtab.c b/security/selinux/ss/avtab.c
index d049c7acbc8b..ebb993c5c244 100644
--- a/security/selinux/ss/avtab.c
+++ b/security/selinux/ss/avtab.c
@@ -28,7 +28,7 @@
28 (keyp->source_type << 9)) & \ 28 (keyp->source_type << 9)) & \
29 AVTAB_HASH_MASK) 29 AVTAB_HASH_MASK)
30 30
31static kmem_cache_t *avtab_node_cachep; 31static struct kmem_cache *avtab_node_cachep;
32 32
33static struct avtab_node* 33static struct avtab_node*
34avtab_insert_node(struct avtab *h, int hvalue, 34avtab_insert_node(struct avtab *h, int hvalue,
@@ -36,7 +36,7 @@ avtab_insert_node(struct avtab *h, int hvalue,
36 struct avtab_key *key, struct avtab_datum *datum) 36 struct avtab_key *key, struct avtab_datum *datum)
37{ 37{
38 struct avtab_node * newnode; 38 struct avtab_node * newnode;
39 newnode = kmem_cache_alloc(avtab_node_cachep, SLAB_KERNEL); 39 newnode = kmem_cache_alloc(avtab_node_cachep, GFP_KERNEL);
40 if (newnode == NULL) 40 if (newnode == NULL)
41 return NULL; 41 return NULL;
42 memset(newnode, 0, sizeof(struct avtab_node)); 42 memset(newnode, 0, sizeof(struct avtab_node));
diff --git a/sound/arm/sa11xx-uda1341.c b/sound/arm/sa11xx-uda1341.c
index c79a9afd0955..c7e1b2646193 100644
--- a/sound/arm/sa11xx-uda1341.c
+++ b/sound/arm/sa11xx-uda1341.c
@@ -125,7 +125,7 @@ struct audio_stream {
125#else 125#else
126 dma_regs_t *dma_regs; /* points to our DMA registers */ 126 dma_regs_t *dma_regs; /* points to our DMA registers */
127#endif 127#endif
128 int active:1; /* we are using this stream for transfer now */ 128 unsigned int active:1; /* we are using this stream for transfer now */
129 int period; /* current transfer period */ 129 int period; /* current transfer period */
130 int periods; /* current count of periods registerd in the DMA engine */ 130 int periods; /* current count of periods registerd in the DMA engine */
131 int tx_spin; /* are we recoding - flag used to do DMA trans. for sync */ 131 int tx_spin; /* are we recoding - flag used to do DMA trans. for sync */
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 66e24b5da469..6ea67b16c676 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -3027,7 +3027,7 @@ static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area,
3027 struct page * page; 3027 struct page * page;
3028 3028
3029 if (substream == NULL) 3029 if (substream == NULL)
3030 return NOPAGE_OOM; 3030 return NOPAGE_SIGBUS;
3031 runtime = substream->runtime; 3031 runtime = substream->runtime;
3032 page = virt_to_page(runtime->status); 3032 page = virt_to_page(runtime->status);
3033 get_page(page); 3033 get_page(page);
@@ -3070,7 +3070,7 @@ static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area,
3070 struct page * page; 3070 struct page * page;
3071 3071
3072 if (substream == NULL) 3072 if (substream == NULL)
3073 return NOPAGE_OOM; 3073 return NOPAGE_SIGBUS;
3074 runtime = substream->runtime; 3074 runtime = substream->runtime;
3075 page = virt_to_page(runtime->control); 3075 page = virt_to_page(runtime->control);
3076 get_page(page); 3076 get_page(page);
@@ -3131,18 +3131,18 @@ static struct page *snd_pcm_mmap_data_nopage(struct vm_area_struct *area,
3131 size_t dma_bytes; 3131 size_t dma_bytes;
3132 3132
3133 if (substream == NULL) 3133 if (substream == NULL)
3134 return NOPAGE_OOM; 3134 return NOPAGE_SIGBUS;
3135 runtime = substream->runtime; 3135 runtime = substream->runtime;
3136 offset = area->vm_pgoff << PAGE_SHIFT; 3136 offset = area->vm_pgoff << PAGE_SHIFT;
3137 offset += address - area->vm_start; 3137 offset += address - area->vm_start;
3138 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); 3138 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
3139 dma_bytes = PAGE_ALIGN(runtime->dma_bytes); 3139 dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
3140 if (offset > dma_bytes - PAGE_SIZE) 3140 if (offset > dma_bytes - PAGE_SIZE)
3141 return NOPAGE_SIGBUS; 3141 return NOPAGE_SIGBUS;
3142 if (substream->ops->page) { 3142 if (substream->ops->page) {
3143 page = substream->ops->page(substream, offset); 3143 page = substream->ops->page(substream, offset);
3144 if (! page) 3144 if (! page)
3145 return NOPAGE_OOM; 3145 return NOPAGE_OOM; /* XXX: is this really due to OOM? */
3146 } else { 3146 } else {
3147 vaddr = runtime->dma_area + offset; 3147 vaddr = runtime->dma_area + offset;
3148 page = virt_to_page(vaddr); 3148 page = virt_to_page(vaddr);
diff --git a/sound/oss/Kconfig b/sound/oss/Kconfig
index cc2b9ab7f4e5..a0588c21324a 100644
--- a/sound/oss/Kconfig
+++ b/sound/oss/Kconfig
@@ -5,20 +5,6 @@
5# 5#
6# Prompt user for primary drivers. 6# Prompt user for primary drivers.
7 7
8config OSS_OBSOLETE_DRIVER
9 bool "Obsolete OSS drivers"
10 depends on SOUND_PRIME
11 help
12 This option enables support for obsolete OSS drivers that
13 are scheduled for removal in the near future since there
14 are ALSA drivers for the same hardware.
15
16 Please contact Adrian Bunk <bunk@stusta.de> if you had to
17 say Y here because your soundcard is not properly supported
18 by ALSA.
19
20 If unsure, say N.
21
22config SOUND_BT878 8config SOUND_BT878
23 tristate "BT878 audio dma" 9 tristate "BT878 audio dma"
24 depends on SOUND_PRIME && PCI 10 depends on SOUND_PRIME && PCI
@@ -35,40 +21,6 @@ config SOUND_BT878
35 To compile this driver as a module, choose M here: the module will 21 To compile this driver as a module, choose M here: the module will
36 be called btaudio. 22 be called btaudio.
37 23
38config SOUND_EMU10K1
39 tristate "Creative SBLive! (EMU10K1)"
40 depends on SOUND_PRIME && PCI && OSS_OBSOLETE_DRIVER
41 ---help---
42 Say Y or M if you have a PCI sound card using the EMU10K1 chipset,
43 such as the Creative SBLive!, SB PCI512 or Emu-APS.
44
45 For more information on this driver and the degree of support for
46 the different card models please check:
47
48 <http://sourceforge.net/projects/emu10k1/>
49
50 It is now possible to load dsp microcode patches into the EMU10K1
51 chip. These patches are used to implement real time sound
52 processing effects which include for example: signal routing,
53 bass/treble control, AC3 passthrough, ...
54 Userspace tools to create new patches and load/unload them can be
55 found in the emu-tools package at the above URL.
56
57config MIDI_EMU10K1
58 bool "Creative SBLive! MIDI (EXPERIMENTAL)"
59 depends on SOUND_EMU10K1 && EXPERIMENTAL && ISA_DMA_API
60 help
61 Say Y if you want to be able to use the OSS /dev/sequencer
62 interface. This code is still experimental.
63
64config SOUND_FUSION
65 tristate "Crystal SoundFusion (CS4280/461x)"
66 depends on SOUND_PRIME && PCI && OSS_OBSOLETE_DRIVER
67 help
68 This module drives the Crystal SoundFusion devices (CS4280/46xx
69 series) when wired as native sound drivers with AC97 codecs. If
70 this driver does not work try the CS4232 driver.
71
72config SOUND_BCM_CS4297A 24config SOUND_BCM_CS4297A
73 tristate "Crystal Sound CS4297a (for Swarm)" 25 tristate "Crystal Sound CS4297a (for Swarm)"
74 depends on SOUND_PRIME && SIBYTE_SWARM 26 depends on SOUND_PRIME && SIBYTE_SWARM
@@ -448,47 +400,6 @@ config SOUND_DMAP
448 400
449 Say Y unless you have 16MB or more RAM or a PCI sound card. 401 Say Y unless you have 16MB or more RAM or a PCI sound card.
450 402
451config SOUND_AD1816
452 tristate "AD1816(A) based cards (EXPERIMENTAL)"
453 depends on EXPERIMENTAL && SOUND_OSS && OSS_OBSOLETE_DRIVER
454 help
455 Say M here if you have a sound card based on the Analog Devices
456 AD1816(A) chip.
457
458 If you compile the driver into the kernel, you have to add
459 "ad1816=<io>,<irq>,<dma>,<dma2>" to the kernel command line.
460
461config SOUND_AD1889
462 tristate "AD1889 based cards (AD1819 codec) (EXPERIMENTAL)"
463 depends on EXPERIMENTAL && SOUND_OSS && PCI && OSS_OBSOLETE_DRIVER
464 help
465 Say M here if you have a sound card based on the Analog Devices
466 AD1889 chip.
467
468config SOUND_ADLIB
469 tristate "Adlib Cards"
470 depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
471 help
472 Includes ASB 64 4D. Information on programming AdLib cards is
473 available at <http://www.itsnet.com/home/ldragon/Specs/adlib.html>.
474
475config SOUND_ACI_MIXER
476 tristate "ACI mixer (miroSOUND PCM1-pro/PCM12/PCM20)"
477 depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
478 ---help---
479 ACI (Audio Command Interface) is a protocol used to communicate with
480 the microcontroller on some sound cards produced by miro and
481 Cardinal Technologies. The main function of the ACI is to control
482 the mixer and to get a product identification.
483
484 This VoxWare ACI driver currently supports the ACI functions on the
485 miroSOUND PCM1-pro, PCM12 and PCM20 radio. On the PCM20 radio, ACI
486 also controls the radio tuner. This is supported in the video4linux
487 miropcm20 driver (say M or Y here and go back to "Multimedia
488 devices" -> "Radio Adapters").
489
490 This driver is also available as a module and will be called aci.
491
492config SOUND_CS4232 403config SOUND_CS4232
493 tristate "Crystal CS4232 based (PnP) cards" 404 tristate "Crystal CS4232 based (PnP) cards"
494 depends on SOUND_OSS 405 depends on SOUND_OSS
@@ -594,18 +505,6 @@ config SOUND_MPU401
594 If you compile the driver into the kernel, you have to add 505 If you compile the driver into the kernel, you have to add
595 "mpu401=<io>,<irq>" to the kernel command line. 506 "mpu401=<io>,<irq>" to the kernel command line.
596 507
597config SOUND_NM256
598 tristate "NM256AV/NM256ZX audio support"
599 depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
600 help
601 Say M here to include audio support for the NeoMagic 256AV/256ZX
602 chipsets. These are the audio chipsets found in the Sony
603 Z505S/SX/DX, some Sony F-series, and the Dell Latitude CPi and CPt
604 laptops. It includes support for an AC97-compatible mixer and an
605 apparently proprietary sound engine.
606
607 See <file:Documentation/sound/oss/NM256> for further information.
608
609config SOUND_PAS 508config SOUND_PAS
610 tristate "ProAudioSpectrum 16 support" 509 tristate "ProAudioSpectrum 16 support"
611 depends on SOUND_OSS 510 depends on SOUND_OSS
@@ -714,20 +613,6 @@ config SOUND_YM3812
714 613
715 If unsure, say Y. 614 If unsure, say Y.
716 615
717config SOUND_OPL3SA2
718 tristate "Yamaha OPL3-SA2 and SA3 based PnP cards"
719 depends on SOUND_OSS && OSS_OBSOLETE_DRIVER
720 help
721 Say Y or M if you have a card based on one of these Yamaha sound
722 chipsets or the "SAx", which is actually a SA3. Read
723 <file:Documentation/sound/oss/OPL3-SA2> for more information on
724 configuring these cards.
725
726 If you compile the driver into the kernel and do not also
727 configure in the optional ISA PnP support, you will have to add
728 "opl3sa2=<io>,<irq>,<dma>,<dma2>,<mssio>,<mpuio>" to the kernel
729 command line.
730
731config SOUND_UART6850 616config SOUND_UART6850
732 tristate "6850 UART support" 617 tristate "6850 UART support"
733 depends on SOUND_OSS 618 depends on SOUND_OSS
diff --git a/sound/oss/btaudio.c b/sound/oss/btaudio.c
index 6ad384114239..ad7210a00dc0 100644
--- a/sound/oss/btaudio.c
+++ b/sound/oss/btaudio.c
@@ -1020,6 +1020,7 @@ static int __devinit btaudio_probe(struct pci_dev *pci_dev,
1020 fail2: 1020 fail2:
1021 free_irq(bta->irq,bta); 1021 free_irq(bta->irq,bta);
1022 fail1: 1022 fail1:
1023 iounmap(bta->mmio);
1023 kfree(bta); 1024 kfree(bta);
1024 fail0: 1025 fail0:
1025 release_mem_region(pci_resource_start(pci_dev,0), 1026 release_mem_region(pci_resource_start(pci_dev,0),
@@ -1051,6 +1052,7 @@ static void __devexit btaudio_remove(struct pci_dev *pci_dev)
1051 free_irq(bta->irq,bta); 1052 free_irq(bta->irq,bta);
1052 release_mem_region(pci_resource_start(pci_dev,0), 1053 release_mem_region(pci_resource_start(pci_dev,0),
1053 pci_resource_len(pci_dev,0)); 1054 pci_resource_len(pci_dev,0));
1055 iounmap(bta->mmio);
1054 1056
1055 /* remove from linked list */ 1057 /* remove from linked list */
1056 if (bta == btaudios) { 1058 if (bta == btaudios) {
diff --git a/sound/oss/emu10k1/audio.c b/sound/oss/emu10k1/audio.c
index 86dd23974e05..49f902f35c28 100644
--- a/sound/oss/emu10k1/audio.c
+++ b/sound/oss/emu10k1/audio.c
@@ -111,9 +111,15 @@ static ssize_t emu10k1_audio_read(struct file *file, char __user *buffer, size_t
111 111
112 if ((bytestocopy >= wiinst->buffer.fragment_size) 112 if ((bytestocopy >= wiinst->buffer.fragment_size)
113 || (bytestocopy >= count)) { 113 || (bytestocopy >= count)) {
114 int rc;
115
114 bytestocopy = min_t(u32, bytestocopy, count); 116 bytestocopy = min_t(u32, bytestocopy, count);
115 117
116 emu10k1_wavein_xferdata(wiinst, (u8 __user *)buffer, &bytestocopy); 118 rc = emu10k1_wavein_xferdata(wiinst,
119 (u8 __user *)buffer,
120 &bytestocopy);
121 if (rc)
122 return rc;
117 123
118 count -= bytestocopy; 124 count -= bytestocopy;
119 buffer += bytestocopy; 125 buffer += bytestocopy;
diff --git a/sound/oss/emu10k1/cardwi.c b/sound/oss/emu10k1/cardwi.c
index 8bbf44b881b4..060d1be94d33 100644
--- a/sound/oss/emu10k1/cardwi.c
+++ b/sound/oss/emu10k1/cardwi.c
@@ -304,11 +304,12 @@ void emu10k1_wavein_getxfersize(struct wiinst *wiinst, u32 * size)
304 } 304 }
305} 305}
306 306
307static void copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov) 307static int copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov)
308{ 308{
309 if (cov == 1) 309 if (cov == 1) {
310 __copy_to_user(dst, src + str, len); 310 if (__copy_to_user(dst, src + str, len))
311 else { 311 return -EFAULT;
312 } else {
312 u8 byte; 313 u8 byte;
313 u32 i; 314 u32 i;
314 315
@@ -316,22 +317,26 @@ static void copy_block(u8 __user *dst, u8 * src, u32 str, u32 len, u8 cov)
316 317
317 for (i = 0; i < len; i++) { 318 for (i = 0; i < len; i++) {
318 byte = src[2 * i] ^ 0x80; 319 byte = src[2 * i] ^ 0x80;
319 __copy_to_user(dst + i, &byte, 1); 320 if (__copy_to_user(dst + i, &byte, 1))
321 return -EFAULT;
320 } 322 }
321 } 323 }
324
325 return 0;
322} 326}
323 327
324void emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size) 328int emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size)
325{ 329{
326 struct wavein_buffer *buffer = &wiinst->buffer; 330 struct wavein_buffer *buffer = &wiinst->buffer;
327 u32 sizetocopy, sizetocopy_now, start; 331 u32 sizetocopy, sizetocopy_now, start;
328 unsigned long flags; 332 unsigned long flags;
333 int ret;
329 334
330 sizetocopy = min_t(u32, buffer->size, *size); 335 sizetocopy = min_t(u32, buffer->size, *size);
331 *size = sizetocopy; 336 *size = sizetocopy;
332 337
333 if (!sizetocopy) 338 if (!sizetocopy)
334 return; 339 return 0;
335 340
336 spin_lock_irqsave(&wiinst->lock, flags); 341 spin_lock_irqsave(&wiinst->lock, flags);
337 start = buffer->pos; 342 start = buffer->pos;
@@ -345,11 +350,17 @@ void emu10k1_wavein_xferdata(struct wiinst *wiinst, u8 __user *data, u32 * size)
345 if (sizetocopy > sizetocopy_now) { 350 if (sizetocopy > sizetocopy_now) {
346 sizetocopy -= sizetocopy_now; 351 sizetocopy -= sizetocopy_now;
347 352
348 copy_block(data, buffer->addr, start, sizetocopy_now, buffer->cov); 353 ret = copy_block(data, buffer->addr, start, sizetocopy_now,
349 copy_block(data + sizetocopy_now, buffer->addr, 0, sizetocopy, buffer->cov); 354 buffer->cov);
355 if (ret == 0)
356 ret = copy_block(data + sizetocopy_now, buffer->addr, 0,
357 sizetocopy, buffer->cov);
350 } else { 358 } else {
351 copy_block(data, buffer->addr, start, sizetocopy, buffer->cov); 359 ret = copy_block(data, buffer->addr, start, sizetocopy,
360 buffer->cov);
352 } 361 }
362
363 return ret;
353} 364}
354 365
355void emu10k1_wavein_update(struct emu10k1_card *card, struct wiinst *wiinst) 366void emu10k1_wavein_update(struct emu10k1_card *card, struct wiinst *wiinst)
diff --git a/sound/oss/emu10k1/cardwi.h b/sound/oss/emu10k1/cardwi.h
index 15cfb9b35596..e82029b46ad1 100644
--- a/sound/oss/emu10k1/cardwi.h
+++ b/sound/oss/emu10k1/cardwi.h
@@ -83,7 +83,7 @@ void emu10k1_wavein_close(struct emu10k1_wavedevice *);
83void emu10k1_wavein_start(struct emu10k1_wavedevice *); 83void emu10k1_wavein_start(struct emu10k1_wavedevice *);
84void emu10k1_wavein_stop(struct emu10k1_wavedevice *); 84void emu10k1_wavein_stop(struct emu10k1_wavedevice *);
85void emu10k1_wavein_getxfersize(struct wiinst *, u32 *); 85void emu10k1_wavein_getxfersize(struct wiinst *, u32 *);
86void emu10k1_wavein_xferdata(struct wiinst *, u8 __user *, u32 *); 86int emu10k1_wavein_xferdata(struct wiinst *, u8 __user *, u32 *);
87int emu10k1_wavein_setformat(struct emu10k1_wavedevice *, struct wave_format *); 87int emu10k1_wavein_setformat(struct emu10k1_wavedevice *, struct wave_format *);
88void emu10k1_wavein_update(struct emu10k1_card *, struct wiinst *); 88void emu10k1_wavein_update(struct emu10k1_card *, struct wiinst *);
89 89
diff --git a/sound/oss/emu10k1/passthrough.c b/sound/oss/emu10k1/passthrough.c
index 4e3baca7d41f..6d21d4368dec 100644
--- a/sound/oss/emu10k1/passthrough.c
+++ b/sound/oss/emu10k1/passthrough.c
@@ -162,12 +162,15 @@ ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t co
162 162
163 DPD(3, "prepend size %d, prepending %d bytes\n", pt->prepend_size, needed); 163 DPD(3, "prepend size %d, prepending %d bytes\n", pt->prepend_size, needed);
164 if (count < needed) { 164 if (count < needed) {
165 copy_from_user(pt->buf + pt->prepend_size, buffer, count); 165 if (copy_from_user(pt->buf + pt->prepend_size,
166 buffer, count))
167 return -EFAULT;
166 pt->prepend_size += count; 168 pt->prepend_size += count;
167 DPD(3, "prepend size now %d\n", pt->prepend_size); 169 DPD(3, "prepend size now %d\n", pt->prepend_size);
168 return count; 170 return count;
169 } 171 }
170 copy_from_user(pt->buf + pt->prepend_size, buffer, needed); 172 if (copy_from_user(pt->buf + pt->prepend_size, buffer, needed))
173 return -EFAULT;
171 r = pt_putblock(wave_dev, (u16 *) pt->buf, nonblock); 174 r = pt_putblock(wave_dev, (u16 *) pt->buf, nonblock);
172 if (r) 175 if (r)
173 return r; 176 return r;
@@ -178,7 +181,8 @@ ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t co
178 blocks_copied = 0; 181 blocks_copied = 0;
179 while (blocks > 0) { 182 while (blocks > 0) {
180 u16 __user *bufptr = (u16 __user *) buffer + (bytes_copied/2); 183 u16 __user *bufptr = (u16 __user *) buffer + (bytes_copied/2);
181 copy_from_user(pt->buf, bufptr, PT_BLOCKSIZE); 184 if (copy_from_user(pt->buf, bufptr, PT_BLOCKSIZE))
185 return -EFAULT;
182 r = pt_putblock(wave_dev, (u16 *)pt->buf, nonblock); 186 r = pt_putblock(wave_dev, (u16 *)pt->buf, nonblock);
183 if (r) { 187 if (r) {
184 if (bytes_copied) 188 if (bytes_copied)
@@ -193,7 +197,8 @@ ssize_t emu10k1_pt_write(struct file *file, const char __user *buffer, size_t co
193 i = count - bytes_copied; 197 i = count - bytes_copied;
194 if (i) { 198 if (i) {
195 pt->prepend_size = i; 199 pt->prepend_size = i;
196 copy_from_user(pt->buf, buffer + bytes_copied, i); 200 if (copy_from_user(pt->buf, buffer + bytes_copied, i))
201 return -EFAULT;
197 bytes_copied += i; 202 bytes_copied += i;
198 DPD(3, "filling prepend buffer with %d bytes", i); 203 DPD(3, "filling prepend buffer with %d bytes", i);
199 } 204 }
diff --git a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
index 17837d4b5ed3..c96cc8c68b3b 100644
--- a/sound/oss/via82cxxx_audio.c
+++ b/sound/oss/via82cxxx_audio.c
@@ -2120,8 +2120,8 @@ static struct page * via_mm_nopage (struct vm_area_struct * vma,
2120 return NOPAGE_SIGBUS; /* Disallow mremap */ 2120 return NOPAGE_SIGBUS; /* Disallow mremap */
2121 } 2121 }
2122 if (!card) { 2122 if (!card) {
2123 DPRINTK ("EXIT, returning NOPAGE_OOM\n"); 2123 DPRINTK ("EXIT, returning NOPAGE_SIGBUS\n");
2124 return NOPAGE_OOM; /* Nothing allocated */ 2124 return NOPAGE_SIGBUS; /* Nothing allocated */
2125 } 2125 }
2126 2126
2127 pgoff = vma->vm_pgoff + ((address - vma->vm_start) >> PAGE_SHIFT); 2127 pgoff = vma->vm_pgoff + ((address - vma->vm_start) >> PAGE_SHIFT);
diff --git a/sound/usb/usx2y/usX2Yhwdep.c b/sound/usb/usx2y/usX2Yhwdep.c
index 4b52d18dcd53..b76b3dd9df25 100644
--- a/sound/usb/usx2y/usX2Yhwdep.c
+++ b/sound/usb/usx2y/usX2Yhwdep.c
@@ -48,7 +48,7 @@ static struct page * snd_us428ctls_vm_nopage(struct vm_area_struct *area, unsign
48 48
49 offset = area->vm_pgoff << PAGE_SHIFT; 49 offset = area->vm_pgoff << PAGE_SHIFT;
50 offset += address - area->vm_start; 50 offset += address - area->vm_start;
51 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM); 51 snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_SIGBUS);
52 vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset; 52 vaddr = (char*)((struct usX2Ydev *)area->vm_private_data)->us428ctls_sharedmem + offset;
53 page = virt_to_page(vaddr); 53 page = virt_to_page(vaddr);
54 get_page(page); 54 get_page(page);